levene_test
reports Levene's robust test statistic
for the equality of variances and the
two statistics proposed by Brown and Forsythe that replace the mean in
Levene's formula with alternative location estimators. The first alternative
replaces the mean with the median. The second alternative replaces
the mean with the 10
levene_test(variable, ...) # S3 method for default levene_test(variable, ..., group_var = NA, trim.mean = 0.1) # S3 method for lm levene_test(variable, ...) # S3 method for formula levene_test(variable, data, ...)
lm
levene_test
returns an object of class "levene_test"
.
An object of class "levene_test"
is a list containing the
following components:
Bland, M. 2000. An Introduction to Medical Statistics. 3rd ed. Oxford: Oxford University Press.
Brown, M. B., and A. B. Forsythe. 1974. Robust tests for the equality of variances. Journal of the American Statistical Association 69: 364–367.
Carroll, R. J., and H. Schneider. 1985. A note on Levene’s tests for equality of variances. Statistics and Probability Letters 3: 191–194.
# using grouping variable levene_test(hsb$read, group_var = hsb$race)#> Summary Statistics #> Levels Frequency Mean Std. Dev #> ----------------------------------------- #> 1 24 46.67 10.24 #> 2 11 51.91 7.66 #> 3 20 46.8 7.12 #> 4 145 53.92 10.28 #> ----------------------------------------- #> Total 200 52.23 10.25 #> ----------------------------------------- #> #> Test Statistics #> ------------------------------------------------------------------------- #> Statistic Num DF Den DF F Pr > F #> ------------------------------------------------------------------------- #> Brown and Forsythe 3 196 3.44 0.0179 #> Levene 3 196 3.4792 0.017 #> Brown and Forsythe (Trimmed Mean) 3 196 3.3936 0.019 #> -------------------------------------------------------------------------# using two variables levene_test(hsb$read, hsb$write, hsb$socst)#> Summary Statistics #> Levels Frequency Mean Std. Dev #> ----------------------------------------- #> 0 200 52.23 10.25 #> 1 200 52.77 9.48 #> 2 200 52.41 10.74 #> ----------------------------------------- #> Total 600 52.47 10.15 #> ----------------------------------------- #> #> Test Statistics #> ------------------------------------------------------------------------- #> Statistic Num DF Den DF F Pr > F #> ------------------------------------------------------------------------- #> Brown and Forsythe 2 597 1.1683 0.3116 #> Levene 2 597 1.3803 0.2523 #> Brown and Forsythe (Trimmed Mean) 2 597 1.3258 0.2664 #> -------------------------------------------------------------------------# using model m <- lm(read ~ female, data = hsb) levene_test(m)#> Summary Statistics #> Levels Frequency Mean Std. Dev #> ----------------------------------------- #> 0 91 52.82 10.51 #> 1 109 51.73 10.06 #> ----------------------------------------- #> Total 200 52.23 10.25 #> ----------------------------------------- #> #> Test Statistics #> ------------------------------------------------------------------------- #> Statistic Num DF Den DF F Pr > F #> ------------------------------------------------------------------------- #> Brown and Forsythe 1 198 0.4542 0.5011 #> Levene 1 198 0.6024 0.4386 #> Brown and Forsythe (Trimmed Mean) 1 198 0.494 0.483 #> -------------------------------------------------------------------------# using formula levene_test(as.formula(paste0('read ~ schtyp')), hsb)#> Summary Statistics #> Levels Frequency Mean Std. Dev #> ----------------------------------------- #> 1 168 51.85 10.42 #> 2 32 54.25 9.2 #> ----------------------------------------- #> Total 200 52.23 10.25 #> ----------------------------------------- #> #> Test Statistics #> ------------------------------------------------------------------------- #> Statistic Num DF Den DF F Pr > F #> ------------------------------------------------------------------------- #> Brown and Forsythe 1 198 0.5643 0.4534 #> Levene 1 198 0.6153 0.4337 #> Brown and Forsythe (Trimmed Mean) 1 198 0.5886 0.4439 #> -------------------------------------------------------------------------