Learn R Programming

AID (version 1.5)

boxcoxfr: A Function to Estimate Box-Cox Transformation Parameter for Comparing Two or More Groups

Description

boxcoxfr estimates Box-Cox power transformation parameter. It is useful to use if the normality or/and the homogenity of variance is/are not satisfied while comparing two or more groups. While estimating transformation parameter, maximum likelihood estimation in feasible region (MLEFR) is used. MLEFR maximizes the likehood function in feasible region constructed by Shapiro-Wilk test and Bartlett's test. After transformation parameter is estimated, normality of groups and homogenity of variance are checked by Shapiro-Wilk test and Bartlett's test, respectively.

Usage

boxcoxfr(y, x, option = "both", lam = seq(-2, 2, 0.02), alpha = 0.05)

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
lam
a vector which includes the sequence of feasible lambda values. Default is set to (-2, 2) with increment 0.02.
alpha
the significance level for the construction of feasible region.

Value

  • Returns a list containing following elements:
  • methodmethod applied in the algorithm
  • datedate which the function is used
  • lambda.hatthe estimated lambda
  • shapiro.testa matrix which gives the test results for the normality of groups via shapiro.test
  • bartlett.testa matrix which returns the test result for the homogenity of variance via bartlett.test

References

Bartlett, M.S.(1937). Properties of Sufficiency and Statistical Tests. Proceedings of the Royal Society of London, Series A, 160, 268-282. Box, G.E.P., Cox, D.R. (1964). An Analysis of Transformations (with discussion). Journal of The Royal Statistical Society, Series B (Methodological), 26, 211-252. Shapiro, S.S., Wilk, M.B. (1965). An Analysis of Variance Test for Normality (Complete Samples). Biometrika, 52(3/4), 591-611.

Examples

Run this code
data = rnorm(120, 10, 1)
factor = rep(c("X", "Y", "Z"), each = 40)
boxcoxfr(data, factor, lam = seq(-3, 3, 0.01))

Run the code above in your browser using DataLab