R: A Function to Estimate Box-Cox Transformation Parameter for...
boxcoxfr
R Documentation
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.
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 (-2, 2) with increment 0.02.
alpha
the significance level for the construction of feasible region. Default is set to 0.05. If alpha = 0, it returns the MLE of transformation parameter.
Value
Returns a list containing following elements:
method
method applied in the algorithm
date
date which the function is used
lambda.hat
the estimated lambda
shapiro.test
a matrix which gives the test results for the normality of groups via shapiro.test
bartlett.test
a matrix which returns the test result for the homogenity of variance via bartlett.test
Author(s)
Osman Dag, Ozlem Ilk
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.
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(AID)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/AID/boxcoxfr.Rd_%03d_medium.png", width=480, height=480)
> ### Name: boxcoxfr
> ### Title: A Function to Estimate Box-Cox Transformation Parameter for
> ### Comparing Two or More Groups
> ### Aliases: boxcoxfr
> ### Keywords: functions
>
> ### ** Examples
>
>
> data(AADT)
> attach(AADT)
> boxcoxfr(aadt, class, lam = seq(-3, 3, 0.01))
$method
[1] "MLEFR"
$date
[1] "Mon Jul 4 14:12:03 2016"
$lambda.hat
[1] 0.07
$shapiro.test
W p-value
Group 1 0.9616863 0.82600329
Group 2 0.9583807 0.05108728
Group 3 0.9259602 0.16481355
Group 4 0.9636063 0.23477931
$bartlett.test
K-squared df p-value
4.257035 3 0.2350132
>
>
> data = rnorm(120, 10, 1)
> factor = rep(c("X", "Y", "Z"), each = 40)
> boxcoxfr(data, factor, lam = seq(-3, 3, 0.01))
$method
[1] "MLEFR"
$date
[1] "Mon Jul 4 14:12:03 2016"
$lambda.hat
[1] -0.52
$shapiro.test
W p-value
Group X 0.9862475 0.9002049
Group Y 0.9683868 0.3195653
Group Z 0.9862095 0.8991827
$bartlett.test
K-squared df p-value
1.048113 2 0.5921137
>
>
>
>
>
>
> dev.off()
null device
1
>