Basics

Tests for nominal variables

Descriptive statistics

Tests for one measurement variable

Tests for multiple measurement variables

Multiple tests

Miscellany

Homoscedasticity and Bartlett's test


One of the assumptions of an anova and other parametric tests is that the within-group variances of the groups are all the same (exhibit homoscedasticity). If the variances are different from each other (exhibit heteroscedasticity), the probability of obtaining a "significant" result even though the null hypothesis is true is greater than the desired alpha level. Therefore, it is a good idea to check the homogeneity of variances before doing an anova. If the variances are very heterogeneous, you should try different transformations and hope that one of them makes the variances more similar.

Parametric tests are not particularly sensitive to violations of this assumption, so if you have statistically significant heteroscedasticity no matter what data transformation you try, you can still do a parametric test unless the variances are dramatically different from each other. I don't know what level of heteroscedasticity makes a parametric test seriously misleading.

If the variances of your groups are very heterogeneous no matter what transformation you apply, it's not always clear what you should do. If you have just two groups, you can do Welch's t-test instead of Student's t-test; if you have more than two groups, you can do Welch's anova instead of one-way anova. Non-parametric tests, such as the Kruskal–Wallis test instead of a one-way anova, do not assume normality, but they do assume that the shapes of the distributions in different groups are the same, so they are not a solution to the problem of heteroscedasticity. Of course, once you've examined the normality and homoscedasticity of your data, you should decide how to transform and analyze it before you see the results of the anova or other tests.

Bartlett's test

The usual test for homogeneity of variances is Bartlett's test. This test is used when you have one measurement variable, one nominal variable, and you want to test the null hypothesis that the variances of the measurement variable are the same for the different groups. The basic idea is that the natural log of the variance is calculated for each group, then these are averaged. The variances are also averaged across groups. The average of the natural logs of the individual variances is subtracted from the natural log of the average variance. Under the null hypothesis of homogeneity of variances, this statistic is chi-square distributed with d.f. equal to the number of groups minus one.

Bartlett's test is not a particularly good one, because it is sensitive to departures from normality as well as heteroscedasticity. It may be more helpful to use Bartlett's test to see what effect different transformations have on the heteroscedasticity, choosing the transformation with the highest (least significant) P-value, rather than take the P values too seriously; you shouldn't panic just because you have a significant Bartlett's test.

An alternative to Bartlett's test that I won't cover here is Levene's test. It is less sensitive to departures from normality, but if the data are approximately normal, it is less powerful than Bartlett's test.

For many measurement variables in biology, the coefficient of variation is the same for different groups. When this occurs, groups with larger means will also have larger variances. For example, if the petal lengths of red roses and pink roses both have a coefficient of variation of 20%, and red roses have a mean petal length 10% longer than pink roses, then the standard deviation of red petal length is 10% larger than for pink petal length. This means the variance is 21% larger for red roses. This kind of heteroscedasticity, in which the variance increases as the mean increases, can usually be greatly reduced with the right data transformation.

While Bartlett's test is usually used when examining data to see if it's appropriate for a parametric test, there are times when testing the homogeneity of variances is the primary goal of an experiment. For example, let's say you want to know whether variation in stride length among runners is related to their level of experience--maybe as people run more, those who started with unusually long or short strides gradually converge on some ideal stride length. You could measure the stride length of non-runners, beginning runners, experienced amateur runners, and professional runners, with several individuals in each group, then use Bartlett's test to see whether there was significant heterogeneity in the variances.

How to do Bartlett's test

Spreadsheet

I have put together a spreadsheet that performs Bartlett's test for homogeneity of variances for up to 1000 observations in each of up to 50 groups. It allows you to see what the log or square-root transformation will do. It also shows a graph of the standard deviations plotted vs. the means. This gives you a quick visual display of the difference in amount of variation among the groups, and it also shows whether the mean and standard deviation are correlated.

Entering the mussel shell data from the one-way anova web page into the spreadsheet, the P-values are 0.655 for untransformed data, 0.856 for square-root transformed, and 0.929 for log-transformed data. None of these is close to significance, so there's no real need to worry. The graph of the untransformed data hints at a correlation between the mean and the standard deviation, so it might be a good idea to log-transform the data:

Standard deviation vs. mean
Standard deviation vs. mean AAM for untransformed and log-transformed data.
Standard deviation vs. mean
Standard deviation vs. mean AAM for untransformed and log-transformed data.

Web page

There is web page for Bartlett's test that will handle up to 14 groups. You have to enter the variances and sample sizes, not the raw data.

SAS

You can use the HOVTEST=BARTLETT option in the MEANS statement of PROC GLM to perform Bartlett's test. This modification of the program from the one-way anova page does Bartlett's test.


proc glm data=musselshells;
  class location;
  model aam = location;
  means location / hovtest=bartlett;
run; 

Further reading

Sokal and Rohlf, pp. 398-399.

Zar, pp. 185, 202-204.



Return to the Biological Data Analysis syllabus

Return to John McDonald's home page

This page was last revised August 8, 2008. Its address is http://udel.edu/~mcdonald/stathomog.html.
©2008 by John H. McDonald. You can probably do what you want with this content; see the permissions pagefor details.