Performance Test Levene’s Tooltips

R and SAS links in Help

Introduction

Brown and Forsythe (Brown and Forsythe 1974) suggested a modification to Levene’s test statistic for the equality of variances. Simply, Levene proposed a one-way ANOVA of deviations of group observations from the group center. Where Levene used absolute differences from the mean, \(z_{ij} = |y_{ij} - \bar{y}_{i .}|\), Brown and Forsythe recommend using differences from the group median, and found that this measure is more robust when group errors are not normally distributed (i.e. long-tailed). This method is also more robust when data are skewed (Carroll and Schneider 1985, Nordstokke and Zumbo (2007)). Conover, Johnson and Johnson (Conover, Johnson, and Johnson 1981), using extensive simulations, compared the Brown and Forsythe statistic with other test of homogeneity of variance tests and found this method to be the best of the non-ranked based tests.

Since Levene initially proposed a family of tests, including \(\sqrt{z_{ij}}\) and \(\log{z_{ij}}\), Brown and Forsythe’s test is commonly referred to as Levene (Med) (Kuehl 2000, Schabenberger and Pierce (2001)), or more simply state the modification to Levene’s test (Milliken and Johnson 1992). Thus, the SAS option for Levene (Med) test is hovtest=bf.

Calculations

To illustrate, we use data from (Milliken and Johnson 1992, Table 2.1) as an example:

Table2.1 <- data.frame(
  trt=as.factor(c(1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4)),
  reps=as.factor(c(1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8)),
  Score = c(1,8,9,9,4,0,1,NA,12,10,13,13,12,10,NA,NA,12,4,11,7,8,10,12,5,13,14,14,17,11,14,13,14)
)

Compute the median for each treatment group and analyze the absolute values of the differences as a response.

z.med <- tapply(Table2.1$Score,list(Table2.1$trt),median, na.rm=TRUE)
Table2.1$z.med <- z.med[Table2.1$trt]
summary(aov(abs(z.med-Score) ~ trt, data=subset(Table2.1,!is.na(Table2.1$Score))))
##             Df Sum Sq Mean Sq F value  Pr(>F)   
## trt          3  31.38  10.459   5.494 0.00486 **
## Residuals   25  47.59   1.904                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

We can also compute Levene’s orginal by

z.mean <- tapply(Table2.1$Score,list(Table2.1$trt),mean, na.rm=TRUE)
Table2.1$z.mean <- z.mean[Table2.1$trt]
summary(aov(abs(z.mean-Score) ~ trt, data=Table2.1))
##             Df Sum Sq Mean Sq F value  Pr(>F)   
## trt          3  30.60  10.201   6.966 0.00145 **
## Residuals   25  36.61   1.464                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 3 observations deleted due to missingness

We can compare this with the leveneTest function in R library car

library(car)
## Warning: package 'car' was built under R version 3.3.2
leveneTest(Score ~ trt,data=Table2.1) #default is center=median
## Levene's Test for Homogeneity of Variance (center = median)
##       Df F value   Pr(>F)   
## group  3  5.4943 0.004861 **
##       25                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
leveneTest(Score ~ trt,data=Table2.1,center=mean) #original Levene
## Levene's Test for Homogeneity of Variance (center = mean)
##       Df F value   Pr(>F)   
## group  3  6.9664 0.001454 **
##       25                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

and using SAS:

data Milliken21;
input trt reps Score;
datalines;
  1    1     1
  1    2     8
  1    3     9
  1    4     9
  1    5     4
  1    6     0
  1    7     1
  2    1    12
  2    2    10
  2    3    13
  2    4    13
  2    5    12
  2    6    10
  3    1    12
  3    2     4
  3    3    11
  3    4     7
  3    5     8
  3    6    10
  3    7    12
  3    8     5
  4    1    13
  4    2    14
  4    3    14
  4    4    17
  4    5    11
  4    6    14
  4    7    13
  4    8    14
;

/* Test for homogeneity of variance */
proc glm data=Milliken21;
  class trt; 
  model Score = trt;
  means trt / hovtest=bf; /*Levene (Med)*/
  means trt / hovtest=levene; /*Levene Mean*/
run;

