Learn R Programming

AID (version 1.9)

boxcoxfr:

Description

boxcoxfr performs Box-Cox transformation for one-way independent groups designs. It is useful to use if the normality or/and the homogenity of variance is/are not satisfied while comparing two or more groups.

Usage

boxcoxfr(y, x, option = "both", lam = seq(-3, 3, 0.01), tau = 0.05, alpha = 0.05, 
  verbose = TRUE)

Arguments

y
a numeric vector of data values.
x
a vector or factor object which gives the group for the corresponding elements of y.
option
a character string to select the desired option for the objective of transformation. "norm" and "var" are the options which search for a transformation to satisfy the normality of groups and the homogenity of variances, respectively. "both" is the option which searches for a transformation to satisfy both the normality of groups and the homogenity of variances. Default is set to "both".
lam
a vector which includes the sequence of feasible lambda values. Default is set to (-3, 3) with increment 0.01.
tau
the feasible region parameter for the construction of feasible region. Default is set to 0.05. If tau = 0, it returns the MLE of transformation parameter.
alpha
the level of significance to check the normality and variance homogenity after transformation. Default is set to alpha = 0.05.
verbose
a logical for printing output to R console.

Value

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

method
method applied in the algorithm
lambda.hat
the estimated lambda
shapiro
a data frame which gives the test results for the normality of groups via Shapiro-Wilk test
bartlett
a matrix which returns the test result for the homogenity of variance via Bartlett's test
alpha
the level of significance to assess the assumptions.
tf.data
transformed data set
x
a factor object which gives the group for the corresponding elements of y
y.name
variable name of y
x.name
variable name of x

Details

Maximum likelihood estimation in feasible region (MLEFR) is used while estimating transformation parameter. MLEFR maximizes the likehood function in feasible region constructed by Shapiro-Wilk test and Bartlett's test. After transformation, normality of the data in each group and homogeneity of variance are assessed by Shapiro-Wilk test and Bartlett's test, respectively.

References

Dag, O., Ilk, O. An Algorithm for Estimating Box-Cox Transformation Parameter in ANOVA. Communications in Statistics - Simulation and Computation, Accepted (June 16, 2016).

Examples

Run this code

library(AID)

data(AADT)
attach(AADT)
out <- boxcoxfr(aadt, class)
out$shapiro
out$bartlett
out$tf.data
confInt(out, level = 0.95)


data <- rnorm(120, 10, 1)
factor <- rep(c("X", "Y", "Z"), each = 40)
out <- boxcoxfr(data, factor, lam = seq(-5, 5, 0.01), tau = 0.01, alpha = 0.01)
confInt(out, level = 0.95)


Run the code above in your browser using DataLab