Many statistical tests (like a one-way ANOVA) make the assumption that the variance among several groups is equal.
One way to formally test this assumption is to use Levene’s Test, which tests whether or not the variance among two or more groups is equal.
This test uses the following hypotheses:
- Null hypothesis (H0): The variance among the groups is equal.
- Alternative hypothesis (HA): The variance among the groups is not equal.
If the p-value from the test is less than our chosen significance level, we can reject the null hypothesis and conclude that we have enough evidence to state that the variance among the groups is not equal.
The following example shows how to perform Levene’s test in SAS.
Example: Levene’s Test in SAS
Suppose we have the following dataset in SAS that shows the fertilizer used on various plants and the resulting growth (in inches) for 18 plants:
/*create dataset*/ data my_data; input fertilizer $ growth; datalines; A 29 A 23 A 20 A 21 A 33 A 30 B 19 B 19 B 17 B 24 B 25 B 29 C 21 C 22 C 30 C 25 C 24 C 33 ; run; /*view dataset*/ proc print data=my_data;
Suppose we would like to perform a one-way ANOVA to determine if the mean plant growth is equal between the three different fertilizers.
We can use the following syntax in SAS to perform a one-way ANOVA with the statement hovtest=levene(type=abs) to also perform Levene’s test to determine whether or not the three groups have equal variances:
/*perform one-way ANOVA along with Levene's test*/ proc glm data = my_data; class fertilizer; model growth = fertilizer; means fertilizer / hovtest=levene(type=abs); run;
The first table in the output shows the results of the one-way ANOVA:
The p-value in the ANOVA table is 0.3358.
Since this value is not less than .05, we would conclude that there is no statistically significant difference in mean plant growth between the three fertilizers.
To check if this result is reliable, we should check if the assumption of equal variances is met.
We can see the output of Levene’s test in the second table in the output:
From this table we can see that the p-value of Levene’s test is 0.6745.
Since this value is not less than .05, we fail to reject the null hypothesis of the test.
In other words, we can assume that the three groups have equal variances.
Note: We used the argument type=abs in the levene() function to specify that we should use the absolute value of the residuals when performing Levene’s test. This is consistent with the method used by other statistical software such as R.
The following tutorials explain how to perform other common statistical tests in SAS: