Description Usage Arguments Details Value Examples
Generalized Box-Cox transformation.
1 2 |
x |
Vector of quantiles at which to compute the transformation. |
lambda |
Exponent of the transformation. See Details. |
alpha |
Offset of the transformation. See Details. |
normalize |
Logical; if |
jacobian |
Logical; if |
The Generalized Power or Box-Cox transformation is
z = \begin{array}{rl} ((x + α)^λ - 1) / (λ C^{λ-1}) & λ \neq 0 \ C \log(x + α) & λ = 0, \end{array}
where C is the Geometric mean, i.e., C = exp(mean(log(x + alpha)))
. Note that C
is only calculated if normalize = TRUE
.
The vector z
of transformed values, and optionally the Jacobian of the inverse transformation. See Details.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # generate data and plot
# apply power transform and superimpose on plot
# finally, superimpose N(0, 1) on plot
n <- 1e5
df <- 5
X <- rchisq(n, df = df)
xdens <- kernelXD(X)
xdens.trans <- kernelXD(powTrans(X))
# plots
curve(dnorm(x), col = "blue", xlim=c(-5, 5), ylim = c(0,0.7)) # true PDF
curve(dXD(x, xDens = xdens), add = TRUE, col = "red") # xDensity PDF
curve(dXD(x, xDens = xdens.trans), add = TRUE, col = "black") # xDensity PDF
legend("topleft", c("N(0, 1", "Chi-Sq(4)", "Power Trans"),
pch = c(22,22,22,NA), pt.cex = 1.5,
pt.bg = c("blue", "red", "black"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.