A function that transforms a vector of statistics or data to be approximately normally distributed.
powerTrans(
y,
eps = 0.001,
target = NULL,
interp = FALSE,
forceYJ = FALSE,
useStDev = FALSE
)A list containing the following:
The optimized lambda parameter.
The power-transformed values.
If spline interpolation is used, the values of lambda used.
If spline interpolation is used, the log-likelihoods calculated for lambda.
How additional transformation was performed: one of a linear transformation, a Yeo-Johnson transformation, or none. The result could also indicate whether standard deviates of y were used.
A vector of values to use.
Tolerance for lambda = 0.
The value to target in the distribution. (If null, the first value in the vector is used.) This will be moved to the first value in results.
Logical value for whether to spline interpolate lambda (ideal for vectors of small length). This will default if the number of values is less than 100, as in boxcox.
A logical value whether to force a Yeo-Johnson transformation for non-negative values. Negative values trigger the transformation, but positive values can be transformed similarly.
A logical value whether to initially use standard deviates of y. This might be useful if the range of y is restricted, say between 0 and 1.
Michael Collyer
This function uses a Box-Cox power transformation for a vector of values, (presumably statistics from RRPP) with the following conditions:
(1) If any values are 0 or negative, either a Yeo-Johnson transformation or a linear transformation of y - min(y) + 1e-7 is performed to optimize lambda with only positive values. There might be cases where one works better than the other. This function will determine which produces more normally distributed data, indicating which transformation was used.
(2) The lambda parameter is optimized over a range of -2 to +2, as is typical for most applications.
(3) The first (or targeted) value (assumed to be the observed value in a distribution of random values) is removed from the vector to perform optimization of lambda, but is returned to the vector for transformation. This assures that large, aberrant values, such as might be found via RRPP for large effects, do not have leverage for the optimization.
A Yeo-Johnson transformation can be forced, which for positive values merely shifts the distribution by adding 1. For most RRPP statistics (SS. MS, Rsq, F, d), this is not needed for effect sizes, as values are positive. However, for certain distributions, this might be a good idea for comparisons, because values might be strongly positive or bimodal in nature.
Using standard deviates (useStDev) is a good idea for statistics with aberrant ranges (like 0 to 1, or 1,000 to 2,000). If used, a Yeo-Johnson or linear transformation is implicit, since standardizing introduces negative values.
Box, G. E. P. and Cox, D. R. (1964) An analysis of transformations (with discussion). Journal of the Royal Statistical Society B, 26, 211–252.
Yeo, I. and Johnson, R. (2000) A new family of power transformations to improve normality or symmetry. Biometrika, 87, 954-959.