Bartlett’s test is a statistical test that is used to determine whether or not the variances between several groups are equal.
Many statistical tests (like a one-way ANOVA) assume that variances are equal across samples. Bartlett’s test can be used to verify that assumption.
This test uses the following null and alternative hypotheses:
H0: The variance among each group is equal.
HA: At least one group has a variance that is not equal to the rest.
The test statistic follows a Chi-Square distribution with k-1 degrees of freedom where k is the number of groups.
If the corresponding p-value of the test statistic is less than some significance level (like α = .05) then we can reject the null hypothesis and conclude that not all groups have the same variance.
The following step-by-step example explains how to perform Bartlett’s test in R.
Step 1: Create the Data
To determine if three different studying techniques lead to different exam scores, a professor randomly assigns 10 students to use each technique (Technique A, B, or C) for one week and then makes each student take an exam of equal difficulty.
The exam scores of the 30 students are shown below:
#create data frame df frame(group = rep(c('A','B', 'C'), each=10), score = c(85, 86, 88, 75, 78, 94, 98, 79, 71, 80, 91, 92, 93, 85, 87, 84, 82, 88, 95, 96, 79, 78, 88, 94, 92, 85, 83, 85, 82, 81)) #view data frame df group score 1 A 85 2 A 86 3 A 88 4 A 75 5 A 78 6 A 94 7 A 98 8 A 79 9 A 71 10 A 80 11 B 91 12 B 92 13 B 93 14 B 85 15 B 87 16 B 84 17 B 82 18 B 88 19 B 95 20 B 96 21 C 79 22 C 78 23 C 88 24 C 94 25 C 92 26 C 85 27 C 83 28 C 85 29 C 82 30 C 81
Step 2: Perform Bartlett’s Test
To perform Bartlett’s test, we can use the bartlett.test function in base R, which uses the following syntax:
bartlett.test(formula, data)
Here’s how to use this function in our example:
#perform Bartlett's test bartlett.test(score ~ group, data = df) Bartlett test of homogeneity of variances data: score by group Bartlett's K-squared = 3.3024, df = 2, p-value = 0.1918
The test returns the following results:
- Test statistic B: 3.3024
- P-value: 0.1918
Since the p-value is not less than 0.05, the professor will fail to reject the null hypothesis.
In other words, she doesn’t have sufficient evidence to say that the three groups have different variances.
Thus, she can proceed to perform the one-way ANOVA.
Additional Resources
Bartlett’s Test Calculator
How to Check ANOVA Assumptions
How to Perform a One-Way ANOVA in R