# A Nonparametric Two-Sample Wald Test of Equality of Variances

Authors: David Allingham; J. C. W. Rayner
Journal: Advances in Decision Sciences
 (2011)

---

## Abstract

We develop a test for equality of variances given two independent random samples of observations. The test can be expected to perform well when both sample sizes are at least moderate and the sample variances are asymptotically equivalent to the maximum likelihood estimators of the population variances. The test is motivated by and is here assessed for the case when both populations sampled are assumed to be normal. Popular choices of test would be the two-sampleF test if normality can be assumed and Levene’s test if this assumption is dubious. Another competitor is the Wald test for the difference in the population variances. We give a nonparametric analogue of this test and call it the R test. In an indicative empirical study when both populations are normal, we find that when both sample sizes are at least 25 the R test is nearly as robust as Levene’s test and nearly as powerful as the F test.


---

## Body

## 1. Introduction: Testing Equality of Variances for Two Independent Samples

In the two-sample problem, we are given two independent random samplesX11,…,X1n1and X21,…,X2n2. The location problem attracts most attention. Assuming that the samples are from normal populations, the pooled t-test is used to test equality of means assuming equal variances and Welch’s test can be used when equality of variances is suspect but normality is not. When normality is in doubt, the Wilcoxon test is often used.The corresponding dispersion problem is of interest to confirm the validity of, for example, the pooledt-test, and when dispersion differences are of direct interest. For example, testing for reduced variability is of interest in confirming natural selection (see, e.g., [1, Section  5.5]) and if some processes are in control. In exploratory data analysis, it is sensible to assess if one population is more variable than another. If it is, the cause may be that one population is bimodal and the other is not; the consequences of this in both the scenario and the model can then be explored in depth.The study here introduces a new test of equality of variances. The asymptotic null distribution of the test statistic isχ12, but, depending on the populations sampled from, this may or may not be satisfactory for small to moderate sample sizes.To assess this, and other aspects of the proposed test, an indicative empirical study is undertaken. We give comparisons when both populations sampled are normal, when both samples have the same sample size, and for 5% level tests. First, we derive a finite sample correction to the critical values based on the asymptotic null distribution when sampling from normal populations. Different corrections would be needed when sampling from different distributions. Next, we show that in moderate samples the new test is nearly as powerful as theF test when normality may be assumed and, finally, that it is nearly as robust as Levene’s test when normality is in doubt. Moore and McCabe [2, page  519] claim that the “F test and other procedures for inference about variances are so lacking in robustness as to be of little use in practice.” The new test gives a counterexample to that proposition.We acknowledge that the new test is the most effective for at least moderate sample sizes. In the normal case, each random sample should have at least 25 observations, which is what we would expect of a serious study aiming at reasonable power that cannot be hoped for with samples of size 10 or so. See Section4.We are aware of more expansive comparative studies such as [3, 4]. Our goal here is not to emulate these studies but to show that the new test is competitive in terms of test size, robustness, and power.In Section2, the new test is introduced. Sections 3, 4, and 5 give the results of an empirical investigation when the populations sampled are assumed to be normal. In Section 3, we investigate test size, showing that the asymptotic χ2 critical values should only be used for moderate to large sample sizes. For smaller sample sizes, a finite sample correction to the asymptotic 5%  χ2 critical value is given. This results in actual test sizes between 4.6% and 5.3%.In Section4, we show that when normality holds, the new test is not as powerful as the Levene test for smaller sample sizes but overtakes it for moderate samples of about 25. The new test is always inferior to the optimal F test. However, the R test has power that approaches that of the F test, being at least 95% that of the F test throughout most of the parameter space in samples of at least 80.In Section5, we show that if we sample from t-distributions with varying degrees of freedom, the F test is highly nonrobust for small degrees of freedom, as is well known for fat-tailed distributions. When both populations sampled are gamma distributions, chosen to model skewness differences from normality, or t-distributions, chosen to model kurtosis differences, the new test performs far better than the F test, and is competitive with the Levene test.That the new test gives a good compromise between power and robustness and is valid when normality does not hold are strong reasons for preferring the new test for sample sizes that are at least moderate, and normality is dubious.


