Unit 8, lesson 60

Inference for Variance and Comparing Spread

How the chi-square pivot gives confidence intervals for a variance and a standard deviation, how the F test and the Levene and Brown-Forsythe tests compare spread, and how much each one depends on normality.

  • Video 60
  • Comparing Distributions and Spread

Two filling machines can put the same average amount into bottles while one of them varies far more from bottle to bottle. When consistency is the question, an interval for the mean does not answer it. This lesson builds confidence intervals for a population variance and standard deviation from the chi-square pivot, compares two variances with the F test, and compares spread across groups with the Levene and Brown-Forsythe tests. Each method rests on a model, and the classical ones depend on normality far more strongly than the t procedures for means do.

Key terms

Chi-square pivot

Definition A pivot is a function of the data and an unknown parameter whose distribution is completely known, the same for every value of the parameters. Let X1,…,XnX_1, \dots, X_n be independent observations from one normal population N(μ,σ2)N(\mu, \sigma^2), with σ>0\sigma > 0 and n≥2n \ge 2, and let S2S^2 be the sample variance with denominator n−1n - 1. Then

Q=(n−1)S2σ2∼χn−12,Q = \frac{(n - 1) S^2}{\sigma^2} \sim \chi^2_{n-1} ,

whatever the values of μ\mu and σ\sigma. Write χν, p2\chi^2_{\nu,\,p} for the pp quantile of χν2\chi^2_\nu. For 0<α<10 < \alpha < 1 the pivot lies between χn−1, α/22\chi^2_{n-1,\,\alpha/2} and χn−1, 1−α/22\chi^2_{n-1,\,1-\alpha/2} with probability exactly 1−α1 - \alpha. The result needs independence and normality. It holds for every n≥2n \ge 2 under that model, but a large sample does not in general rescue it when the population is not normal, as the last card explains.

In plain words The unknown σ2\sigma^2 divides the sample variance, which removes the scale, so the distribution of the ratio is the same whatever the true spread. That known distribution is what turns a probability statement about QQ into an interval for σ2\sigma^2.

Example Five constructed measurements of a part, in millimeters, are 88, 99, 1010, 1111 and 1212. The mean is xˉ=10\bar{x} = 10, the deviations are −2-2, −1-1, 00, 11 and 22, and their squares add to 1010. So s2=10/4=2.5 mm2s^2 = 10/4 = 2.5 \ \text{mm}^2 and s=2.5≈1.581 mms = \sqrt{2.5} \approx 1.581 \ \text{mm}. Under the normal model 4S2/σ24S^2/\sigma^2 has the χ42\chi^2_4 distribution, whose 0.0250.025 and 0.9750.975 quantiles are about 0.484420.48442 and 11.143311.1433, so the event

0.48442≤4S2σ2≤11.14330.48442 \le \frac{4S^2}{\sigma^2} \le 11.1433

has probability 0.950.95 before the data are seen. For these data the observed value of the pivot is 10/σ210/\sigma^2, which still contains the unknown σ2\sigma^2.

Confidence interval for a standard deviation

Definition Under the same model, solving the pivot inequality for σ2\sigma^2 gives the 100(1−α)100(1 - \alpha) percent confidence interval [L,U][L, U] for σ2\sigma^2, with

L=(n−1)s2χn−1, 1−α/22,U=(n−1)s2χn−1, α/22.\begin{aligned} L &= \frac{(n - 1)s^2}{\chi^2_{n-1,\,1-\alpha/2}} , \\[0.4em] U &= \frac{(n - 1)s^2}{\chi^2_{n-1,\,\alpha/2}} . \end{aligned}

The larger quantile gives the lower endpoint, because dividing by a larger positive number gives a smaller result. The interval for σ2\sigma^2 is in squared units. The square root is increasing on the nonnegative numbers, so σ2\sigma^2 lies in [L,U][L, U] exactly when σ\sigma lies in [L,U][\sqrt{L}, \sqrt{U}]. Hence [L,U][\sqrt{L}, \sqrt{U}] is a confidence interval for σ\sigma with the same confidence level, in the original units. The intervals are not symmetric about the sample values s2s^2 and ss. The confidence level describes the procedure. For a 95 percent interval this means that, in repeated samples from the normal model, 95 percent of the intervals built this way contain σ\sigma, which is not the same as a 95 percent probability that σ\sigma lies in one computed interval.

In plain words Take the square roots of both endpoints, not of the width or of the midpoint. Spread is hard to pin down from a few observations, so with a small sample the interval is long and reaches much farther above the sample value than below it.

Example For the five measurements, (n−1)s2=10(n - 1)s^2 = 10, so in square millimeters

L=1011.1433≈0.8974,U=100.48442≈20.643.\begin{aligned} L &= \frac{10}{11.1433} \approx 0.8974 , \\[0.4em] U &= \frac{10}{0.48442} \approx 20.643 . \end{aligned}

The 95 percent interval for σ\sigma runs from 0.8974≈0.947 mm\sqrt{0.8974} \approx 0.947 \ \text{mm} to 20.643≈4.543 mm\sqrt{20.643} \approx 4.543 \ \text{mm}. The sample value s≈1.581 mms \approx 1.581 \ \text{mm} lies about 0.63 mm0.63 \ \text{mm} above the lower end and about 2.96 mm2.96 \ \text{mm} below the upper end, and the upper end is almost three times ss. Five observations leave the spread very uncertain, even when the normal model is right.

F test for two variances

Definition Suppose two independent samples of sizes n1≥2n_1 \ge 2 and n2≥2n_2 \ge 2 consist of independent observations from normal populations N(μ1,σ12)N(\mu_1, \sigma_1^2) and N(μ2,σ22)N(\mu_2, \sigma_2^2). Then

S12/σ12S22/σ22∼Fn1−1, n2−1.\frac{S_1^2 / \sigma_1^2}{S_2^2 / \sigma_2^2} \sim F_{n_1 - 1,\, n_2 - 1} .

To test H0 ⁣:σ12=σ22H_0\colon \sigma_1^2 = \sigma_2^2 against H1 ⁣:σ12≠σ22H_1\colon \sigma_1^2 \ne \sigma_2^2, use the statistic F=S12/S22F = S_1^2 / S_2^2, which under H0H_0 has the Fn1−1, n2−1F_{n_1 - 1,\, n_2 - 1} distribution. For an observed value ff, the equal-tailed two-sided p-value is 2min⁡{P(F≤f),P(F≥f)}2\min\{P(F \le f), P(F \ge f)\}. Putting the other sample on top swaps the degrees of freedom and gives the same two-sided p-value. Inverting the same pivot gives a confidence interval for the ratio σ12/σ22\sigma_1^2 / \sigma_2^2.

In plain words The test compares two sample variances through their ratio. A ratio far from 11 in either direction is evidence of unequal variances, but with small samples ratios far from 11 are common even when the variances are equal, and nonnormal data can produce extreme ratios too. A nonsignificant result does not show that the variances are equal. Welch’s t test and Welch’s ANOVA allow unequal variances from the start, so no preliminary variance test is needed before using them, and letting such a test choose the method changes the error rates of the whole two-stage analysis.

Example The constructed groups A={1,2,3}A = \{1, 2, 3\} and B={0,2,4}B = \{0, 2, 4\} both have mean 22, with sample variances sA2=1s_A^2 = 1 and sB2=4s_B^2 = 4. With BB on top, f=4f = 4 on 22 and 22 degrees of freedom. The F2,2F_{2,2} distribution has the simple tail P(F≥x)=1/(1+x)P(F \ge x) = 1/(1 + x) for x≥0x \ge 0, so P(F≥4)=0.2P(F \ge 4) = 0.2 and the two-sided p-value is 0.40.4. The same formula gives 1/391/39 and 3939 as the 0.0250.025 and 0.9750.975 quantiles of F2,2F_{2,2}, so the 95 percent interval for σB2/σA2\sigma_B^2 / \sigma_A^2 is

