Package 'Transform'

Title: Statistical Transformations
Description: Performs various statistical transformations; Box-Cox and Log (Box and Cox, 1964) <doi:10.1111/j.2517-6161.1964.tb00553.x>, Glog (Durbin et al., 2002) <doi:10.1093/bioinformatics/18.suppl_1.S105>, Neglog (Whittaker et al., 2005) <doi:10.1111/j.1467-9876.2005.00520.x>, Reciprocal (Tukey, 1957), Log Shift (Feng et al., 2016) <doi:10.1002/sta4.104>, Bickel-Docksum (Bickel and Doksum, 1981) <doi:10.1080/01621459.1981.10477649>, Yeo-Johnson (Yeo and Johnson, 2000) <doi:10.1093/biomet/87.4.954>, Square Root (Medina et al., 2019), Manly (Manly, 1976) <doi:10.2307/2988129>, Modulus (John and Draper, 1980) <doi:10.2307/2986305>, Dual (Yang, 2006) <doi:10.1016/j.econlet.2006.01.011>, Gpower (Kelmansky et al., 2013) <doi:10.1515/sagmb-2012-0030>. It also performs graphical approaches, assesses the success of the transformation via tests and plots.
Authors: Muge Coskun Yildirim [aut], Osman Dag [aut, cre]
Maintainer: Osman Dag <[email protected]>
License: GPL (>= 2)
Version: 1.0
Built: 2025-01-30 05:06:56 UTC
Source: https://github.com/cran/Transform

Help Index


Box-Cox Transformation for Normality

Description

bcTransform performs Box-Cox transformation for normality of a variable and provides graphical analysis.

Usage

bcTransform(data, lambda = seq(-3,3,0.01), lambda2 = NULL, plot = TRUE, 
  alpha = 0.05, verbose = TRUE)

Arguments

data

a numeric vector of data values.

lambda

a vector which includes the sequence of candidate lambda values. Default is set to (-3,3) with increment 0.01.

lambda2

a numeric for an additional shifting parameter. Default is set to lambda2 = NULL.

plot

a logical to plot histogram with its density line and qqplot of raw and transformed data. Defaults plot = TRUE.

alpha

the level of significance to check the normality after transformation. Default is set to alpha = 0.05.

verbose

a logical for printing output to R console.

Details

Denote yy the variable at the original scale and yy' the transformed variable. The Box-Cox power transformation is defined by:

y={yλ1λ , if λ0log(y) , if λ=0y' = \left\{ \begin{array}{ll} \frac{y^\lambda - 1}{\lambda} \mbox{ , if $\lambda \neq 0$} \cr log(y) \mbox{ , if $\lambda = 0$} \end{array} \right.

If the data include any non- positive observations, a shifting parameter λ2\lambda_2 can be included in the transformation given by:

y={(y+λ2)λ1λ , if λ0log(y+λ2) , if λ=0y' = \left\{ \begin{array}{ll} \frac{(y + \lambda_2)^\lambda - 1}{\lambda} \mbox{ , if $\lambda \neq 0$} \cr log(y + \lambda_2) \mbox{ , if $\lambda = 0$} \end{array} \right.

Value

A list with class "bc" containing the following elements:

method

method to estimate Box-Cox transformation parameter

lambda.hat

estimate of Box-Cox Power transformation parameter

lambda2

additional shifting parameter

statistic

Shapiro-Wilk test statistic for transformed data

p.value

Shapiro-Wilk test p.value for transformed data

alpha

level of significance to assess normality

tf.data

transformed data set

var.name

variable name

Author(s)

Muge Coskun Yildirim, Osman Dag

References

Asar, O., Ilk, O., Dag, O. (2017). Estimating Box-Cox Power Transformation Parameter via Goodness of Fit Tests. Communications in Statistics - Simulation and Computation, 46:1, 91–105.

Box, G.E., Cox, D.R. (1964). An Analysis of Transformations. Journal of the Royal Statistical Society: Series B (Methodological), 26:2, 211–43.

Examples

data <- cars$dist

library(Transform)
out <- bcTransform(data)
out$lambda.hat # the estimate of Box-Cox parameter based on Shapiro-Wilk test statistic 
out$p.value # p.value of Shapiro-Wilk test for transformed data 
out$tf.data # transformed data set

Bickel-Docksum Transformation for Normality

Description

bdTransform performs Bickel-Docksum transformation for normality of a variable and provides graphical analysis.

Usage

bdTransform(data, lambda = seq(0.01,6,0.01), plot = TRUE, alpha = 0.05, 
  verbose = TRUE)

Arguments

data

a numeric vector of data values.

lambda

a vector which includes the sequence of candidate lambda values. Default is set to (0.01,6) with increment 0.01.

plot

a logical to plot histogram with its density line and qqplot of raw and transformed data. Defaults plot = TRUE.

alpha

the level of significance to check the normality after transformation. Default is set to alpha = 0.05.

verbose

a logical for printing output to R console.

Details

Denote yy the variable at the original scale and yy' the transformed variable. The Bickel-Docksum power transformation is defined by:

y=yλSign(y)1λ , if λ>0y' = \frac{|y|^\lambda Sign(y)-1}{\lambda} \mbox{ , if $\lambda > 0$}

Value

A list with class "bd" containing the following elements:

method

method to estimate Bickel-Docksum transformation parameter

lambda.hat

estimate of Bickel-Docksum transformation parameter

statistic

Shapiro-Wilk test statistic for transformed data

p.value

Shapiro-Wilk test p.value for transformed data

alpha

level of significance to assess normality

tf.data

transformed data set

var.name

variable name

Author(s)

Muge Coskun Yildirim, Osman Dag

References

Asar, O., Ilk, O., Dag, O. (2017). Estimating Box-Cox Power Transformation Parameter via Goodness of Fit Tests. Communications in Statistics - Simulation and Computation, 46:1, 91–105.

Bickel, P.J., Doksum, K.A. (1981). An Analysis of Transformations Revisited. Journal of the American Statistical Association, 76:374, 296–311.

Examples

data <- cars$dist

library(Transform)
out <- bdTransform(data)
out$lambda.hat # the estimate of Bickel-Docksum parameter based on Shapiro-Wilk test statistic 
out$p.value # p.value of Shapiro-Wilk test for transformed data 
out$tf.data # transformed data set

Dual Transformation for Normality

Description

dlTransform performs Dual transformation for normality of a variable and provides graphical analysis.

Usage

dlTransform(data, lambda = seq(0,6,0.01), plot = TRUE, alpha = 0.05, 
  verbose = TRUE)

Arguments

data

a numeric vector of data values.

lambda

a vector which includes the sequence of candidate lambda values. Default is set to (0,6) with increment 0.01.

plot

a logical to plot histogram with its density line and qqplot of raw and transformed data. Defaults plot = TRUE.

alpha

the level of significance to check the normality after transformation. Default is set to alpha = 0.05.

verbose

a logical for printing output to R console.

Details

Denote yy the variable at the original scale and yy' the transformed variable. The Dual power transformation is defined by:

y={yλyλ2λ , if λ>0log(y) , if λ=0y' = \left\{ \begin{array}{ll} \frac{y^\lambda-y^{-\lambda}}{2\lambda} \mbox{ , if $\lambda > 0$} \cr \log(y) \mbox{ , if $\lambda = 0$} \end{array} \right.

Value

A list with class "dl" containing the following elements:

method

method to estimate Dual transformation parameter

lambda.hat

estimate of Dual transformation parameter

statistic

Shapiro-Wilk test statistic for transformed data

p.value

Shapiro-Wilk test p.value for transformed data

alpha

level of significance to assess normality

tf.data

transformed data set

var.name

variable name

Author(s)

Muge Coskun Yildirim, Osman Dag

References

Asar, O., Ilk, O., Dag, O. (2017). Estimating Box-Cox Power Transformation Parameter via Goodness of Fit Tests. Communications in Statistics - Simulation and Computation, 46:1, 91–105.

Yang, Z. (2006). A Modified Family of Power Transformations. Economics Letters. 92:1, 14–9.

Examples

data <- cars$dist

library(Transform)
out <- dlTransform(data)
out$lambda.hat # the estimate of Dual parameter based on Shapiro-Wilk test statistic 
out$p.value # p.value of Shapiro-Wilk test for transformed data 
out$tf.data # transformed data set

Glog Transformation for Normality

Description

glTransform performs Glog transformation for normality of a variable and provides graphical analysis.

Usage

glTransform(data, plot = TRUE, alpha = 0.05, verbose = TRUE)

Arguments

data

a numeric vector of data values.

plot

a logical to plot histogram with its density line and qqplot of raw and transformed data. Defaults plot = TRUE.

alpha

the level of significance to check the normality after transformation. Default is set to alpha = 0.05.

verbose

a logical for printing output to R console.

Details

Denote yy the variable at the original scale and yy' the transformed variable. The Glog power transformation is defined by:

y=log(y+y2+1)y' = \log(y+ \sqrt{y^2+1})

Value

A list with class "gl" containing the following elements:

method

method name

statistic

Shapiro-Wilk test statistic for transformed data

p.value

Shapiro-Wilk test p.value for transformed data

alpha

level of significance to assess normality

tf.data

transformed data set

var.name

variable name

Author(s)

Muge Coskun Yildirim, Osman Dag

References

Asar, O., Ilk, O., Dag, O. (2017). Estimating Box-Cox Power Transformation Parameter via Goodness of Fit Tests. Communications in Statistics - Simulation and Computation, 46:1, 91–105.

Durbin, B.P., Hardin, J.S., Hawkins, D.M., Rocke, D.M. (2002). A Variance-Stabilizing Transformation for Gene-expression Microarray Data. Bioinformatics, 18(suppl_1), 105–110.

Examples

data <- cars$dist

library(Transform)
out <- glTransform(data)
out$p.value # p.value of Shapiro-Wilk test for transformed data 
out$tf.data # transformed data set

Gpower Transformation for Normality

Description

gpTransform performs Gpower transformation for normality of a variable and provides graphical analysis.

Usage

gpTransform(data, lambda = seq(-3,3,0.01), plot = TRUE, alpha = 0.05, 
  verbose = TRUE)

Arguments

data

a numeric vector of data values.

lambda

a vector which includes the sequence of candidate lambda values. Default is set to (-3,3) with increment 0.01.

plot

a logical to plot histogram with its density line and qqplot of raw and transformed data. Defaults plot = TRUE.

alpha

the level of significance to check the normality after transformation. Default is set to alpha = 0.05.

verbose

a logical for printing output to R console.

Details

Denote yy the variable at the original scale and yy' the transformed variable. The Gpower power transformation is defined by:

y={(y+y2+1)λ1λ , if λ0log(y+y2+1) , if λ=0y' = \left\{ \begin{array}{ll} \frac{({y+ \sqrt{y^2+1}})^\lambda-1}{\lambda} \mbox{ , if $\lambda \neq 0$} \cr \log({y+ \sqrt{y^2+1}}) \mbox{ , if $\lambda = 0$} \end{array} \right.

Value

A list with class "gp" containing the following elements:

method

method to estimate Gpower transformation parameter

lambda.hat

estimate of Gpower transformation parameter

statistic

Shapiro-Wilk test statistic for transformed data

p.value

Shapiro-Wilk test p.value for transformed data

alpha

level of significance to assess normality

tf.data

transformed data set

var.name

variable name

Author(s)

Muge Coskun Yildirim, Osman Dag

References

Asar, O., Ilk, O., Dag, O. (2017). Estimating Box-Cox Power Transformation Parameter via Goodness of Fit Tests. Communications in Statistics - Simulation and Computation, 46:1, 91–105.

Kelmansky, D.M., Martinez, E.J., Leiva, V. (2013). A New Variance Stabilizing Transformation for Gene Expression Data Analysis. Statistical Applications in Genetics and Molecular Biology, 12:6, 653–66.

Examples

data <- cars$dist

library(Transform)
out <- gpTransform(data)
out$lambda.hat # the estimate of Gpower parameter based on Shapiro-Wilk test statistic 
out$p.value # p.value of Shapiro-Wilk test for transformed data 
out$tf.data # transformed data set

Log Transformation for Normality

Description

lgTransform performs Log transformation for normality of a variable and provides graphical analysis.

Usage

lgTransform(data, lambda2 = NULL, plot = TRUE, alpha = 0.05, verbose = TRUE)

Arguments

data

a numeric vector of data values.

lambda2

a numeric for an additional shifting parameter. Default is set to lambda2 = NULL.

plot

a logical to plot histogram with its density line and qqplot of raw and transformed data. Defaults plot = TRUE.

alpha

the level of significance to check the normality after transformation. Default is set to alpha = 0.05.

verbose

a logical for printing output to R console.

Details

Denote yy the variable at the original scale and yy' the transformed variable. The Log power transformation is defined by:

y=log(y)y' = \log(y)

If the data include any nonpositive observations, a shifting parameter λ2\lambda_2 can be included in the transformation given by:

y=log(y+λ2)y' = \log(y+\lambda_2)

Value

A list with class "lg" containing the following elements:

method

method name

lambda2

additional shifting parameter

statistic

Shapiro-Wilk test statistic for transformed data

p.value

Shapiro-Wilk test p.value for transformed data

alpha

level of significance to assess normality

tf.data

transformed data set

var.name

variable name

Author(s)

Muge Coskun Yildirim, Osman Dag

References

Asar, O., Ilk, O., Dag, O. (2017). Estimating Box-Cox Power Transformation Parameter via Goodness of Fit Tests. Communications in Statistics - Simulation and Computation, 46:1, 91–105.

Box, G.E., Cox, D.R. (1964). An Analysis of Transformations. Journal of the Royal Statistical Society: Series B (Methodological), 26:2, 211–43.

Examples

data <- cars$dist

library(Transform)
out <- lgTransform(data)
out$p.value # p.value of Shapiro-Wilk test for transformed data 
out$tf.data # transformed data set

Log-shift Transformation for Normality

Description

lsTransform performs Log-shift transformation for normality of a variable and provides graphical analysis.

Usage

lsTransform(data, lambda = seq(-3,3,0.01), plot = TRUE, alpha = 0.05, 
  verbose = TRUE)

Arguments

data

a numeric vector of data values.

lambda

a vector which includes the sequence of candidate lambda values. Default is set to (-3,3) with increment 0.01.

plot

a logical to plot histogram with its density line and qqplot of raw and transformed data. Defaults plot = TRUE.

alpha

the level of significance to check the normality after transformation. Default is set to alpha = 0.05.

verbose

a logical for printing output to R console.

Details

Denote yy the variable at the original scale and yy' the transformed variable. The Log-shift power transformation is defined by:

y=log(y+λ)y' = \log({y + \lambda })

Value

A list with class "ls" containing the following elements:

method

method to estimate Log-shift transformation parameter

lambda.hat

estimate of Log-shift transformation parameter

statistic

Shapiro-Wilk test statistic for transformed data

p.value

Shapiro-Wilk test p.value for transformed data

alpha

level of significance to assess normality

tf.data

transformed data set

var.name

variable name

Author(s)

Muge Coskun Yildirim, Osman Dag

References

Asar, O., Ilk, O., Dag, O. (2017). Estimating Box-Cox Power Transformation Parameter via Goodness of Fit Tests. Communications in Statistics - Simulation and Computation, 46:1, 91–105.

Feng, Q., Hannig, J., Marron, J. (2015). A Note on Automatic Data Transformation. Stat, 5:1, 82–7.

Examples

data <- cars$dist

library(Transform)
out <- lsTransform(data)
out$lambda.hat # the estimate of Log-shift parameter based on Shapiro-Wilk test statistic 
out$p.value # p.value of Shapiro-Wilk test for transformed data 
out$tf.data # transformed data set

Modulus Transformation for Normality

Description

mdTransform performs Modulus transformation for normality of a variable and provides graphical analysis.

Usage

mdTransform(data, lambda = seq(-3,3,0.01), plot = TRUE, alpha = 0.05, 
  verbose = TRUE)

Arguments

data

a numeric vector of data values.

lambda

a vector which includes the sequence of candidate lambda values. Default is set to (-3,3) with increment 0.01.

plot

a logical to plot histogram with its density line and qqplot of raw and transformed data. Defaults plot = TRUE.

alpha

the level of significance to check the normality after transformation. Default is set to alpha = 0.05.

verbose

a logical for printing output to R console.

Details

Denote yy the variable at the original scale and yy' the transformed variable. The Modulus power transformation is defined by:

y={Sign(y)(y+1)λ1λ , if λ0Sign(y)log(y+1) , if λ=0y' = \left\{ \begin{array}{ll} Sign(y)\frac{(|y|+1)^\lambda-1}{\lambda} \mbox{ , if $\lambda \neq 0$} \cr Sign(y) \log{(|y|+1)} \mbox{ , if $\lambda = 0$} \end{array} \right.

Value

A list with class "md" containing the following elements:

method

method to estimate Modulus transformation parameter

lambda.hat

estimate of Modulus transformation parameter

statistic

Shapiro-Wilk test statistic for transformed data

p.value

Shapiro-Wilk test p.value for transformed data

alpha

level of significance to assess normality

tf.data

transformed data set

var.name

variable name

Author(s)

Muge Coskun Yildirim, Osman Dag

References

Asar, O., Ilk, O., Dag, O. (2017). Estimating Box-Cox Power Transformation Parameter via Goodness of Fit Tests. Communications in Statistics - Simulation and Computation, 46:1, 91–105.

John, J., Draper, N.R. (1980). An Alternative Family of Transformations. Journal of the Royal Statistical Society Series C: Applied Statistics, 29:2, 190–7.

Examples

data <- cars$dist

library(Transform)
out <- mdTransform(data)
out$lambda.hat # the estimate of Modulus parameter based on Shapiro-Wilk test statistic 
out$p.value # p.value of Shapiro-Wilk test for transformed data 
out$tf.data # transformed data set

Manly Transformation for Normality

Description

mnTransform performs Manly transformation for normality of a variable and provides graphical analysis.

Usage

mnTransform(data, lambda = seq(-3,3,0.01), plot = TRUE, alpha = 0.05, 
  verbose = TRUE)

Arguments

data

a numeric vector of data values.

lambda

a vector which includes the sequence of candidate lambda values. Default is set to (-3,3) with increment 0.01.

plot

a logical to plot histogram with its density line and qqplot of raw and transformed data. Defaults plot = TRUE.

alpha

the level of significance to check the normality after transformation. Default is set to alpha = 0.05.

verbose

a logical for printing output to R console.

Details

Denote yy the variable at the original scale and yy' the transformed variable. The Manly power transformation is defined by:

y={eλy1λ , if λ0y , if λ=0y' = \left\{ \begin{array}{ll} \frac{e^{\lambda y} - 1}{\lambda} \mbox{ , if $\lambda \neq 0$} \cr y \mbox{ , if $\lambda = 0$} \end{array} \right.

Value

A list with class "mn" containing the following elements:

method

method to estimate Manly transformation parameter

lambda.hat

estimate of Manly transformation parameter

statistic

Shapiro-Wilk test statistic for transformed data

p.value

Shapiro-Wilk test p.value for transformed data

alpha

level of significance to assess normality

tf.data

transformed data set

var.name

variable name

Author(s)

Muge Coskun Yildirim, Osman Dag

References

Asar, O., Ilk, O., Dag, O. (2017). Estimating Box-Cox Power Transformation Parameter via Goodness of Fit Tests. Communications in Statistics - Simulation and Computation, 46:1, 91–105.

Manly, B.F. (1976). Exponential Data Transformations. Journal of the Royal Statistical Society: Series D (The Statistician), 25:1, 37–42.

Examples

data <- cars$dist

library(Transform)
out <- mnTransform(data)
out$lambda.hat # the estimate of Manly parameter based on Shapiro-Wilk test statistic 
out$p.value # p.value of Shapiro-Wilk test for transformed data 
out$tf.data # transformed data set

Neglog Transformation for Normality

Description

nlTransform performs Neglog transformation for normality of a variable and provides graphical analysis.

Usage

nlTransform(data, plot = TRUE, alpha = 0.05, verbose = TRUE)

Arguments

data

a numeric vector of data values.

plot

a logical to plot histogram with its density line and qqplot of raw and transformed data. Defaults plot = TRUE.

alpha

the level of significance to check the normality after transformation. Default is set to alpha = 0.05.

verbose

a logical for printing output to R console.

Details

Denote yy the variable at the original scale and yy' the transformed variable. The Neglog power transformation is defined by:

y=Sign(y)log(y+1)y' = Sign(y) \log(|y|+1)

Value

A list with class "nl" containing the following elements:

method

method name

statistic

Shapiro-Wilk test statistic for transformed data

p.value

Shapiro-Wilk test p.value for transformed data

alpha

level of significance to assess normality

tf.data

transformed data set

var.name

variable name

Author(s)

Muge Coskun Yildirim, Osman Dag

References

Asar, O., Ilk, O., Dag, O. (2017). Estimating Box-Cox Power Transformation Parameter via Goodness of Fit Tests. Communications in Statistics - Simulation and Computation, 46:1, 91–105.

Whittaker, J., Whitehead, C., Somers, M. (2005). The Neglog Transformation and Quantile Regression for the Analysis of a Large Credit Scoring Database. Journal of the Royal Statistical Society: Series C (Applied Statistics), 54:5, 863–78.

Examples

data <- cars$dist

library(Transform)
out <- nlTransform(data)
out$p.value # p.value of Shapiro-Wilk test for transformed data 
out$tf.data # transformed data set

Reciprocal Transformation for Normality

Description

rpTransform performs Reciprocal transformation for normality of a variable and provides graphical analysis.

Usage

rpTransform(data, plot = TRUE, alpha = 0.05, verbose = TRUE)

Arguments

data

a numeric vector of data values.

plot

a logical to plot histogram with its density line and qqplot of raw and transformed data. Defaults plot = TRUE.

alpha

the level of significance to check the normality after transformation. Default is set to alpha = 0.05.

verbose

a logical for printing output to R console.

Details

Denote yy the variable at the original scale and yy' the transformed variable. The Dual power transformation is defined by:

y=1yy' = \frac{1}{y}

Value

A list with class "rp" containing the following elements:

method

method name

statistic

Shapiro-Wilk test statistic for transformed data

p.value

Shapiro-Wilk test p.value for transformed data

alpha

level of significance to assess normality

tf.data

transformed data set

var.name

variable name

Author(s)

Muge Coskun Yildirim, Osman Dag

References

Asar, O., Ilk, O., Dag, O. (2017). Estimating Box-Cox Power Transformation Parameter via Goodness of Fit Tests. Communications in Statistics - Simulation and Computation, 46:1, 91–105.

Tukey, J.W. (1957). On the Comparative Anatomy of Transformations. The Annals of Mathematical Statistics, 602–32.

Examples

data <- cars$dist

library(Transform)
out <- rpTransform(data)
out$p.value # p.value of Shapiro-Wilk test for transformed data 
out$tf.data # transformed data set

Square Root Transformation for Normality

Description

ssTransform performs Square Root transformation for normality of a variable and provides graphical analysis.

Usage

ssTransform(data, lambda = seq(-3,3,0.01), plot = TRUE, alpha = 0.05, 
  verbose = TRUE)

Arguments

data

a numeric vector of data values.

lambda

a vector which includes the sequence of candidate lambda values. Default is set to (-3,3) with increment 0.01.

plot

a logical to plot histogram with its density line and qqplot of raw and transformed data. Defaults plot = TRUE.

alpha

the level of significance to check the normality after transformation. Default is set to alpha = 0.05.

verbose

a logical for printing output to R console.

Details

Denote yy the variable at the original scale and yy' the transformed variable. The Square Root power transformation is defined by:

y=y+λy' = \sqrt{y + \lambda}

Value

A list with class "ss" containing the following elements:

method

method to estimate Square Root transformation parameter

lambda.hat

estimate of Square Root transformation parameter

statistic

Shapiro-Wilk test statistic for transformed data

p.value

Shapiro-Wilk test p.value for transformed data

alpha

level of significance to assess normality

tf.data

transformed data set

var.name

variable name

Author(s)

Muge Coskun Yildirim, Osman Dag

References

Asar, O., Ilk, O., Dag, O. (2017). Estimating Box-Cox Power Transformation Parameter via Goodness of Fit Tests. Communications in Statistics - Simulation and Computation, 46:1, 91–105.

Medina, L., Castro, P., Kreutzmann, A. (2018). Rojas-Perilla N. trafo: Estimation, Comparison and Selection of Transformations. R package version. 1.0.1.

Examples

data <- cars$speed

library(Transform)
out <- ssTransform(data)
out$lambda.hat # the estimate of Square Root parameter based on Shapiro-Wilk test statistic 
out$p.value # p.value of Shapiro-Wilk test for transformed data 
out$tf.data # transformed data set

Statistical Transformations for Normality

Description

Transform performs transformations for normality of a variable and provides graphical analysis.

Usage

Transform(data, method = "dl", lambda = seq(0,6,0.01), lambda2 = NULL, plot = TRUE, 
  alpha = 0.05, verbose = TRUE)

Arguments

data

a numeric vector of data values.

method

a character string. Different transformation methods can be used for the estimation of the optimal transformation parameter: Box-Cox ("bc"), Log-shift ("ls"), Bickel-Doksum ("bd"), Yeo-Johnson ("yj"), Square Root ("ss"), Manly ("mn"), Modulus ("md"), Dual ("dl"), Gpower ("gp"), Log ("lg"), Glog ("gl"), Neglog ("nl"), Reciprocal ("rp"). Default is set to method = "dl".

lambda

a vector which includes the sequence of candidate lambda values. Please see the corresponding method to learn the lambda range. Default is set to (0,6) with increment 0.01.

lambda2

a numeric for an additional shifting parameter. Please see the corresponding method to learn the lambda2. Default is set to lambda2 = NULL.

plot

a logical to plot histogram with its density line and qqplot of raw and transformed data. Defaults plot = TRUE.

alpha

the level of significance to check the normality after transformation. Default is set to alpha = 0.05.

verbose

a logical for printing output to R console.

Value

See the corresponding transformation method.

Author(s)

Muge Coskun Yildirim, Osman Dag

Examples

data <- cars$dist

library(Transform)
out <- Transform(data, method = "bc")
out$lambda.hat # the estimate of Box-Cox parameter based on Shapiro-Wilk test statistic 
out$p.value # p.value of Shapiro-Wilk test for transformed data 
out$tf.data # transformed data set

Yeo- Johnson Transformation for Normality

Description

yjTransform performs Yeo- Johnson transformation for normality of a variable and provides graphical analysis.

Usage

yjTransform(data, lambda = seq(-3,3,0.01), plot = TRUE, alpha = 0.05, 
  verbose = TRUE)

Arguments

data

a numeric vector of data values.

lambda

a vector which includes the sequence of candidate lambda values. Default is set to (-3,3) with increment 0.01.

plot

a logical to plot histogram with its density line and qqplot of raw and transformed data. Defaults plot = TRUE.

alpha

the level of significance to check the normality after transformation. Default is set to alpha = 0.05.

verbose

a logical for printing output to R console.

Details

Denote yy the variable at the original scale and yy' the transformed variable. The Yeo-Johnson power transformation is defined by:

y={(y+1)λ1λ , if λ0,y0log(y+1) , if λ=0,y0(1y)2λ1λ2 , if λ2,y<0log(1y) , if λ=2,y<0y' = \left\{ \begin{array}{ll} \frac{(y+1)^\lambda-1}{\lambda} \mbox{ , if $\lambda \neq 0, y \geq 0$} \cr \log(y+1) \mbox{ , if $\lambda = 0, y \geq 0$} \cr \frac{(1-y)^{2-\lambda}-1}{\lambda-2} \mbox{ , if $\lambda \neq 2, y < 0$} \cr -\log(1-y) \mbox{ , if $\lambda = 2, y < 0$} \end{array} \right.

Value

A list with class "yj" containing the following elements:

method

method to estimate Yeo-Johnson transformation parameter

lambda.hat

estimate of Yeo-Johnson transformation parameter

statistic

Shapiro-Wilk test statistic for transformed data

p.value

Shapiro-Wilk test p.value for transformed data

alpha

level of significance to assess normality

tf.data

transformed data set

var.name

variable name

Author(s)

Muge Coskun Yildirim, Osman Dag

References

Asar, O., Ilk, O., Dag, O. (2017). Estimating Box-Cox Power Transformation Parameter via Goodness of Fit Tests. Communications in Statistics - Simulation and Computation, 46:1, 91–105.

Yeo, I.K., Johnson, R.A. (2000). A New Family of Power Transformations to Improve Normality or Symmetry. Biometrika, 87:4, 954–9.

Examples

data <- cars$dist

library(Transform)
out <- yjTransform(data)
out$lambda.hat # the estimate of Yeo- Johnson parameter based on Shapiro-Wilk test statistic 
out$p.value # p.value of Shapiro-Wilk test for transformed data 
out$tf.data # transformed data set