## 2. Competitor Tests for Equality of Variance

Initially we assume that we have two independent random samplesXi1,…,Xini from normal populations, N(μi,σi2)for i=1 and 2. We wish to test H:σ12=σ22 against the alternative K:σ12≠σ22, with the population means being unknown nuisance parameters. If Si2=∑j=1ni(Xij-X̅i.)2/(ni-1), in which X̅i.=∑j=1niXij/ni, i=1,2, then the Si2 are the unbiased sample variances, and the so-called F test is based on their quotient, S22/S12=F, say. It is well known and will be confirmed yet again in Section 5 that the null distribution of F, Fn1-1,n2-1, is sensitive to departures from normality. If Fn1-1,n2-1(x)is the cumulative distribution function of the Fn1-1,n2-1 distribution, and if cp is such that Fn1-1,n2-1(cp)=p, then the F test rejects H at the 100α% level when F≤cα/2 and when F≥c(1-α/2).Common practice when normality is in doubt is to use Levene’s test or a nonparametric test such as Mood’s test. Levene’s test is based on the ANOVAF test applied to the residuals. There are different versions of Levene’s test using different definitions of residual. The two most common versions use residuals based on the group means, |Xij-X̅i.|, and the group medians, |Xij-X̃i.|, in which X̃i. is the median of the ith sample. The latter is called the Brown-Forsythe test. Again it is well known that these tests are robust in that when the population variances are equal but the populations themselves are not normal, they achieve levels close to nominal. However, this happens at the expense of some power. As the empirical study in this paper is intended to be indicative rather than exhaustive, we will henceforth make comparisons only with the Levene test, based on a test statistic we denote by L.We now construct a new test that we call theR test. For univariate parameters θ, a Wald test statistic of H:θ=θ0 against the alternative K:θ≠θ0 is based on θ̂, the maximum likelihood estimator of θ, usually via the test statistic (θ̂-θ0)2/est var(θ̂), where est var(θ̂) is the asymptotic variance of θ̂ evaluated when θ=θ̂. Under the null hypothesis, this test statistic has an asymptotic χ12distribution. As well as being equivalent to the likelihood ratio test, the F test is also a Wald test for testing H:θ=σ22/σ12=1 against K:θ≠1.Rayner [5] derived the Wald test for testing H:θ=σ22-σ12=0 against K:θ≠0. The test statistic is(2.1)(S12-S22)22S14/(n1+1)+2S24/(n2+1)=W,  say.Being a Wald test, the asymptotic distribution ofW is χ12, while its exact distribution is not immediately obvious. However, W is a 1-1 function of F, so the two tests are equivalent. Since the exact distribution of F is available, the F test is the obvious test to use.InW, the variances var(Sj2) are estimated optimally using the Rao-Blackwell theorem. This depends very strongly on the assumption of normality. If normality is in doubt, then we can estimate var(S12-S22) using results given, for example, in [6]. For a random sample, Y1,…,Yn with population and sample central moments μr and mr=∑j=1n(Yj-Y̅)r/n, r=2,3,…, [6] gives that(2.2)E[mr]=μr+O(n-1),var(m2)=(μ4-μ22)n+O(n-2).Applying [6, 10.5] to the numerator of var(m2), μ22 may be estimated to O(n-1) by m22, or, equivalently, by nm22/(n-1)=S4, where S2 is the unbiased sample variance. It follows that, to order O(n-2), var(m2) may be estimated by (m4-m22)/n. We thus propose a robust alternative to W, given by(2.3)(S12-S22)2(m14-S14)/n1+(m24-S24)/n2=R,say,in whichmi4 are the fourth central sample moments for the ith sample, i=1,2. We call the test based on R the R test. As the sample sizes increase, the distributions of the standardised sample variances approach standard normality, the denominator in R will approximate var(S12-S22), and R will have asymptotic distribution χ12. Thus, if cα is the point for which the χ12 distribution has weight α in the right hand tail, then the R test rejects H at approximately the 100α% level when R≥cα.We emphasise that although the motivation for the derivation ofR is under the assumption of sampling from normal populations, it is a valid test statistic for testing equality of variances no matter what the populations sampled.If the sample variances are equal to or asymptotically equivalent to the maximum likelihood estimators of the population variances, as is the case when sampling from normal populations, then theR test is a Wald test for equality of variances in the sense described above. Since it does not depend on any distributional assumptions about the data, it can be thought of as a nonparametric Wald test. As such, it can be expected to have good properties in large samples.We note that all the above test statistics are invariant under transformationsa(Xij-bi), for constants a, b1, and b2 and for j=1,…,ni and i=1,2.The next three sections report an empirical study when the distributions sampled are assumed to be normal. As this is an indicative study, we fix the samples sizes to be equal,n1=n2=n, say, and the significance level to be 5% throughout.


