Applies a log-logistic like transformation, specifically log_base(x^lambda + 1) / lambda.
This transformation is useful for compressing data that spans several orders of
magnitude while handling zero values gracefully (as x=0 yields 0).
It's a variation related to the Box-Cox transformation or a generalized logarithm.
Value
A numeric vector or scalar of the transformed values.
Returns NaN for x < 0 if lambda results in non-real numbers (e.g., even root of negative).
However, the intended domain is x >= 0.
Examples
# Basic usage
ll4(0)
#> [1] 0
ll4(1)
#> [1] 0.0752575
ll4(10)
#> [1] 1.000011
ll4(c(0, 1, 10, 100, 1000))
#> [1] 0.0000000 0.0752575 1.0000109 2.0000000 3.0000000
# Using a different lambda or base
ll4(10, lambda = 2)
#> [1] 1.002161
ll4(10, base = exp(1)) # Natural log base
#> [1] 2.30261
# Typical workflow: transform -> fit -> back-transform
data(apt)
apt$y_ll4 <- ll4(apt$y)
# Verify round-trip: ll4_inv(ll4(x)) == x
all.equal(apt$y, ll4_inv(apt$y_ll4))
#> [1] TRUE
