Levene’s test

Intermediate

What you need first. Nothing else on this path comes first. This page is part of Statistical inference.

In statistical inference, Levene’s test is a test of equal variances formed by an analysis of variance on absolute deviations from each group’s centre. It tests equality of variances by replacing each observation with its absolute deviation from a centre of its own group, and then comparing those deviations with a one-way analysis of variance. The centre may be the group mean, the group median, or a trimmed mean. The three choices do not test the same finite-sample statistic, and on a skewed group they need not reach the same decision.

Levene’s test

Levene’s test
Fact Value
Topic Statistical inference
Listed on Statistical inference

Motivating example

Three groups of three observations are (3,5,7),(2,4,6),(0,2,13).(3, 5, 7), \qquad (2, 4, 6), \qquad (0, 2, 13). The first two groups are symmetric and have the same spacing. The third has the same two small values a short step apart and one value, 1313, far to the right. An ordinary one-way analysis of the raw numbers would ask whether the means differ, and it would do so under a common variance. The question here is that common variance. Levene’s test answers it by running the one-way analysis on the absolute deviations from a group centre. Using the mean, the resulting FF is 16/3≈5.33316/3 \approx 5.333, just above the upper 5%5\% point 5.1435.143 of FF on (2,6)(2, 6) degrees of freedom. Using the median, the FF is 27/37≈0.73027/37 \approx 0.730, and the test does not reject. The same three groups, with 1313 replaced by 44, give F=0F = 0 for the mean-centred statistic. One observation, and the choice of centre, both decide the 5%5\% conclusion.

One-way analysis of variance on absolute deviations

Let YijY_{ij} be observation jj in group ii, with j=1,…,nij = 1, \ldots, n_i, i=1,…,ki = 1, \ldots, k, and N=∑iniN = \sum_i n_i. Choose a centre cic_i for each group and set Zij=∣Yij−ci∣Z_{ij} = |Y_{ij} - c_i|. Write Zˉi⋅\bar Z_{i\cdot} for the mean of the ZijZ_{ij} in group ii and Zˉ⋅⋅\bar Z_{\cdot\cdot} for the mean of all NN of them. The Levene statistic is the one-way FF statistic of the ZijZ_{ij}: W=(N−k)(k−1)∑i=1kni(Zˉi⋅−Zˉ⋅⋅)2∑i=1k∑j=1ni(Zij−Zˉi⋅)2.W = \frac{(N-k)}{(k-1)} \frac{\sum_{i=1}^{k} n_i (\bar Z_{i\cdot} - \bar Z_{\cdot\cdot})^2}{\sum_{i=1}^{k} \sum_{j=1}^{n_i} (Z_{ij} - \bar Z_{i\cdot})^2}. The numerator measures how far the groups’ typical absolute deviations are from one another. The denominator measures the scatter of those absolute deviations inside the groups. Large WW is evidence against equal variances. Under the equal-variance null, and with the usual normal-theory reference for this FF ratio, WW is compared with the upper point of the FF distribution on (k−1, N−k)(k-1,\, N-k) degrees of freedom. That critical value is the upper point FαF_{\alpha}. The mean-centred form is this FF statistic applied to dij=∣Yij−Yˉi⋅∣d_{ij} = |Y_{ij} - \bar Y_{i\cdot}|.[1] It is not exactly an Fk−1, N−kF_{k-1,\, N-k} random variable, because the absolute deviations are not normal and are not independent within a group.[2]

Three centres are in use. The original statistic takes cic_i to be the group mean. Replacing that mean by a more robust centre, for example the group median, puts Zij=∣Yij−μ^i∣Z_{ij} = |Y_{ij} - \hat\mu_i| in place of dijd_{ij} in the same FF statistic. The 10%10\% trimmed mean is the third centre. The three definitions change both the robustness of the test and its power. Robustness here means that equal variances are not declared unequal merely because the data are non-normal. Power means that unequal variances are detected when they are present.[2] [1]