## 3. Test Size under Normality

Under the null hypothesis, the distribution ofF is known exactly, the distribution of L is known approximately, and, as mentioned above, the distribution of R is known asymptotically. In analysing data, these distributions are used to determine P values and critical values. We now investigate their use in determining test size, the probability of rejecting the null hypothesis when it is true.Two empirical assessments of test size will now be undertaken. Since the test statistics are scale invariant, it is sufficient under the null hypothesis to take both population variances to be one.In the first assessment, we assume normality. For various values of the common sample sizen, we estimate the 5% critical points for each test by generating 100,000 pairs of random samples of size n, calculating the test statistics, ordering them, and hence identifying the 0.95th percentile. The estimated critical points of R approach the χ12 5% critical point 3.841. These estimated critical points will subsequently be used in the power study to give tests with test the size of exactly 5%.To see the extent of the error caused by using the asymptotic critical point 3.841, Figure1 gives the proportion of rejections in 100,000 pairs of random samples for sample sizes up to 100. For n=10, the proportion of rejections is nearly 20% and although for n=40 this has dropped to nearly 7%, most users would hope for observed test sizes closer to 5%.Figure 1
Proportion of rejections of theR test using the χ12 5% critical point 3.841 for sample sizes up to 100.The application of the test is improved by the use a Bartlett-type correction. This was found by plotting the estimated 5% critical points againstn and using standard curve fitting techniques to find that the exact critical points were well approximated between n=10 and 100 by c(n,0.05)=3.84146(1.339-4.953/√n+24.171/n). For larger n, it is sufficient to use the asymptotic 5% value 3.84146, the error being at most 0.8%. We checked the exact probabilities of rejection under the null hypothesis when applying the test with critical value c(n,0.05), and all were between 4.6% and 5.3%.For levels other than 5%, and when sample sizes are unequal, further empirical work needs to be done to find critical values. However, as this study was intended to be indicative, we leave extensive tabulation of critical values for another time.


## 4. Power under Normality

For theF, Levene, and R tests, we estimate the power as the proportion of rejections from 100,000 pairs of random samples of size n when the first sample is from an N(0,1) population and the second is from an N(0,σ2) population with σ2≥1. To compare like with like, we use estimated critical values that give exact 5% level tests. It is apparent that for sample sizes less than about 20 the Levene test is more powerful than the R test and that for a sample size between approximately 20 and 30 the R test takes over from the Levene test; thereafter the R test is always more powerful than the Levene test. This is shown in Figure 2.Figure 2
Power of the 5% levelL test (solid line) and R test (dashed line) for various sample sizes.Both the Levene andR tests are always less powerful than the F test. This is explored in Figure 3 that compares the Levene test to the F test in the left hand panel and the R test to the F test in the right hand panel. What is given is a contour plot of the regions in which the ratios of the power of the stated test to the F test are less than 95%, between 95% and 99.99%, and greater than 99.99%. Generally, for any given n and σ2, it is clear that the power of the Levene test is at most that of the R test. For example, it appears that for n1=n2=60 approximately the power of the R test is always at least 95% of that of the F test, whereas there is a considerable region where the power of the Levene test are less than 95% of that of the F test.Contour plots of theL test (a) and R test (b) relative to the F test showing regions in which the power ratios are less than 95%, between 95% and 99.99%, and greater than 99.99%.
(a)(b)


