# Regression - Testing for autocorrelation in the presence of heteroscedasticity

I have constructed a linear time series regression model and estimated the parameters by applying OLS. I now want to test wether the assumptions for proper large sample inference (asymptotic Gauß Markov assumptions) are fulfilled.

Now, I am not sure how to test wether the residuals are autocorrelated or not. Since my model contains lagged dependent variables I can not use the Durbin-Watson test (since my independent variables are not strictly exogenous). Following Wooldridge I decided to apply the Breusch-Godfrey test. But the residuals are heteroscedastic, which I tested for via applying the Bresuch-Pagan test.

Wooldridge says that in the case of heteroscedasticity, one can not apply the usual Breusch-Godfrey test. How can I test for autocorrelation in the presence of heteroscedasticity? Is there any robust method? If that is of any interest - I am using R, so it would be helpful if there would be an implementation of the method (if there is one) in R.

EDIT: I have found a quite interesting paper that proposes a method of dealing with the topic: The modified Breusch-Godfrey test. Link: http://www.naun.org/main/NAUN/mcs/17-542.pdf.

Yet, I did not find any practical implementations of this test. As I am (just) an undergrad student, my possibilities regarding implementing such methods on my own are rather limited. So I am still looking for a general approach/test or method. (And I assume there has to to be a method, because the problem I am having strikes me as a rather common one.) Thank you!

General remarks: The BG test under homoskedasticity can be done using the bgtest command in the lmtest package of R. The $(n-p)R_{aux}^2$ version mentioned in link works only under homoskedasticity. In the presence of heteroskedasticity, Wooldridge (1991, JoE) gives a discussion (as noted in the Wooldridge textbook you mentioned).

What I think: I guess that what Wooldridge does is to use a heteroskedasticity-robust variance estimator. For this, (i) get the OLS residuals, (ii) regress e(t) on e(t-1), ..., e(t-p) and X, and test the joint significance of e(t-1), ..., e(t-p) using a heteroskedasticity-robust covariance estimate. If you want to use R, do the following for AR(2):

DF <- data.frame(y=rnorm(100), x1=rnorm(100), x2=rnorm(100))
ols <- lm(y~x1+x2, data=DF)
DF$e <- ols$resid
DF$e1 <- c(NA,DF$e[-100])    # are there better ways to lag a variable?
DF$e2 <- c(NA,DF$e1[-100])
aux <- lm(e~e1+e2+x1+x2, data=DF)
library(car)


Discussions: That said, there is the generated regressor problem in the aux regression above, that is, the some of RHS variables (e1 and e2) are generated using the OLS regression results. This usually causes trouble. However some tests can be done even if the regressors are generated. I guess this is one, but I haven't checked it formally.

Further discussions: The BG test is an LM test, while lht does a Wald test. The difference should be minor.

Simulation results: I did simulations. The ordinary BG test seems to fail. The robustified version seems working.

library(car)
iterate <- 1000
n <- 400

ans <- data.frame(ord=rep(NA,iterate), rob=rep(NA,iterate))
set.seed(1)
for (iter in seq_len(iterate)) {
x1 <- rnorm(n+1)
x2 <- rnorm(n+1)
u0 <- rnorm(n+1)
u0[1:floor(n/2)] <- 2*u0[1:floor(n/2)]
u <- sqrt(1+abs(x1+x2))*u0

## y(t) = 1+x1(t)+x2(t)+0.5*y(t-1)+u(t)
y <- filter(1+x1+x2+u, 0.5, method='recursive')

y1 <- y[-(n+1)]      # y(1), ..., y(n)
y <- y[-1]           # y(2), ..., y(n+1)
x1 <- x1[-1]         # x1(2), ..., x1(n+1)
x2 <- x2[-1]         # x2(2), ..., x2(n+1)

ols <- lm(y~x1+x2+y1)

e <- ols$resid e1 <- c(NA,e[-n]) # NA, e(1), ..., e(n-1) e2 <- c(NA,e1[-n]) # NA, NA, e(1), ..., e(n-2) aux <- lm(e~e1+e2+x1+x2+y1) tst0 <- lht(aux, c('e1','e2'), white.adjust=FALSE) ans$ord[iter] <- as.numeric(tst0$Pr(>F)[2] < 0.05) tst1 <- lht(aux, c('e1','e2'), white.adjust=TRUE) ans$rob[iter] <- as.numeric(tst1\$Pr(>F)[2] < 0.05)
}

print(colMeans(ans))
##   ord   rob
## 0.090 0.046


Note: I edited the simulation a lot. I hope this one is OK.

• Thank you for your detailed answer. I understand the concept you are proposing. What I do not understand yet is the specific problem you are aiming to tackle with the approach: I understand that a Wald-Test statistic is affected by the covariance matrix since the test statistic includes the variance of the estimated parameter. What I do not understand is how a LM based test statistic (for example the Breusch Godfrey test) is affected by it since it relies on Rsquared and n (both do not include the variance of the estimators). Am I missing something? Jan 20, 2018 at 10:51
• As Wald based on the ordinary covariance is not approximately chi-square (or F), so LM (n times Rsq) is not approximately chi-square if the Rsq is obtained from aux. A robust LM can be constructed as "n*Rsq" but the Rsq should be from a a different regression in order for it to be approximately chisquare. Wooldridge's 1991 paper discusses it. Jan 20, 2018 at 10:59
• I do not quite get your answer. Maybe let me reformulate the issue I am having: How does the presence of heteroscedastic residuals affect the LM-test statistic (the Breusch-Godfrey test)? However, I will try to work my way through the paper you are proposing in your answer. Also - simply looking at the autocorrelation function plot of the residuals should also give me an answer to wether the residuals are autocorrelated or not, right? Since I am thinking about using Newey-West Estimators as a solution to autocorrelation and heteroscedasticity, I just need to see if there is any autocorrelation Jan 20, 2018 at 11:19
• To answer your question, try to prove how n times Rsq (from the aux regression) is approximately chi-square. The proof relies on the homoskedasticity assumption. The BG test statistic is the BG test statistic regardless of the presence of Het. The statistic is not affected. It is its distribution that is affected by Het. The BG test stat is calculated all the same. The problem is that tests based on the BG stat is invalid (its size not equal to the significance level). Also, check if Newey-West works with y(t-1). Jan 20, 2018 at 11:25
• The BG test is not approximately chisquare under Het, so you need to modify it, i.e., you need to use a different test statistic. You can formulate one as n times Rsq, but in oder for the result to be approx chi-square, you need to use a particular regression, not of e(t) on e(t-1), ..., e(t-p) and X. The new one, you can still call an LM test, but it is certainly not the original BG test. Jan 20, 2018 at 11:31