| ll4_inv | R Documentation |
Applies the inverse of the ll4 transformation.
Given y = ll4(x), this function calculates x = (base^(y * lambda) - 1)^(1/lambda).
ll4_inv(y, lambda = 4, base = 10)
y |
A numeric vector or scalar of transformed values (output from |
lambda |
A positive numeric scalar, the lambda parameter used in the original
|
base |
A positive numeric scalar, the base of the logarithm used in the
original |
A numeric vector or scalar of the original, untransformed values.
May return NaN if (base^(y * lambda) - 1) is negative and 1/lambda implies
an even root (e.g., if lambda is 2 or 4).
original_values <- c(0, 1, 10, 100, 1000)
transformed_values <- ll4(original_values)
back_transformed_values <- ll4_inv(transformed_values)
print(data.frame(original_values, transformed_values, back_transformed_values))
all.equal(original_values, back_transformed_values) # Should be TRUE or very close
# Example with negative y (log-transformed value)
# If y_ll4 = -0.5 (meaning original value was between 0 and 1 for log10)
ll4_inv(-0.5, lambda = 4, base = 10) # (10^(-0.5*4) - 1)^(1/4) = (0.01 - 1)^(1/4) -> NaN
# The ll4_inv function as provided will return NaN here.
# A more robust version for demand might floor at 0 if NaN occurs.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.