## 5. Robustness

Even if theR test has good power, the test is of little value unless it is robust in the sense that when the distributions from which we are sampling are not from the nominated population (here, the normal distribution), the P values are reasonably accurate. It is thus of interest to estimate the proportion of rejections when the null hypothesis is true and both the populations from which we sample are not normal. We have looked at variable kurtosis and skewness. First, variable kurtosis was considered via t-distributions with varying degrees of freedomν, say. Second, variable skewness was considered through gamma distributions with probability density functions bc-1exp(-x)/Γ(c) for x>0. Thus, the scale parameter is set at one and the scale parameter c was varied. As νand c increase, the distributions become increasingly more normal, the distribution sampled will be close enough to normal that we could expect the proportion of rejections to be close to the nominal.In Figure4, we plot the proportion of rejections for the Levene, F, and R tests when sampling from tν distributions, for ν=1,…,20, and from gamma distributions with scale parameter 1 and shape parameter c, for c=0.1,…,30. We show curves for each test with common sample sizes n=10 and 20. The critical values used for the R test are the c(n,0.05) from Section 3; the critical values used for the Levene test are those estimated by simulation to give exactly the nominal level when normality holds. Thus, this comparison favours the Levene test.Test sizes for theF (dots), L (dashes), and R (solid line) tests for sample sizes of 10 and 20 for (a), (b) t-distributions with varying degrees of freedom, ν, from 1 to 20, and (c), (d) gamma distributions with scale parameter 1 and varying shape parameter, c, from 0.1 to 30.
(a)(b)(c)(d)For these distributions, samples are increasingly nonnormal asν and c decrease. It is apparent that the F test performs increasingly poorly as these parameters decrease.When sampling from thet-distribution, the Levene test generally has exact level closer to the nominal level than the R test except for very nonnormal samples (small ν). However, the level of the R test is almost always reasonable, and while for very small ν, the level is not as close to the exact level as perhaps we may prefer, the same is the case for the Levene test.When sampling from the gamma distribution whenn=10, the R test outperforms the Levene test at small values of c and is slightly inferior for larger values of c, although both tests have exact test sizes acceptably close to the nominal test size. When n=20, the R test is uniformly closer to the nominal test size than the Levene test. Although we only display results for n=10 and n=20, sample sizes of more than 20 yield very similar conclusions.


## 6. Conclusion

First, we reflect on testing for equality of variances when it is assumed that the populations sampled are normal. TheF test is both the likelihood ratio test and a Wald test, and is the appropriate test to apply. When normality does not hold, the F test is no longer an asymptotically optimal test, and its well-known nonrobustness means that tests such as the Levene are more appropriate for small to moderate sample sizes. However, for sample sizes of about 25 or more, the R test is more powerful than the Levene, and with the small sample corrected critical values, it holds its nominal significance level well. For these sample sizes, it can be preferred to the Levene test.Second, consider testing for equality of variances when both samples are drawn from the same population. If that population is nominated, then theR test may be applied after determining critical values or using P values calculated by Monte Carlo methods. When the sample variances are asymptotically equivalent to the maximum likelihood estimators of the population variances (as, e.g., is the case when sampling from normal populations but not Poisson populations), the R test is a nonparametric Wald test and hence will have good power in sufficiently large samples. If the population is not specified, the R test can be confidently applied when the sample sizes are large, using the asymptotic χ12 null distribution to calculate P values or critical values.



---

*Source: 748580-2012-01-05.xml*