transfo {cellWise}  R Documentation 
This function uses reweighted maximum likelihood to robustly fit the
BoxCox or YeoJohnson transformation to each variable in a dataset.
Note that this function first calls checkDataSet
to ensure that the variables to be transformed are not too discrete.
transfo(X, type = "YJ", robust = TRUE, lambdarange = NULL, prestandardize = TRUE, prescaleBC = F, scalefac = 1, quant = 0.99, nbsteps = 2, checkPars = list())
X 
A data matrix of dimensions n x d. Its columns are the variables to be transformed. 
type 
The type of transformation to be fit. Should be one of:

robust 
if 
lambdarange 
range of lambda values that will be optimized over.
If 
prestandardize 
whether to standardize the variables before the
power transformation.For BC the variable is divided by its median.
For YJ and 
prescaleBC 
for BC only. This standardizes the logarithm of the original variable by subtracting its median and dividing by its mad, after which the exponential function turns the result into a positive variable again. 
scalefac 
when YJ is fit and 
quant 
quantile for determining the weights in the
reweighting step (ignored when 
nbsteps 
number of reweighting steps (ignored when

checkPars 
Optional list of parameters used in the call to

A list with components:
lambdahats
the estimated transformation parameter for each column of X
.
Xt
A matrix in which each column is the transformed version of the
corresponding column of X
.
muhat
The estimated location of each column of Xt
.
sigmahat
The estimated scale of each column of Xt
.
Zt
Xt
poststandardized by the centers in muhat
and the
scales in sigmahat
. Is always provided.
weights
The final weights from the reweighting.
ttypes
The type of transform used in each column.
objective
Value of the (reweighted) maximum likelihood objective function.
J. Raymaekers and P.J. Rousseeuw
J. Raymaekers and P.J. Rousseeuw (2020). Transforming variables to central normality. Arxiv: 2005.07946. (link to open access pdf)
# find BoxCox transformation parameter for lognormal data: set.seed(123) x < exp(rnorm(1000)) transfo.out < transfo(x, type = "BC") # estimated parameter: transfo.out$lambdahat # value of the objective function: transfo.out$objective # the transformed variable: transfo.out$Xt # the poststandardized transformed variable: transfo.out$Zt # the type of transformation used: transfo.out$ttypes # qqplot of the poststandardized transformed variable: qqnorm(transfo.out$Zt); abline(0,1) # For more examples, we refer to the vignette: vignette("transfo_examples")