which produces the results

                                         The SAS System       10:25 Thursday, August 31, 2017   1

                                        The GLM Procedure

                                    Class Level Information

                                Class         Levels    Values

                                trt                4    1 2 3 4


                             Number of Observations Read          29
                             Number of Observations Used          29


                                        The GLM Procedure

                                  Dependent Variable: Score

                                               Sum of
       Source                      DF         Squares     Mean Square    F Value    Pr > F

       Model                        3     347.7842775     115.9280925      14.91    <.0001

       Error                       25     194.4226190       7.7769048

       Corrected Total             28     542.2068966


                       R-Square     Coeff Var      Root MSE    Score Mean

                       0.641424      28.78028      2.788710      9.689655


       Source                      DF       Type I SS     Mean Square    F Value    Pr > F

       trt                          3     347.7842775     115.9280925      14.91    <.0001


       Source                      DF     Type III SS     Mean Square    F Value    Pr > F

       trt                          3     347.7842775     115.9280925      14.91    <.0001


                                        The GLM Procedure

                   Brown and Forsythe's Test for Homogeneity of Score Variance
                         ANOVA of Absolute Deviations from Group Medians

                                        Sum of        Mean
                  Source        DF     Squares      Square    F Value    Pr > F

                  trt            3     31.3762     10.4587       5.49    0.0049
                  Error         25     47.5893      1.9036


                                        The GLM Procedure

                        Level of           ------------Score------------
                        trt          N             Mean          Std Dev

                        1            7        4.5714286       4.03555625
                        2            6       11.6666667       1.36626010
                        3            8        8.6250000       3.11390889
                        4            8       13.7500000       1.66904592


                                        The GLM Procedure

                         Levene's Test for Homogeneity of Score Variance
                          ANOVA of Squared Deviations from Group Means

                                        Sum of        Mean
                  Source        DF     Squares      Square    F Value    Pr > F

                  trt            3       698.5       232.8       7.36    0.0011
                  Error         25       791.2     31.6468


                                        The GLM Procedure

                        Level of           ------------Score------------
                        trt          N             Mean          Std Dev

                        1            7        4.5714286       4.03555625
                        2            6       11.6666667       1.36626010
                        3            8        8.6250000       3.11390889
                        4            8       13.7500000       1.66904592


                                        The GLM Procedure

                                    Class Level Information

                                Class         Levels    Values

                                trt                4    1 2 3 4


                             Number of Observations Read          29
                             Number of Observations Used          29

                                        The GLM Procedure

                                  Dependent Variable: Score

                                               Sum of
       Source                      DF         Squares     Mean Square    F Value    Pr > F

       Model                        3     347.7842775     115.9280925      14.91    <.0001

       Error                       25     194.4226190       7.7769048

       Corrected Total             28     542.2068966


                       R-Square     Coeff Var      Root MSE    Score Mean

                       0.641424      28.78028      2.788710      9.689655


       Source                      DF       Type I SS     Mean Square    F Value    Pr > F

       trt                          3     347.7842775     115.9280925      14.91    <.0001


       Source                      DF     Type III SS     Mean Square    F Value    Pr > F

       trt                          3     347.7842775     115.9280925      14.91    <.0001


                                        The GLM Procedure

                   Brown and Forsythe's Test for Homogeneity of Score Variance
                         ANOVA of Absolute Deviations from Group Medians

                                        Sum of        Mean
                  Source        DF     Squares      Square    F Value    Pr > F

                  trt            3     31.3762     10.4587       5.49    0.0049
                  Error         25     47.5893      1.9036


                                        The GLM Procedure

                        Level of           ------------Score------------
                        trt          N             Mean          Std Dev

                        1            7        4.5714286       4.03555625
                        2            6       11.6666667       1.36626010
                        3            8        8.6250000       3.11390889
                        4            8       13.7500000       1.66904592

                                         The SAS System       10:25 Thursday, August 31, 2017  11

                                        The GLM Procedure

                         Levene's Test for Homogeneity of Score Variance
                          ANOVA of Squared Deviations from Group Means

                                        Sum of        Mean
                  Source        DF     Squares      Square    F Value    Pr > F

                  trt            3       698.5       232.8       7.36    0.0011
                  Error         25       791.2     31.6468


                                        The GLM Procedure

                        Level of           ------------Score------------
                        trt          N             Mean          Std Dev

                        1            7        4.5714286       4.03555625
                        2            6       11.6666667       1.36626010
                        3            8        8.6250000       3.11390889
                        4            8       13.7500000       1.66904592

Bibliography

Brown, Morton B, and Alan B Forsythe. 1974. “Robust Tests for the Equality of Variances.” Journal of the American Statistical Association 69 (June): 364–67.

Carroll, Raymond J, and Helmut Schneider. 1985. “A Note on Levene’s Test for Equality of Variances.” Statistics Probability Letters 3: 191–94.

Conover, W J, Mark E Johnson, and Myrle M Johnson. 1981. “A Comparative Study of Tests for Homogeneity of Variances, with Applications to the Outer Continental Shelf Bidding Data.” Technometrics 23 (November): 351–61.

Kuehl, R O. 2000. Design of experiments: statistical principles of research design and analysis. 2nd ed. Brooks/Cole.

Milliken, George A., and Dallas E. Johnson. 1992. Analysis of Messy Data. 1st ed. Vol. Designed Experiments. Chapman; Hall/CRC.

Nordstokke, David W, and Bruno D Zumbo. 2007. “A Cautionary Tale About Levenes Tests for Equal Variances.” Journal of Educational Research and Policy Studies 7.

Schabenberger, Oliver, and Francis J. Pierce. 2001. Contemporary Statistical Models for the Plant and Soil Sciences [Hardcover]. CRC Press.