A one-way analysis of variance writes Yij=μ+τi+εijY_{ij} = \mu + \tau_i + \varepsilon_{ij} and compares a between-group sum of squares with a within-group sum of squares.[3] Applied to the ZijZ_{ij}, that comparison treats the groups as the treatments and the absolute deviations as the observations. Rejection then says that the groups differ in the location of ∣Y−c∣|Y - c|, which is the sense in which the scale differs. It does not say which group is more variable, and it does not by itself name a transformation.

What a rejection changes about the next comparison

A rejection says that a single variance is not a fair description of all the groups. It does not order the groups. In the mean-centred example the third group’s absolute deviations are the large ones, which is visible from (5,3,8)(5, 3, 8) against (2,0,2)(2, 0, 2), but that comparison of the ZZ means is descriptive. The test itself is one FF on all kk groups.

The procedures that used the rejected assumption are the ones to set aside. A two-sample statistic that pools the two sample variances assumes those variances are equal. If that assumption is not tenable, the comparison of the two means Yˉ1\bar Y_1 and Yˉ2\bar Y_2 uses the unpooled statistic t=Yˉ1−Yˉ2s12/n1+s22/n2,t = \frac{\bar Y_1 - \bar Y_2}{\sqrt{s_1^2/n_1 + s_2^2/n_2}}, where n1n_1 and n2n_2 are the sample sizes and s12s_1^2 and s22s_2^2 are the sample variances. The degrees of freedom are the Welch–Satterthwaite values used for a Welch interval. If the two standard deviations cannot be treated as equal, the comparison uses this unpooled statistic rather than a pooled variance. A pooled error mean square in a larger layout is the same assumption.[4] [5]

A non-rejection does not prove the variances equal, any more than a large Shapiro–Wilk pp-value proves normality. With N=9N = 9 and k=3k = 3 the FF reference on (2,6)(2, 6) degrees of freedom is wide: the median-centred W=0.730W = 0.730 has tail probability 0.5200.520. That is a failure to detect a difference in scale, not a demonstration that the scales match. The mean-centred rejection at p=0.0467p = 0.0467 is itself close to 5%5\%. Reporting 16/316/3 and 5.1435.143, rather than only the word “significant”, shows how little room there was.

Mean, median, and trimmed mean

As summarised in the NIST/SEMATECH account, sampling comparisons put the trimmed mean ahead when the underlying distribution is Cauchy, and the median ahead when it is chi-squared on 44 degrees of freedom, a skewed law. The mean-centred form has the best power of the three when the distribution is symmetric with tails that are not extreme. No single centre wins for every distribution. When the shape is unknown, the median is the centre recommended as a default: it keeps the type I behaviour under a range of non-normal laws and still has power. If the shape is known to be symmetric and not heavy-tailed, the mean is the more powerful centre.[1]

The contrast with the other classical variance tests is the reason for going through absolute deviations at all. Bartlett’s test of several variances is sensitive to departures from normality. If the samples are non-normal, the test may simply be testing for non-normality.[6] Levene’s test is an alternative to Bartlett’s test, and it is less sensitive to departures from normality.[1] The two-sample variance-ratio test uses F=s12/s22F = s_1^2/s_2^2 and compares that ratio with an FF reference.[7] A Levene statistic can be computed for two groups; it is still the FF ratio of the ZijZ_{ij}, not that ratio of sample variances.

leveneTest in the car package implements the same analysis. The default centre is the median. Setting the centre to the mean recovers the original statistic. Passing trim = 0.1 with that mean centre uses a 10%10\% trimmed mean. The default is the resistant choice, not the historically first one, and a published FF is not interpretable until the centre is named.[8]

Name the centre, then choose the comparison of means

State kk, the nin_i, the centre, WW, the degrees of freedom, and the reference probability. “Levene’s test was significant” leaves out the choice that, in the worked example, changes the decision. In leveneTest the call leveneTest(y, group) uses the median. The call with center = mean is the original statistic. The two FF values 5.3335.333 and 0.7300.730 are those two calls on these nine numbers.[8]