[439, 4⋅39]≈[0.103, 156].\Bigl[\frac{4}{39},\ 4 \cdot 39\Bigr] \approx [0.103,\ 156] .

These tiny samples are compatible both with equal variances and with a variance ratio above one hundred.

Levene test

Definition Let k≥2k \ge 2 independent groups have observations YijY_{ij}, where j=1,…,kj = 1, \dots, k labels the group and i=1,…,nji = 1, \dots, n_j the observation, and let N=n1+⋯+nkN = n_1 + \dots + n_k. Levene’s test replaces each observation by its absolute deviation from a group center cjc_j,

Zij=∣Yij−cj∣,Z_{ij} = \lvert Y_{ij} - c_j \rvert ,

where the original version uses the group mean, cj=Yˉjc_j = \bar{Y}_j. It then computes the one-way ANOVA F statistic of the deviations,

W=SSB/(k−1)SSW/(N−k),W = \frac{\text{SS}_{\text{B}}/(k - 1)}{\text{SS}_{\text{W}}/(N - k)} ,

with between-group sum of squares SSB=∑jnj(Zˉj−Zˉ)2\text{SS}_{\text{B}} = \sum_j n_j (\bar{Z}_j - \bar{Z})^2 and within-group sum of squares SSW=∑j∑i(Zij−Zˉj)2\text{SS}_{\text{W}} = \sum_j \sum_i (Z_{ij} - \bar{Z}_j)^2, where Zˉj\bar{Z}_j is the mean of the deviations in group jj and Zˉ\bar{Z} the mean of all NN deviations. It compares WW with Fk−1, N−kF_{k-1,\, N-k}. The null hypothesis is that the groups have equal population mean absolute deviations from their centers. This matches equal variances when the group distributions have the same shape apart from scale. The F reference is approximate, even for normal data, and the test requires independent observations within and between groups.

In plain words Replace each observation by its distance from its group’s center, then ask with an ordinary ANOVA whether some groups have larger typical distances than others. A more spread out group tends to have larger distances. The mean-centered version can reject a true null hypothesis too often when the populations are skewed, which is why the median-centered version in the next card is often preferred.

Example For A={1,2,3}A = \{1, 2, 3\} and B={0,2,4}B = \{0, 2, 4\}, each group has mean 22, which is also its median. The deviations are ZA=(1,0,1)Z_A = (1, 0, 1) and ZB=(2,0,2)Z_B = (2, 0, 2), with group means 2/32/3 and 4/34/3 and grand mean 11. So SSB=3(1/3)2+3(1/3)2=2/3\text{SS}_{\text{B}} = 3(1/3)^2 + 3(1/3)^2 = 2/3 and SSW=2/3+8/3=10/3\text{SS}_{\text{W}} = 2/3 + 8/3 = 10/3, which give

W=(2/3)/1(10/3)/4=2/35/6=0.8.\begin{aligned} W &= \frac{(2/3)/1}{(10/3)/4} \\[0.4em] &= \frac{2/3}{5/6} = 0.8 . \end{aligned}

Compared with F1,4F_{1,4}, the p-value is P(F1,4≥0.8)≈0.422P(F_{1,4} \ge 0.8) \approx 0.422. The calculation shows the mechanics only. Six constructed observations do not establish a real difference in consistency.

Brown-Forsythe test

