7.6 - Tests for Constant Error Variance

7.6 - Tests for Constant Error Variance

There are various tests that may be performed on the residuals for testing if the regression errors have constant variance. It is usually sufficient to "visually" interpret a residuals versus fitted values plot. However, the tests we discuss can provide an added layer of justification to your analysis. Note that some of the following procedures require you to partition the residuals into a certain number of groups, say $$g\geq 2$$ groups of sizes $$n_{1},\ldots,n_{g}$$ such that $$\sum_{i=1}^{g}n_{i}=n$$. For these procedures, the sample variance of group i is given by:

$$\begin{equation*} s_{i}^{2}=\dfrac{\sum_{j=1}^{n_{i}}(e_{i,j}-\bar{e}_{i,\cdot})^{2}}{n_{i}-1} \end{equation*}$$

where $$e_{i,j}$$ is the $$j^{\textrm{th}}$$ residual from group i. Moreover, the pooled variance is given by:

$$\begin{equation*} s_{p}^{2}=\dfrac{\sum_{i=1}^{g}(n_{i}-1)s_{i}^{2}}{n-g} \end{equation*}$$

F-Test

Suppose we partition the residuals of observations into two groups - one consisting of residuals associated with the lowest predictor values and the other consisting of those belonging to the highest predictor values. Treating these two groups as if they could (potentially) represent two different populations, we can test

\begin{align*} \nonumber H_{0}&\colon \sigma_{1}^{2}=\sigma_{2}^{2} \\ \nonumber H_{A}&\colon \sigma_{1}^{2}\neq\sigma_{2}^{2} \end{align*}

using the F-statistic $$F^{*}=s_{1}^{2}/s_{2}^{2}$$. This test statistic is distributed according to a $$F_{n_{1}-1,n_{2}-1}$$ distribution, so if $$F^{*}\geq F_{n_{1}-1,n_{2}-1;1-\alpha}$$, then reject the null hypothesis and conclude that there is statistically significant evidence that the variance is not constant.

Modified Levene Test

Another test for nonconstant variance is the modified Levene test (sometimes called the Brown-Forsythe test). This test does not require the error terms to be drawn from a normal distribution and hence it is a nonparametric test. The test is constructed by grouping the residuals into g groups according to the values of the quantity on the horizontal axis of the residual plot. It is typically recommended that each group has at least 25 observations and usually g=2 groups are used.

Begin by letting group 1 consist of the residuals associated with the $$n_{1}$$ lowest values of the predictor. Then, let group 2 consists of the residuals associated with the $$n_{2}$$ highest values of the predictor (so $$n_{1}+n_{2}=n$$). The objective is to perform the following hypothesis test:

\begin{align*} \nonumber H_{0}&\colon \textrm{the variance is constant} \\ \nonumber H_{A}&\colon \textrm{the variance is not constant} \end{align*}

As with the normality tests considered in the previous section, we hope we fail to reject the null hypothesis as this would mean the variance is constant. The test statistic for the above is computed as follows:

• $$d_{i,j}=|e_{i,j}-\tilde{e}_{i,\cdot}|$$, where $$\tilde{e}_{i,\cdot}$$ is the median of the $$i^{\textrm{th}}$$ group of residuals
• $$s_{L}=\sqrt{\dfrac{\sum_{j=1}^{n_{1}}(d_{1,j}-\bar{d}_{1})^{2}+\sum_{j=1}^{n_{2}}(d_{2,j}-\bar{d}_{2})^{2}}{n_{1}+n_{2}-2}}$$
• $$L=\dfrac{\bar{d}_{1}-\bar{d}_{2}}{s_{L}\sqrt{\frac{1}{n_{1}}+\frac{1}{n_{2}}}}$$

L is approximately distributed according to a $$t_{n_{1}+n_{2}-2}$$ distribution, or (equivalently) $$L^2$$ is approximately distributed according to an $$F_{1,n_{1}+n_{2}-2}$$ distribution.

To illustrate consider the Toluca Company dataset described on page 19 of Applied Linear Regression Models (4th ed) by Kutner, Nachtsheim, and Neter. We fit a simple linear regression model with predictor variable LotSize (the number of refrigerator parts in a production run) and response variable WorkHours (labor hours required to produce the lot of refrigerator parts). A modified levene test applied with the 13 smallest lot sizes in the first group and the remaining 12 lot sizes in the second group results in the following:

• $$\tilde{e}_1=-19.87596$$ and $$\tilde{e}_2=-2.68404$$
• $$\bar{d}_1=44.81507$$ and $$\bar{d}_2=28.45034$$
• $$\sum{(d_1-\bar{d}_1)^2}=12566.61$$ and $$\sum{(d_2-\bar{d}_2)^2}=9610.287$$
• $$s_L = \sqrt{(12566.61+9610.287)/23} = 31.05178$$
• $$L = (44.81507-28.40534)/(31.05178\sqrt{(1/13+1/12)}) = 1.31648$$ and $$L^2=1.7331$$
• The $$t_{23}$$ probability area to the left of 1.31648 is 0.8995, which means the p-value for the test is $$2(1-0.8995) = 0.201$$, i.e., there is no evidence the errors have nonconstant variance.

Breusch-Pagan Test

The Breusch-Pagan test (also known as the Cook-Weisberg score test) is an alternative to the modified Levene test. Whereas the modified Levene test is a nonparametric test, the Breusch-Pagan test assumes that the error terms are normally distributed, with $$\mbox{E}(\epsilon_{i})=0$$ and $$\mbox{Var}(\epsilon_{i})=\sigma^{2}_{i}$$ (i.e., nonconstant variance). The $$\sigma_{i}^{2}$$ values depend on the horizontal axis quantity ($$X_{i}$$) values in the following way:

$$\begin{equation*} \log\sigma_{i}^{2}=\gamma_{0}+\gamma_{1}X_{i} \end{equation*}$$

We are interested in testing the null hypothesis of constant variance versus the alternative hypothesis of nonconstant variance. Specifically, the hypothesis test is formulated as:

\begin{align*} \nonumber H_{0}&\colon \gamma_{1}=0 \\ \nonumber H_{A}&\colon \gamma_{1}\neq 0 \end{align*}

This test is carried out by first regressing the squared residuals on the predictor (i.e., regressing $$e_{i}^2$$ on $$X_{i}$$). The sum of squares resulting from this analysis is denoted by $$\textrm{SSR}^{*}$$, which provides a measure of the dependency of the error term on the predictor. The test statistic is given by:

$$\begin{equation*} X^{2*}=\dfrac{\textrm{SSR}^{*}/2}{(\textrm{SSE}/n)^{2}} \end{equation*}$$

where SSE is from the regression analysis of the response on the predictor. The p-value for this test is found using a $$\chi^{2}$$ distribution with 1 degree of freedom (written as $$\chi^{2}_{1}$$).

To illustrate consider the Toluca Company example from above:

• $$SSE=54825$$
• $$SSR^*=7896142$$
• $$X^{2*} = (7896142/2) / (54825/25)^2 = 0.8209$$
• The $$\chi^{2}_{1}$$ probability area to the left of 0.8209 is 0.635, which means the p-value for the test is $$1-0.635 = 0.365$$, i.e., there is no evidence the errors have nonconstant variance.

When the variance is a function of q > 1 predictors, SSR* derives from a multiple regression of the squared residuals against these predictors, and there are q degrees of freedom for the $$\chi^{2}$$ distribution.

Bartlett's Test

Bartlett's test is another test that can be used to test for a constant variance. The objective is to again perform the following hypothesis test:

\begin{align*}\nonumber H_{0}\colon \textrm{the variance is constant} \\ \nonumber H_{A}\colon \textrm{the variance is not constant}\end{align*}

Bartlett's test is highly sensitive to the normality assumption, so if the residuals do not appear normal (even after transformations), then this test should not be used. Instead, the Levene test is the alternative to Bartlett's test that is less sensitive to departures from normality.

This test is carried out similarly to the Levene test. Once you have partitioned the residuals into g groups, the following test statistic can be constructed:

$$\begin{equation*} B=\dfrac{(n-g)\ln s_{p}^{2}-\sum_{i=1}^{g}(n_{i}-1)\ln s_{i}^{2}}{1+\biggl(\dfrac{1}{3(g-1)}\biggl((\sum_{i=1}^{g}\dfrac{1}{n_{i}-1})-\dfrac{1}{n-g}\biggr)\biggr)} \end{equation*}$$

The test statistic B is distributed according to a $$\chi^{2}_{g-1}$$ distribution, so if $$B\geq \chi^{2}_{g-1;1-\alpha}$$, then reject the null hypothesis and conclude that there is statistically significant evidence that the variance is not constant.

 [1] Link ↥ Has Tooltip/Popover Toggleable Visibility