If the scientific question is a difference of means and WW has rejected a common variance, the follow-up is the unpooled comparison above, not a pooled tt and not a further transformation chosen because it makes WW smaller. A transformation changes the scale on which the means are compared. That may be the right scientific step, but it is not what the rejection by itself instructs. If the question is the variances, the FF on the absolute deviations is already the answer, and the next description is which groups’ deviations are large.

Bartlett’s test remains the more powerful variance comparison when there is strong evidence that the data are nearly normal. Levene’s test is the one to use when that evidence is absent or when a Shapiro–Wilk check on the residuals has already made normality doubtful. The two checks are not substitutes: one is about shape, the other is about scale.[1] [6]

Three groups, two centres

The groups are those in the motivating example, ni=3n_i = 3, k=3k = 3, N=9N = 9. The analysis-of-variance FF therefore has 22 and 66 degrees of freedom, and the upper 5%5\% point of that FF law is 5.1435.143.

The group means are 55, 44 and 55. The absolute deviations from those means are (2,0,2),(2,0,2),(5,3,8).(2, 0, 2), \qquad (2, 0, 2), \qquad (5, 3, 8). Their group means are 4/34/3, 4/34/3 and 16/316/3. The nine deviations add to 2424, so the grand mean is 8/38/3. The between-group sum of squares is 3[(43−83)2+(43−83)2+(163−83)2]=3⋅16+16+649=32.3\Bigl[\Bigl(\frac{4}{3}-\frac{8}{3}\Bigr)^2 + \Bigl(\frac{4}{3}-\frac{8}{3}\Bigr)^2 + \Bigl(\frac{16}{3}-\frac{8}{3}\Bigr)^2\Bigr] = 3 \cdot \frac{16+16+64}{9} = 32. Inside the first group the deviations from 4/34/3 are 2/32/3, −4/3-4/3 and 2/32/3, and the sum of squares is 8/38/3. The second group contributes the same 8/38/3. Inside the third group the deviations from 16/316/3 are −1/3-1/3, −7/3-7/3 and 8/38/3, and the sum of squares is 38/338/3. The within-group sum of squares is 8/3+8/3+38/3=188/3 + 8/3 + 38/3 = 18. Then W=32/218/6=163≈5.333.W = \frac{32/2}{18/6} = \frac{16}{3} \approx 5.333. Since 16/3>5.14316/3 > 5.143, the mean-centred test rejects equal variances at 5%5\%. The upper-tail FF probability is 0.04670.0467.

The group medians are 55, 44 and 22. Groups AA and BB are symmetric, so their absolute deviations do not change. Group C=(0,2,13)C = (0, 2, 13) has median 22, and its absolute deviations are 22, 00 and 1111. The group means of the deviations are 4/34/3, 4/34/3 and 13/313/3, and the grand mean is 7/37/3. The between-group sum of squares is 1818 and the within-group sum of squares is 7474, so W=18/274/6=2737≈0.730.W = \frac{18/2}{74/6} = \frac{27}{37} \approx 0.730. The upper-tail probability is 0.5200.520. The median-centred test does not reject. leveneTest with center = mean returns F=5.3333F = 5.3333 on (2,6)(2, 6) degrees of freedom, and with the default median centre it returns F=0.7297F = 0.7297. The hand arithmetic and the function agree.[8]

The two calculations use the same observations and the same FF reference. They differ in cic_i for the skewed group. The mean of (0,2,13)(0, 2, 13) is 55, pulled toward the outlier, and the absolute deviations 5,3,85, 3, 8 are moderately spread. The median stays at 22, and the absolute deviations 2,0,112, 0, 11 put almost all of the within-group square on the single large residual. That inflates the denominator of WW and the statistic falls from 16/316/3 to 27/3727/37. Choosing the centre is part of the test. On this sample it changes the 5%5\% decision.

Replace 1313 by 44, so the third group is (0,2,4)(0, 2, 4). Every group is then an arithmetic progression with the same spacing, and the absolute deviations from each group mean are (2,0,2)(2, 0, 2). The three groups of ZijZ_{ij} are identical, the between-group sum of squares is 00, and W=0W = 0. The mean-centred rejection was carried by the value 1313. A variance test that ignores that fact has reported a property of one observation.