Definition The Brown-Forsythe test for spread is Levene’s procedure with each group’s median as the center, Zij=∣Yij−Y~j∣Z_{ij} = \lvert Y_{ij} - \tilde{Y}_j \rvert, where Y~j\tilde{Y}_j is the median of group jj. The statistic WW and its approximate Fk−1, N−kF_{k-1,\, N-k} reference are as before. Median centering makes the test less sensitive to skewness and to extreme observations, and simulation studies have found that it keeps the actual error rate closer to the nominal level than mean centering when populations are skewed. It is not free of assumptions. It still needs independent observations, its F reference is still an approximation, least reliable for tiny groups, and like Levene’s test it compares mean absolute deviations rather than variances directly. The same names are also attached to a different procedure, a test of equal means that allows unequal variances, so a report should say which one it used.

In plain words Measure each observation’s distance from its group median instead of its group mean. In a group of three or more, making the largest value even larger moves the group mean, and with it the distances measured from the mean, but leaves the median and the other distances from it unchanged.

Example In the group {1,2,9}\{1, 2, 9\} the mean is 44 and the median is 22. The deviations from the mean are 33, 22 and 55, so the two ordinary values look far from the center because the extreme value has pulled the center toward itself. The deviations from the median are 11, 00 and 77, which keep the ordinary values near the center and assign the spread to the one extreme value. In a group of odd size the middle observation always has deviation 00 from the median, as in ZAZ_A and ZBZ_B above. For those two groups each mean equals the median, so the Brown-Forsythe test gives the same W=0.8W = 0.8 and p-value of about 0.4220.422 as Levene’s test.

Sensitivity to nonnormality

Definition A procedure is sensitive to nonnormality when its actual coverage or error rate moves away from the stated level once the population is not normal. The chi-square interval and the F test for variances are highly sensitive in this sense. For n≥2n \ge 2 independent observations from a population with mean μ\mu, variance σ2>0\sigma^2 > 0 and finite fourth moment,

Var⁡(S2)σ4=2n−1+κn,\frac{\operatorname{Var}(S^2)}{\sigma^4} = \frac{2}{n - 1} + \frac{\kappa}{n} ,

where κ=E((X−μ)4)/σ4−3\kappa = E\bigl((X - \mu)^4\bigr)/\sigma^4 - 3 is the excess kurtosis, equal to 00 for every normal population. The chi-square model builds in κ=0\kappa = 0. When κ>0\kappa > 0, as for heavy-tailed populations, the sample variance varies more than the model says, so in large samples the intervals cover σ2\sigma^2 less often than claimed and the F test rejects true null hypotheses too often. When κ<0\kappa < 0 the errors run the other way. Both terms shrink at the same rate, so the discrepancy does not go away as nn grows. By contrast, the t interval for a mean has approximately correct coverage in large samples from any population with finite variance.

In plain words The mean of a large sample is approximately normal for any population with finite variance, but the sample variance squares the deviations and so carries the population’s tail behavior with it. A few large deviations can dominate S2S^2, and the chi-square model does not allow for them. Normality is a real condition of these methods, not a small-sample technicality. When spread matters and normality is doubtful, a different spread target, a resampling method justified for the sample size, or a model chosen for the population’s shape may serve better.

Example An exponential population is strongly right-skewed and has κ=6\kappa = 6. As nn grows, the coverage of the nominal 95 percent chi-square interval tends to

2Φ(1.9622+κ)−1=2Φ(0.98)−1≈0.673,\begin{aligned} &2\Phi\Bigl(1.96\sqrt{\tfrac{2}{2 + \kappa}}\Bigr) - 1 \\[0.4em] &\quad = 2\Phi(0.98) - 1 \approx 0.673 , \end{aligned}

where Φ\Phi is the standard normal cumulative distribution function. In simulations the coverage is already about 0.820.82 for samples of 55 and about 0.730.73 for samples of 2020. For two large samples from the same exponential population, a nominal 5 percent two-sided F test rejects in about 1−0.673≈0.331 - 0.673 \approx 0.33 of samples. For a uniform population, with κ=−1.2\kappa = -1.2, the limiting coverage is about 0.9980.998 instead of 0.950.95.

