Learn R Programming

AID (version 1.9)

boxcoxnc:

Description

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

Usage

boxcoxnc(data, method = "sw", lam = seq(-3,3,0.01), plot = TRUE, alpha = 0.05, 
  verbose = TRUE)

Arguments

data
a numeric vector of data values.
method
a character string to select the desired method to be used to estimate Box-Cox transformation parameter. To use Shapiro-Wilk test method should be set to "sw". For method = "ad", boxcoxnc function uses Anderson-Darling test to estimate Box-Cox transformation parameter. Similarly, method should be set to "cvm", "pt", "sf", "lt", "jb", "ac" to use Cramer-von Mises, Pearson Chi-square, Shapiro-Francia, Lilliefors, Jarque-Bera tests and artificial covariate method, respectively. Default is set to method = "sw".
lam
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.

Value

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

method
method preferred to estimate Box-Cox transformation parameter
lambda.hat
estimate of Box-Cox Power transformation parameter based on corresponding method
statistic
statistic of normality test for transformed data based on specified normality test in method. For artificial covariate method, statistic is obtained by Shapiro-Wilk test for transformed data
p.value
p.value of normality test for transformed data based on specified normality test in method. For artificial covariate method, p.value is obtained by Shapiro-Wilk test for transformed data
alpha
the level of significance to assess normality.
tf.data
transformed data set
var.name
variable name

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.

Dag, O., Asar, O., Ilk, O. (2014). A Methodology to Implement Box-Cox Transformation When No Covariate is Available. Communications in Statistics - Simulation and Computation, 43:7, 1740--1759.

Examples

Run this code

library(AID)

data(textile)

out <- boxcoxnc(textile[,1], method = "sw")
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
confInt(out) # mean and confidence interval for back transformed data


out2 <- boxcoxnc(textile[,1], method = "sf")
out2$lambda.hat # the estimate of Box-Cox parameter based on Shapiro-Francia test statistic
out2$p.value # p.value of Shapiro-Francia test for transformed data 
out2$tf.data 
confInt(out2) 

Run the code above in your browser using DataLab