bcTransform {Transform}R Documentation

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 y the variable at the original scale and y' the transformed variable. The Box-Cox power transformation is defined by:

y' = \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 \lambda_2 can be included in the transformation given by:

y' = \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



[Package Transform version 1.0 Index]