Tutorials › Multivariate Statistics (Graduate) › Worked Bartlett Test For Equal Variances

Covariance Matrix Inference · Tutorial 248 of 975

Worked Bartlett Test For Equal Variances

Learn to calculate and interpret Bartlett’s corrected test statistic from group sample sizes and variances, and to assess whether the normality assumption makes its conclusion credible.

Intermediate 11 min read

What You'll Learn

  • Set up Bartlett’s test for independent normal groups with potentially different means.
  • Calculate the pooled variance and finite-sample correction from group sample sizes and variances.
  • Obtain and interpret the approximate chi-square p-value.
  • Understand why the test statistic is nonnegative and how its asymptotic calibration arises.
  • Distinguish a failure to reject equal variances from evidence that variances are equal.
  • Check normality and data quality before relying on Bartlett’s test.

When Bartlett’s Test Is Useful

When comparing several groups, a common-variance assumption may be important to the analysis. Bartlett’s test assesses whether the population variances are equal, allowing the groups to have different population means. Its calculation is straightforward once the group sample sizes and sample variances are known, but its conclusion depends on an important condition: the observations in each group should come from a normal population.

The test compares the variation within each group with the variation obtained by pooling all groups under the equal-variance hypothesis. It then uses a finite-sample correction and an approximate chi-square reference distribution. The calculation therefore gives a test result, not a substitute for checking whether the model assumptions are credible.

Definition: Suppose there are \(k\geq 2\) independent groups. In group \(i\), let \(n_i\geq 2\) observations be sampled independently from a normal population with mean \(\mu_i\) and variance \(\sigma_i^2\). Bartlett’s test assesses \(H_0:\sigma_1^2=\cdots=\sigma_k^2\) against the alternative that the group variances are not all equal. The group means \(\mu_i\) need not be equal.

The Statistic and Its Correction

Write \(s_i^2\) for the usual unbiased sample variance in group \(i\), and let \(\nu_i=n_i-1\) be its degrees of freedom. The total within-group degrees of freedom are \(\nu=\sum_{i=1}^k\nu_i\). Under the null hypothesis, the pooled variance estimates the common population variance by combining the group sums of squares.

$$ s_p^2=\frac{\sum_{i=1}^k \nu_i s_i^2}{\nu}, \qquad C=1+\frac{1}{3(k-1)} \left(\sum_{i=1}^k\frac{1}{\nu_i}-\frac{1}{\nu}\right), \qquad T=\frac{\nu\log(s_p^2)-\sum_{i=1}^k\nu_i\log(s_i^2)}{C}. $$

The correction \(C\) is the finite-sample adjustment in Bartlett’s test. For independent normal samples, \(T\) is calibrated approximately by a chi-square distribution with \(k-1\) degrees of freedom under \(H_0\). The approximation is not an exact finite-sample distribution. For an observed value \(t\), the approximate upper-tail p-value is \(P(\chi^2_{k-1}\geq t)\). Small p-values count against the equal-variance hypothesis.

The logarithms require positive sample variances. With continuous normal observations and \(n_i\geq2\), each sample variance is positive with probability one. If a group has zero sample variance, this formula is not defined; the data and analysis require further investigation rather than mechanically applying the test.

Result: The numerator of \(T\) is nonnegative, and it equals zero exactly when all the observed group sample variances are equal. To see this, \(s_p^2\) is the weighted arithmetic mean of the \(s_i^2\), with positive weights \(\nu_i/\nu\). The weighted arithmetic-geometric mean inequality gives $$ s_p^2\geq \prod_{i=1}^k(s_i^2)^{\nu_i/\nu}. $$ Taking logarithms and multiplying by \(\nu>0\) gives \(\nu\log(s_p^2)\geq\sum_i\nu_i\log(s_i^2)\). Equality in the weighted inequality holds exactly when all \(s_i^2\) are equal. Since \(C>0\), the statistic \(T\) is nonnegative as well.

Worked Calculations

For each example, the calculation follows the same sequence: find the degrees of freedom, calculate \(s_p^2\), evaluate \(C\), form \(T\), and compare it with the appropriate chi-square reference distribution. Natural logarithms are used throughout.

Worked Example: Three Groups With No Significant Evidence of Unequal Variances

Three independent normal groups have sample sizes \(10,12,8\) and sample variances \(4,9,16\). Test equality of the population variances at level \(0.05\).

The degrees of freedom are \(\nu_1=9\), \(\nu_2=11\), and \(\nu_3=7\), so \(\nu=27\). The pooled variance is $$ s_p^2=\frac{9(4)+11(9)+7(16)}{27} =\frac{36+99+112}{27} =\frac{247}{27} \approx 9.1481. $$

The correction is $$ C=1+\frac{1}{6}\left(\frac{1}{9}+\frac{1}{11}+\frac{1}{7}-\frac{1}{27}\right) \approx 1.0513. $$ The uncorrected numerator is $$ 27\log(9.1481)-\{9\log(4)+11\log(9)+7\log(16)\} \approx 59.7659-56.0542 =3.7116. $$ Thus \(T\approx3.7116/1.0513=3.53\). There are \(k-1=2\) degrees of freedom; the approximate p-value is about \(0.171\). Since \(0.171>0.05\), we do not reject equal population variances. This result is not proof that the variances are equal; it says these data do not provide sufficient evidence against equality at the chosen level.

Worked Example: A Result That Rejects Equal Variances

Suppose three independent normal groups each have sample size \(15\), with sample variances \(1,4,16\). Test the equal-variance hypothesis at level \(0.05\).

Each group has \(14\) degrees of freedom, and \(\nu=42\). The pooled variance is $$ s_p^2=\frac{14(1)+14(4)+14(16)}{42} =\frac{294}{42}=7. $$ The correction is $$ C=1+\frac{1}{6}\left(\frac{3}{14}-\frac{1}{42}\right) =1+\frac{1}{6}\left(\frac{8}{42}\right) \approx1.0317. $$

The numerator is $$ 42\log(7)-14\{\log(1)+\log(4)+\log(16)\} \approx81.7282-58.2244 =23.5039. $$ Therefore \(T\approx23.5039/1.0317=22.78\). With \(2\) degrees of freedom, the approximate upper-tail p-value is about \(0.000011\). This is below \(0.05\), so we reject \(H_0\): the observed sample variances provide strong evidence against equality of the population variances, provided the model assumptions are reasonable.

Worked Example: Unequal Sample Sizes and an Assumption Check

Three independent groups have sample sizes \(6,10,15\), sample variances \(3,5,12\), and are provisionally treated as normal. Calculate the test result at level \(0.05\), then state what should be checked before relying on it.

Here \((\nu_1,\nu_2,\nu_3)=(5,9,14)\), so \(\nu=28\). The pooled variance is $$ s_p^2=\frac{5(3)+9(5)+14(12)}{28} =\frac{15+45+168}{28} =\frac{57}{7} \approx8.1429. $$ The correction is $$ C=1+\frac{1}{6}\left(\frac{1}{5}+\frac{1}{9}+\frac{1}{14}-\frac{1}{28}\right) \approx1.0578. $$

The numerator is $$ 28\log(8.1429)-\{5\log(3)+9\log(5)+14\log(12)\} \approx58.7199-54.7667 =3.9532. $$ Thus \(T\approx3.9532/1.0578=3.74\), with \(2\) degrees of freedom. The approximate p-value is about \(0.154\), so we do not reject equal variances at level \(0.05\).

The arithmetic alone does not establish that the chi-square calibration is trustworthy. In particular, the first group has only six observations. Before interpreting the p-value, inspect the group data and suitable distributional diagnostics, such as normal quantile plots, for marked skewness or influential outliers. The test conclusion is conditional on the model; a questionable normality assumption makes the reported calibration questionable too.

Why the Chi-Square Reference Is Approximate

The chi-square calibration can be understood from the sampling behavior of normal-theory sample variances. Under \(H_0\), write the common variance as \(\sigma^2\). Independence and normality imply that the quantities \(\nu_i s_i^2/\sigma^2\) are independent chi-square random variables with \(\nu_i\) degrees of freedom. This gives both the large-sample calibration and its degrees of freedom.

Result: If \(k\) is fixed and every \(\nu_i\) tends to infinity, then under \(H_0\), Bartlett’s statistic \(T\) converges in distribution to \(\chi^2_{k-1}\).

For a derivation, define \(\delta_i=s_i^2/\sigma^2-1\). The chi-square central limit theorem gives \(z_i=\sqrt{\nu_i/2}\,\delta_i\xrightarrow{d}N(0,1)\), independently across groups. Let \(\bar{\delta}=\sum_i\nu_i\delta_i/\nu\). A second-order Taylor expansion of \(\log(1+x)\) around zero gives $$ \nu\log(s_p^2)-\sum_i\nu_i\log(s_i^2) =\frac{1}{2}\left\{\sum_i\nu_i\delta_i^2-\nu\bar{\delta}^{\,2}\right\}+o_p(1). $$ The linear terms cancel because \(\nu\bar{\delta}=\sum_i\nu_i\delta_i\). The Taylor remainders are \(o_p(1)\): for fixed \(k\), each \(\delta_i=O_p(\nu_i^{-1/2})\), so \(\sum_i\nu_i|\delta_i|^3=o_p(1)\), and the pooled term has the same order.

Set \(q_i=\sqrt{\nu_i/\nu}\), so \(q'q=1\). The leading quadratic expression above is \(z'(I-qq')z\), where \(z=(z_1,\ldots,z_k)'\). The matrix \(I-qq'\) is a projection of rank \(k-1\). A standard normal vector projected onto a subspace of dimension \(k-1\) has squared length distributed as \(\chi^2_{k-1}\). Finally, \(C\to1\) as all the \(\nu_i\) grow. These facts establish the stated asymptotic calibration. They also explain why the reference distribution is approximate for finite samples.

Assumptions and Interpretation

Bartlett’s test is particularly sensitive to departures from normality. Skewness and heavy tails can affect sample variances and make the nominal chi-square p-value misleading. For that reason, do not read the output as a stand-alone verdict about equal variances. Check that the groups are independent as required by the design, look for unusual observations, and assess whether normality is plausible within each group. With small samples, diagnostics can be limited, so conclusions deserve particular caution.

A common mistake is to treat \(p>0.05\) as proof that the variances are equal. The test does not establish the null hypothesis: it fails to reject it at the selected significance level. Another mistake is to compare the largest and smallest sample variances informally and use that ratio as if it were Bartlett’s statistic. The test combines all group variances with their degrees of freedom, applies the correction \(C\), and uses a chi-square reference distribution. Follow those steps, and report the conclusion in context alongside the assumptions that support it.

Check Your Understanding

Use the definitions and calculation steps above to answer these questions.

  1. For four groups with sample sizes \(8,10,12,15\), what are the four group degrees of freedom and the total \(\nu\)?
  2. Why can the group means differ under the null hypothesis of Bartlett’s test?
  3. What does the finite-sample correction \(C\) adjust, and what reference distribution is used for \(T\)?
  4. If the test gives \(p=0.12\) at level \(0.05\), what conclusion is justified, and what conclusion is not justified?
  5. Name two features of the data or study design that should be checked before relying on Bartlett’s test.
Clinical Biostats