Description Usage Arguments Details Value Author(s) References See Also Examples
Transform the elements of a vector using, the skew power transformations.
1 2 3 4 5 6 7 8 9  | skewPower(U, lambda, jacobian.adjusted=FALSE, gamma)
## S3 method for class 'skewpowerTransform'
contour(x, ksds = 4, levels = c(0.5, 0.95, 0.99, 0.999), 
                 main = "Skew Power Log-likelihood", ...)
                 
## S3 method for class 'skewpowerTransformlmer'
contour(x, ksds = 4, levels = c(0.5, 0.95, 0.99, 0.999), 
                 main = "Skew Power Log-likelihood", ...)
 | 
U | 
 A vector, matrix or data.frame of values to be transformed  | 
lambda | 
 The one-dimensional transformation parameter, usually in 
the range from -2 to 2, or if   | 
jacobian.adjusted | 
 If   | 
gamma | 
 The skew power family has two parameters, the power lambda, and the start gamma, which can be any positive value.  | 
x | 
 An object created by a call to   | 
ksds | 
 Contour plotting of the log-likelihood surface will cover plus of minus   | 
levels | 
 Contours will be drawn at the values of levels.  For example,   | 
main | 
 Title for the contour plot  | 
... | 
 Additional arguments passed to the generic contour function.  | 
The skewPower family is a modification of the Box-Cox power family, see bcPower that allows the untransformed response to include negative values.  Ignoring the Jacobian, correction, the Box-Cox family is defined to be (U^(lambda)-1)/lambda 
for lambda not equal to zero, and 
log(U) if lambda = 0.  The skewPower family is the Box-Cox transformation of z = .5 * (U + (U^2 + γ^2)^{1/2}). Zero or negative values for \code{U} are permitted if gamma is positive. 
If jacobian.adjusted is TRUE, then the transformed values are scaled to have Jacobian equal to 1, as suggested by Box and Cox (1964).  This simplifies computing the maximum likelihood-like estimates of the transformation parameters.  
Missing values are permitted, and return NA where ever U is equal to NA.
The contour method allows drawing a contour plot for the two-dimensional log-likelihood for the skew power parameters with a univariate response.
Returns a vector or matrix of transformed values. The contour method is used for the side-effect of drawing a contour plot.
Sanford Weisberg, <sandy@umn.edu>
Fox, J. and Weisberg, S. (2011) An R Companion to Applied Regression, Second Edition, Sage.
Hawkins, D. and Weisberg, S. (2016) Combining the Box-Cox Power and Generalized Log Transformations to Accomodate Negative Responses In Linear and Mixed-Effects Linear Models, submitted for publication.
Weisberg, S. (2014) Applied Linear Regression, Fourth Edition, Wiley Wiley, Chapter 7.
powerTransform, bcPower, boxCox
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44  | # Univariate Example, from Hawkins and Weisberg (2016)
m1 <- lm(I1L1 ~ pool, LoBD)
p1 <- powerTransform(m1, family="skewPower")
summary(p1)
# summary prints estimate, se and conf.ints for both parameters
# helper functions
c(p1$lambda, p1$gamma, LogLik=p1$llik)
vcov(p1) # Estimated covarinace from inverse Hessian
# tests are for lambda, maximizing over gamma (profile log-likelihoods
testTransform(p1, lambda=0.5)
# Contour plot of the log-likelihood
contour(p1, main="", levels=c(.5, .95, .99))
# the boxCox function can provide profile log-likelihoods for each of the two parameters:
boxCox(m1, family="skewPower", param="lambda", lambda=seq(0.25, 1.1, length=100))
boxCox(m1, family="skewPower", param="gamma", gamma=seq(3, 80, length=100))
# Fit with fixed gamma, in this case fixed at the estimate from p1
p2 <- powerTransform(m1, family="skewPower", gamma=p1$gamma)
# summary gives different tests because gamma is fixed rather than maximized over
summary(p2)
# Multivariate Response
p3 <- powerTransform(update(m1, as.matrix(cbind(LoBD$I1L2, LoBD$I1L1)) ~ .), 
     family="skewPower")
summary(p3)
# gamma fixed
p4 <- powerTransform(update(m1, as.matrix(cbind(LoBD$I1L2, LoBD$I1L1)) ~ .), 
     family="skewPower", gamma=p3$gamma)
summary(p4)
# mixed models fit with lmer - requires lmer and nloptr packages
## Not run: 
data <- reshape(LoBD[1:20,], varying=names(LoBD)[-1], direction="long", v.names="y")
names(data) <- c("pool", "assay", "y", "id")
data$assay <- factor(data$assay)
require(lme4)
m2 <- lmer(y ~ pool + (1|assay), data)
f1 <- powerTransform(m2, family="skewPower")
summary(f1)
f2 <- powerTransform(m2, family="skewPower", gamma= 10)
summary(f2)
## End(Not run)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.