Your turn. Two groups are (0,2,4)(0, 2, 4) and (0,2,10)(0, 2, 10). The centres are the group means, 22 and 44. The absolute deviations are (2,0,2)(2, 0, 2) and (4,2,6)(4, 2, 6). Compute the mean-centred WW. The upper 5%5\% point of FF on (1,4)(1, 4) degrees of freedom is 7.7097.709. Does the test reject?

The group means of the absolute deviations are 4/34/3 and 44, and the grand mean is 8/38/3. The between sum of squares is 32/332/3 and the within sum of squares is 32/332/3. Then W=(32/3)/((32/3)/4)=4W = (32/3) / ((32/3)/4) = 4. Since 4<7.7094 < 7.709, the mean-centred test does not reject equal variances at 5%5\%.

The FF reference is an approximation to a ratio of absolute deviations

The statistic WW is exactly the one-way FF of the constructed variables ZijZ_{ij}. The comparison of WW with Fk−1,N−kF_{k-1, N-k} treats that ratio as if it had the normal-theory FF distribution. The ZijZ_{ij} are absolute deviations, hence skewed and dependent within a group, because the centre cic_i is computed from the same observations. The FF tail is an approximation to the null distribution of this ratio, not a theorem that ∣Yij−ci∣|Y_{ij} - c_i| is normal. The case for the procedure is that the approximation is less easily wrecked by a non-normal YY than Bartlett’s chi-squared form. That is an empirical claim about type I behaviour, taken from the sampling comparisons, not an exact null.[1]

With ni=3n_i = 3 the median of a group is the middle observation, so one of the three absolute deviations is zero whenever the median is unique. The within-group sum of squares is then carried by the other two points. That is visible in the median-centred third group, where 11211^2 dominates 7474. With a larger group the centre is estimated from more observations, and one wild point is a smaller share of the within-group sum of squares. The worked example shows the effect of the centre at ni=3n_i = 3. It does not estimate power at large nin_i.

The rejection rule is WW greater than the upper point of Fk−1, N−kF_{k-1,\, N-k}.[1]

The variance ratio, the pooled comparison, and the shape check

The F test for equal variances is the two-sample ratio s12/s22s_1^2/s_2^2. One-way analysis of variance is both the motive for checking a common variance and the arithmetic applied to the absolute deviations. A Welch interval is the two-sample comparison of means that does not pool the variances. The two-sample tt test is that comparison in either its pooled or its unpooled form; which form is legal depends on the variance conclusion. The Shapiro–Wilk test concerns normality rather than scale. A doubt it raises about the residuals is a reason to prefer Levene’s variance check to Bartlett’s.

Check yourself

1. Two new groups are (1,2,9)(1, 2, 9) and (4,5,6)(4, 5, 6). Using the group means as centres, what is WW? The upper 5%5\% point of FF on (1,4)(1, 4) degrees of freedom is 7.7097.709.

The means are 44 and 55. The absolute deviations are (3,2,5)(3, 2, 5) and (1,0,1)(1, 0, 1), with group means 10/310/3 and 2/32/3 and grand mean 22. The between sum of squares is 32/332/3 and the within sum of squares is 16/316/3, so W=(32/3)/((16/3)/4)=8W = (32/3)/((16/3)/4) = 8. Since 8>7.7098 > 7.709, the mean-centred test rejects at 5%5\%.

2. For the same two groups, (1,2,9)(1, 2, 9) and (4,5,6)(4, 5, 6), use the group medians as centres. What is WW, and does the 5%5\% test reject? The upper 5%5\% point is again 7.7097.709.

The medians are 22 and 55. The absolute deviations are (1,0,7)(1, 0, 7) and (1,0,1)(1, 0, 1). The between sum of squares is 66 and the within sum of squares is 88/388/3, so W=6/((88/3)/4)=9/11≈0.818W = 6/((88/3)/4) = 9/11 \approx 0.818. Since 9/11<7.7099/11 < 7.709, the median-centred test does not reject. The choice of centre changes the 5%5\% decision.

3. The mean-centred test has rejected a common variance, and the next question is a difference between two of the group means. Which two-sample statistic does not use the rejected assumption?

