View source: R/back-transform.R
| pm_boxcox | R Documentation |
Power transformations to use for the response in a model formula, e.g.
lm(pm_boxcox(y, 0.25) ~ A). predictmeans and covariatemeans recognise them
(as they recognise log(y), log(y + c), log10(y), log2(y), log1p(y),
sqrt(y), y^p, 1/y, qlogis(y) and asin(sqrt(y))) and give the means
back-transformed to the original scale as well; bias_adjust = TRUE there gives the mean rather than the
median of the original scale.
pm_boxcox(y, lambda)
pm_yeojohnson(y, lambda)
y |
A numeric vector; positive for |
lambda |
The power: one number. Box-Cox: 1 leaves the shape of |
Box-Cox: (y^\lambda - 1)/\lambda, and \log y for \lambda = 0. Yeo-Johnson (2000): the same for
y + 1 when y \ge 0, and -((1 - y)^{2 - \lambda} - 1)/(2 - \lambda) (-\log(1 - y) for
\lambda = 2) when y < 0, so zero and negative values are allowed.
Choose a transformation from the residuals of the model, not from the raw response, and prefer a generalized linear (mixed) model for counts and proportions.
The transformed values.
Dongwen Luo, Siva Ganesh and John Koolaard
Box, G. E. P. and Cox, D. R. (1964), An analysis of transformations, Journal of the Royal Statistical Society B, 26(2), 211-252.
Yeo, I.-K. and Johnson, R. A. (2000), A new family of power transformations to improve normality or symmetry, Biometrika, 87(4), 954-959.
predictmeans, pm_check
library(predictmeans)
Oats <- as.data.frame(nlme::Oats)
Oats$nitro <- factor(Oats$nitro)
fm <- lm(pm_boxcox(yield, 0.5) ~ Block + nitro, data = Oats)
predictmeans(fm, "nitro", plot = FALSE)$means
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.