lawstat (version 3.2)

levene.test: Levene's Test of Equality of Variances

Description

The function performs the following tests for equality of the k population variances: classical Levene's test, the robust Brown-Forsythe Levene-type test using the group medians and the robust Levene-type test using the group trimmed mean. More robust versions of the test using the correction factor or structural zero removal method are also available. Two options for calculating critical values, namely, approximated and bootstrapped, are available. Instead of the ANOVA statistic suggested by Levene, the Kruskal-Wallis ANOVA may also be applied using this function. By default, NAs from the data are omitted.

Usage

levene.test(y, group, location=c("median", "mean", "trim.mean"), trim.alpha=0.25,
bootstrap = FALSE, num.bootstrap=1000, kruskal.test=FALSE, 
correction.method=c("none","correction.factor","zero.removal","zero.correction"))

Arguments

y

a numeric vector of data values.

group

factor of the data.

location

the default option is "median" corresponding to the robust Brown-Forsythe Levene-type procedure; "mean" corresponds to the classical Levene's procedure, and "trim.mean" corresponds to the robust Levene-type procedure using the group trimmed means.

trim.alpha

the fraction (0 to 0.5) of observations to be trimmed from each end of 'x' before the mean is computed.

bootstrap

the default option is FALSE, i.e., no bootstrap; if the option is set to TRUE, the function performs the bootstrap method described in Lim and Loh (1996) for Levene's test.

num.bootstrap

number of bootstrap samples to be drawn when the bootstrap option is set to TRUE; the default value is 1000.

kruskal.test

use of Kruskal-Wallis statistic. The default option is FALSE, i.e., the usual ANOVA statistic is used in place of Kruskal-Wallis statistic.

correction.method

procedures to make the levene's test more robust; the default option is "none"; "correction.factor" applies the correction factor described by O'Brien (1978) and Keyes and Levy (1997); "zero.removal" performs the structural zero removal method by Hines and Hines (2000); "zero.correction" performs a combination of O'Brien's correction factor and the Hines-Hines structural zero removal method (Noguchi and Gel, 2009); note that the options "zero.removal" and "zero.correction" are only applicable when the location is set to "median"; otherwise, "none" is applied.

Value

A list with the following numeric components.

statistic

the value of the test statistic.

p.value

the p-value of the test.

method

type of test performed.

data.name

a character string giving the name of the data.

non.bootstrap.p.value

the p-value of the test without bootstrap method; i.e. the p-value using the approximated critical value.

Details

Levene (1960) proposed a test for homogeneity of variances in k groups which is based on the ANOVA statistic applied to absolute deviations of observations from the corresponding group mean. The robust Brown-Forsythe version of the Levene-type test substites the group mean by the group median in the classical Levene statistic. The third option is to consider ANOVA applied to the absolute deviations of observations from the group trimmed mean instead of the group means.

References

Boos, D. D. and Brownie, C. (1989). Bootstrap methods for testing homogeneity of variances. Technometrics 31, 69-82.

Brown, M. B. and Forsythe, A.B. (1974). Robust tests for equality of variances. Journal of the American Statistical Association, 69, 364-367.

Gastwirth, J. L., Gel, Y. R., and Miao, W. (2009). The Impact of Levene's Test of Equality of Variances on Statistical Theory and Practice. Statistical Science, 24(3), 343-360.

Hines, W. G. S. and Hines, R. J. O. (2000). Increased power with modified forms of the Levene (med) test for heterogeneity of variance. Biometrics 56, 451-454.

Hui, W., Gel, Y. R., and Gastwirth, J. L. (2008). lawstat: an R package for law, public policy and biostatistics. Journal of Statistical Software 28, Issue 3.

Keyes, T. K. and Levy, M. S. (1997). Analysis of Levenes test under design imbalance. Journal of Educational and Behavioral Statistics 22, 845-858.

Kruskal, W. H. and Wallis, W. A. (1952). Use of ranks in one-criterion variance analysis. Journal of the American Statistical Association 47, 583-621.

Levene, H. (1960). Robust Tests for Equality of Variances, in Contributions to Probability and Statistics, ed. I. Olkin, Palo Alto, CA: Stanford Univ. Press.

Lim,T.-S., Loh, W.-Y. (1996) A comparison of tests of equality of variances Computational Statistical \& Data Analysis 22, 287-301.

Noguchi, K. and Gel, Y. R. (2009) Combination of Levene-type tests and a finite-intersection method for testing equality of variances against ordered alternatives. Working paper, Department of Statistics and Actuarial Science, University of Waterloo.

O'Brien, R. G. (1978). Robust techniques for testing heterogeneity of variance effects in factorial designs. Psychometrika 43, 327-344.

See Also

neuhauser.hothorn.test, lnested.test, ltrend.test, mma.test, robust.mmm.test

Examples

Run this code
# NOT RUN {
data(pot)
levene.test(pot[,"obs"], pot[,"type"], location="median", correction.method="zero.correction")

##        modified robust Brown-Forsythe Levene-type test based on the absolute deviations 
##        from the median with modified structural zero removal method and correction factor
##
## data:  pot[,"obs"] 
## Test Statistic = 6.5673, p-value = 0.001591

##   Bootstrap version of the test. The calculation may take up a few minutes 
##   depending on the number of bootstrap sampling.

levene.test(pot[,"obs"], pot[,"type"], location="median", correction.method="zero.correction", 
bootstrap=TRUE,num.bootstrap=500)

##        bootstrap modified robust Brown-Forsythe Levene-type test based on the absolute 
##        deviations from the median with structural zero removal method and correction factor
##
## data:  pot[, "obs"] 
## Test Statistic = 6.9577, p-value = 0.001

# }

Run the code above in your browser using DataLab