Levene’s Test for Homogeneity of Variances is sometimes called Levene’s Test for Equality of Variances. The term ‘homogeneity’ refers to determining that variances are assumed to be equal variances across groups. Equal variances is an assumption of many statistical tests where the goal is to compare multiple treatment groups for mean differences, such as Analysis of Variance (ANOVA), mixed model ANOVA, and Analysis of Covariance (ANCOVA).
The null hypothesis for Levene’s Test for Homogeneity is that variances across groups are equal. The alternative hypothesis is that variances are considered unequal.
How to Perform Levene’s Test for Homogeneity of Variance in R:
In the example below, we evaluate whether variances differ between plant weights across three treatment groups in R:
library("datasets")
library("car")
library("ggplot2")
data("PlantGrowth")
leveneTest(weight ~ group, data=PlantGrowth)
Levene’s Test for Homogeneity of Variance Results
Levene's Test for Homogeneity of Variance (center = median)
Df F value Pr(>F)
group 2 1.1192 0.3412
27
As shown above a, p-value of 0.3412 is reported. As a result we fail to reject the null hypothesis and conclude that variances considered equal among treatment groups.
Visualizing the Assumption of Variances with Box Plots in R
Sometimes it can be helpful to visualize whether variances appear to be different by using side-by-side box plots. Additionally, this can help determine if there are possible outliers present in the data. The ‘ggplot2’ code below generates box plots across treatment groups:
ggplot(PlantGrowth, aes(x = group, y = weight)) +
stat_boxplot(geom ="errorbar", width = 0.5) +
geom_boxplot(fill = "light blue") +
stat_summary(fun=mean, geom="point", shape=10, size=3.5) +
ggtitle("Boxplots of plant weight for each treatment") +
theme_bw() + theme(legend.position="none")
In the figure below, the circle with a plus sign represents the mean of each treatment group while the thick black line represents the median. If the vertical length of the box plot for each treatment group is roughly the same, then you would not expect variances to differ. However, if one box is significantly smaller, or larger, than the others, Levene’s Test for Homogeneity of Variance may conclude that variances are considered unequal.