The unpooled statistic, (Yˉ1−Yˉ2)(\bar Y_1 - \bar Y_2) divided by the square root of s12/n1+s22/n2s_1^2/n_1 + s_2^2/n_2, with Welch–Satterthwaite degrees of freedom. The pooled two-sample statistic uses one variance for both groups.

The mean in 1960, the median and the trimmed mean in 1974

The mean-centred statistic is the analysis of variance of absolute deviations from the group means, the form dated to 1960. Replacing those means by the group medians is the 1974 modification. The comparison of the mean, the median and the 10%10\% trimmed mean, as summarised in the NIST/SEMATECH account, is the guidance that the trimmed mean behaves best for a heavy-tailed symmetric law such as the Cauchy, the median best for a skewed law such as χ42\chi^2_4, and the mean best for symmetric distributions with moderate tails. When the shape is not known in advance, the median is the robust default drawn from that summary.[2] [1] The software default is the same median centre.[8]

See also

Line chart · Apriori algorithm · Asymptotic analysis · Average treatment effect · Base rate · Bayesian inference · Bayesian model · Bayesian probability

Glossary and index

References

  1. ^ a b c d e f g h a. (§1.3.5.10) b. (§1.3.5.10) c. (§1.3.5.10) d. (§1.3.5.10) e. (§1.3.5.10) f. (§1.3.5.10) g. (§1.3.5.10) h. (§1.3.5.10) NIST/SEMATECH (2002). NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.10: Levene Test for Equality of Variances. National Institute of Standards and Technology. https://www.itl.nist.gov/div898/handbook/eda/section3/eda35a.htm
  2. ^ a b c a. (§1, equation (3)) b. (§1) c. (§1, equation (3)) Gastwirth, Joseph L., Gel, Yulia R. & Miao, Weiwen (2009). The Impact of Levene's Test of Equality of Variances on Statistical Theory and Practice. Statistical Science, 24(3), 343–360. https://doi.org/10.1214/09-STS301
  3. ^ (pp. 399–400) Dodge, Yadolah (2008). The Concise Encyclopedia of Statistics. Springer. https://doi.org/10.1007/978-0-387-32833-1
  4. ^ (§1.3.5.3) NIST/SEMATECH (2002). NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.3: Two-Sample t-Test for Equal Means. National Institute of Standards and Technology. https://www.itl.nist.gov/div898/handbook/eda/section3/eda353.htm
  5. ^ (§7.3.1) NIST/SEMATECH (2002). NIST/SEMATECH e-Handbook of Statistical Methods, §7.3.1: Comparison of Two Means. National Institute of Standards and Technology. https://www.itl.nist.gov/div898/handbook/prc/section3/prc31.htm
  6. ^ a b a. (§1.3.5.7) b. (§1.3.5.7) NIST/SEMATECH (2002). NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.7: Bartlett's Test. National Institute of Standards and Technology. https://www.itl.nist.gov/div898/handbook/eda/section3/eda357.htm
  7. ^ (§1.3.5.9) NIST/SEMATECH (2002). NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.9: F-Test for Equality of Two Variances. National Institute of Standards and Technology. https://www.itl.nist.gov/div898/handbook/eda/section3/eda359.htm
  8. ^ a b c d a. (Arguments, `center` and `...`) b. (Usage and Arguments, `center`) c. (Usage, `center`) d. (Arguments, `center`) Fox, John (2026). Levene's Test (car package documentation for leveneTest). Comprehensive R Archive Network. https://search.r-project.org/CRAN/refmans/car/html/leveneTest.html
Cite this page
Plain text
StatWiki (2026). "Levene's test." StatWiki. Last updated 2 December 2026. https://www.statwiki.io/articles/levene-s-test.html
BibTeX
@misc{statwiki_levene_s_test,
  author = {{StatWiki}},
  title = {{Levene's test}},
  year = {2026},
  url = {https://www.statwiki.io/articles/levene-s-test.html},
  urldate = {2026-12-02},
  note = {StatWiki, last updated 2 December 2026}
}