Check yourself

  1. Under the normal model, a 95 percent confidence interval for the variance of fill weights is [0.36, 6.25][0.36,\ 6.25] in square grams. Give the 95 percent interval for the standard deviation. A classmate instead takes the square root of the midpoint of the variance interval and of its half-width, and reports the midpoint root plus or minus the half-width root. Why is that wrong?
Show the answer

Take the square root of each endpoint. The interval for σ\sigma is [0.36,6.25]=[0.6, 2.5][\sqrt{0.36}, \sqrt{6.25}] = [0.6,\ 2.5] in grams. Since the square root is increasing on the nonnegative numbers, σ2\sigma^2 lies in [0.36,6.25][0.36, 6.25] exactly when σ\sigma lies in [0.6,2.5][0.6, 2.5], so the confidence level is still 95 percent.

The classmate’s method gives the midpoint root 3.305≈1.818\sqrt{3.305} \approx 1.818 and the half-width root 2.945≈1.716\sqrt{2.945} \approx 1.716, hence about [0.102, 3.534][0.102,\ 3.534]. That interval does not correspond to the variance interval, so it carries no 95 percent guarantee. The square root does not commute with adding and subtracting, and only the endpoints can be carried over.

  1. The five measurements 88, 99, 1010, 1111 and 1212 mm came from a process that is known to produce strongly right-skewed values, with an exponential-like shape. Is [0.947, 4.543][0.947,\ 4.543] mm still a 95 percent confidence interval for σ\sigma? Would measuring 10001000 parts instead of five fix the problem?
Show the answer

The arithmetic can still be done, but the 95 percent label no longer follows. The exact coverage came from the pivot (n−1)S2/σ2∼χn−12(n - 1)S^2/\sigma^2 \sim \chi^2_{n-1}, which requires a normal population. An exponential population has excess kurtosis κ=6\kappa = 6, so the sample variance varies far more than the chi-square model assumes, and the intervals are too short to reach the claimed coverage. Simulations give a coverage of about 0.820.82 for samples of five from an exponential population.

A larger sample does not repair this. The term κ/n\kappa/n in the variance of S2S^2 shrinks at the same rate as the normal-model term 2/(n−1)2/(n - 1), and for an exponential population the coverage tends to about 0.6730.673 as nn grows. With 10001000 parts the estimate ss would be much more precise, but the interval would still claim a coverage it does not have. A method justified for the population’s shape, or a different spread target, is needed.

  1. Two constructed groups are A={4,5,6}A = \{4, 5, 6\} and B={0,5,10}B = \{0, 5, 10\}. Find the F statistic with BB on top and its two-sided p-value, using P(F≥x)=1/(1+x)P(F \ge x) = 1/(1 + x) for F2,2F_{2,2}. An analyst sees that the result is not significant at the 5 percent level, concludes that the variances are equal and pools them for a t test of the means. What is wrong?
Show the answer

The sample variances are sA2=1s_A^2 = 1 and sB2=25s_B^2 = 25, so f=25f = 25 on 22 and 22 degrees of freedom. The upper tail is P(F≥25)=1/26P(F \ge 25) = 1/26, and the two-sided p-value is

2⋅126=113≈0.077.2 \cdot \frac{1}{26} = \frac{1}{13} \approx 0.077 .

The sample standard deviations are 11 and 55, yet the test does not reject at the 5 percent level, because three observations per group say little about spread. Not rejecting does not show that the variances are equal. The 95 percent interval for σB2/σA2\sigma_B^2/\sigma_A^2 is [25/39, 25⋅39]≈[0.64, 975][25/39,\ 25 \cdot 39] \approx [0.64,\ 975], which includes 11 and also enormous ratios. The F test also depends strongly on normality. The analyst should compare the means with Welch’s t test, which allows unequal variances, without making it depend on a preliminary variance test.

How this lesson connects