<p><strong>General remarks:</strong> The BG test under homoskedasticity can be done using the <code>bgtest</code> command in the <code>lmtest</code> package of R. The $(n-p)R_{aux}^2$ version mentioned in link works only under homoskedasticity. In the presence of heteroskedasticity, <a href="http://www.sciencedirect.com/science/article/pii/030440769190076P" rel="nofollow noreferrer">Wooldridge (1991, JoE)</a> gives a discussion (as noted in the Wooldridge textbook you mentioned).</p>

<p><strong>What I think:</strong> 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):</p>

<pre><code>DF &lt;- data.frame(y=rnorm(100), x1=rnorm(100), x2=rnorm(100))
ols &lt;- lm(y~x1+x2, data=DF)
DF$e &lt;- ols$resid
DF$e1 &lt;- c(NA,DF$e[-100])    # are there better ways to lag a variable?
DF$e2 &lt;- c(NA,DF$e1[-100])
aux &lt;- lm(e~e1+e2+x1+x2, data=DF)
library(car)
lht(aux, c('e1','e2'), white.adjust='hc3')
</code></pre>

<p><strong>Discussions:</strong> That said, there is the <a href="https://www.jstor.org/stable/2648877" rel="nofollow noreferrer">generated regressor problem</a> in the <code>aux</code> regression above, that is, the some of RHS variables (<code>e1</code> and <code>e2</code>) 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.</p>

<p><strong>Further discussions:</strong> The BG test is an LM test, while <code>lht</code> does a Wald test. The difference should be minor.</p>

<p><strong>Simulation results:</strong> I did simulations. The ordinary BG test seems to fail. The robustified version seems working.</p>

<pre><code>library(car)
iterate &lt;- 1000
n &lt;- 400

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

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

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

  ols &lt;- lm(y~x1+x2+y1)

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

print(colMeans(ans))
##   ord   rob
## 0.090 0.046
</code></pre>

<p>Note: I edited the simulation a lot. I hope this one is OK.</p>

CC BY-SA 3.0
2018-01-20T10:51:04.290Z
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?
shenflow
CC BY-SA 3.0
2018-01-20T10:59:14.080Z
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.
chan1142
CC BY-SA 3.0
2018-01-20T11:19:40.337Z
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
shenflow
CC BY-SA 3.0
2018-01-20T11:25:21.933Z
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).
chan1142
CC BY-SA 3.0
2018-01-20T11:31:31.400Z
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.
chan1142
CC BY-SA 3.0
2018-01-20T14:02:57.273Z
Okay, I understand. Thank you. I did not find any information concerning issues with Newey-West in the presence of lagged dependent variables yet. Are there actually any?
shenflow
CC BY-SA 3.0
2018-01-20T14:05:11.597Z
Also I have just noticed a flaw in my approach - the presence of autocorrelation biases any test for heteroscedasticity. So testing for heteroscedasticity first does not make sense. One should rather test for serial correlation by applying a robust method (like you proposed), then correct for it and then test for heteroscedasticity. Yet, I am of the opinion that one could also stop after testing for serial correlation and then use Newey-West Estimators. (You could call this a "safe" method I guess?)
shenflow
CC BY-SA 3.0
2018-01-20T14:08:00.200Z
The fact that non-robust methods for testing for serial correlation are so common is actually a sign that this logical flaw is actually quite common. To my current knowledge, in a time series context one should *always* use a robust method for testing for serial correlation (since there is no possibility of knowing wether heteroscedasticity is present or not and you can only test for heteroscedasticity if there is no serial correlation).
shenflow
CC BY-SA 3.0
2018-01-20T14:12:58.663Z
It suddenly came up to my mind that y(t-1) and serial correlation in u(t) cannot exist together because then the slope parameters are not identified (due to correlation of regressor and error). So it's not very meaningful to apply NW in that case because the coefficient estimator is inconsistent. In the presence of serial correlation in the error term (and y(t-1) on the RHS), it would be better to increase the lag order until you are happy. I would not use OLS+NW when the (robust) BG test is rejected.
chan1142
CC BY-SA 3.0
2018-01-20T14:18:21.380Z
Regarding your remarks on the robust testing, I agree with you, shenflow, and I am impressed by you. To proceed from that point, perhaps you would want to think about what we can do and what we can't. With only time series (not panel), it is not easy to handle general heteroskedasticity, so (I think) the literature has developed toward conditional heteroskedasticity (like GARCH) which provides parametric models for heteroskedasticity. E.g., instead of saying that u(t) is Het, they _model_ it as u(t) = y(t-1)*e(t).
chan1142
CC BY-SA 3.0
2018-01-21T15:06:39.247Z
Thank you for your comments. Regarding your comment on autocorrelation and the correlation of the regressor and the error term - you are right *if* we assume that the error term follows a specific autoregressive process. But autoregressive does not equal autocorrelation. So I would say that the general statement you are making is wrong. Although it definetly is a point to consider. Practically one can still have autocorrelated errors in an AR model and use NW estimators, *if he assumes the errors do not follow an autoregressive process*.
shenflow
CC BY-SA 3.0
2018-01-21T15:10:40.080Z
Regarding your comment on GARCH models - thank you! I am currently working on a regression model for time series and I am just starting to learn all about it (I only had basic statistics lectures at university) and I came accross GARCH models. Yet, I probably wont implement such a method at the moment, simply because it would be a bit *too much* for the things I am aiming to pursue. In addition, it is actually quite interesting to go all the way from doing a simple regression model to modelling ARDL models and such. I feel like its a good way to learn about the deficits and so on.
shenflow
CC BY-SA 3.0
2018-01-21T15:14:17.510Z
Well, what I mean is the model y(t) = alpha + beta*y(t-1) + u(t), where u(t) is autocorrelated. If u(t) is autocorrelated, then y(t-1) is likely correlated with u(t) and you have endogeneity. In very special cases (e.g., where there is no y(t-1) and u(t) is AR(1)), you can rewrite the model as an AR model with serially uncorrelated errors, but that's not what econometricians usually pursue. So you would want to be rather careful when you say "the __general__ statement you are making is wrong."
chan1142
CC BY-SA 3.0
2018-01-21T15:16:51.177Z
Please let me know if you see any examples in which y(t-1) is on the RHS and NW is used. That would be interesting.
chan1142
CC BY-SA 3.0
2018-01-21T15:21:41.387Z
Econometrics by Wooldridge (2013) pp. 401. He shows that a model y(t) = alpha + beta*y(t-1) + u(t) is still consistent if one can assume the error does not follow an autoregressive process. If you do not have the book at hand: http://fmwww.bc.edu/ec-c/f2010/228/EC228.f2010.nn12.pdf those are lecture notes which directly refer to the book I am mentioning. Slide 5,... discusses the topic.
shenflow
CC BY-SA 3.0
2018-01-21T15:23:24.217Z
So when you (can) assume the errors do not follow an autoregressive process - what should prohibit you from using NW estimators for "tackling" the issue of autocorrelation in the error term?
shenflow
CC BY-SA 3.0
2018-01-21T15:28:47.903Z
First, thanks for the link. The assumption that $E(u_{t} | y_{t-1})=0$ does the trick. Yes, it is possible that $u_t$ is serially correlated but the above zero mean is true, but I would say it is rather a special case, and I believe many will agree with me. The cases (or time series models) where $u_t$ is serially correlated and satisfy the zero mean assumption would be very interesting. Please let me know if you know a real example.
chan1142
CC BY-SA 3.0
2018-01-21T15:35:25.800Z
If $E(u_t | y_{t-1})=0$ and $u_t$ is serially correlated, then (I haven't thought much but) I think you are right and can use NW. (Let me emphasize that I haven't thought enough about this.)
chan1142
CC BY-SA 3.0
2018-01-21T15:43:31.680Z
I agree with you, I also do not know a real example though.
shenflow
CC BY-SA 3.0
2018-01-20T07:46:08.043Z
2018-01-20T09:24:05.853Z
2018-01-20T09:24:05.853Z
chan1142
<p>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 (<em>asymptotic Gauß Markov assumptions</em>) are fulfilled.</p>

<p>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 <em>Wooldridge</em> I decided to apply the Breusch-Godfrey test. <strong>But</strong> the residuals are heteroscedastic, which I tested for via applying the Bresuch-Pagan test. </p>

<p><em>Wooldridge</em> 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.</p>

<p>EDIT: I have found a quite interesting paper that proposes a method of dealing with the topic: The <strong>modified Breusch-Godfrey test</strong>. Link: <a href="http://www.naun.org/main/NAUN/mcs/17-542.pdf" rel="nofollow noreferrer">http://www.naun.org/main/NAUN/mcs/17-542.pdf</a>. </p>

<p>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 <strong>has to</strong> to be a method, because the problem I am having strikes me as a rather common one.) Thank you!</p>

<econometrics><time-series><regression><r>
Regression - Testing for autocorrelation in the presence of heteroscedasticity
shenflow
# Regression - Testing for autocorrelation in the presence of heteroscedasticity

(Asked by: username_0 on 2018-01-19)

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!

**Tags:** econometrics, time-series, regression, r


---

## 1 answers

### Answer by username_1 on 2018-01-20. Score: 2 | Accepted answer

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)
lht(aux, c('e1','e2'), white.adjust='hc3')

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.

> **Comments:**
> **username_0**: 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?  
> **username_1**: 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.  
> **username_0**: 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  
> **username_1**: 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).  
> **username_1**: 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.  
> **username_0**: Okay, I understand. Thank you. I did not find any information concerning issues with Newey-West in the presence of lagged dependent variables yet. Are there actually any?  
> **username_0**: Also I have just noticed a flaw in my approach - the presence of autocorrelation biases any test for heteroscedasticity. So testing for heteroscedasticity first does not make sense. One should rather test for serial correlation by applying a robust method (like you proposed), then correct for it and then test for heteroscedasticity. Yet, I am of the opinion that one could also stop after testing for serial correlation and then use Newey-West Estimators. (You could call this a "safe" method I guess?)  
> **username_0**: The fact that non-robust methods for testing for serial correlation are so common is actually a sign that this logical flaw is actually quite common. To my current knowledge, in a time series context one should *always* use a robust method for testing for serial correlation (since there is no possibility of knowing wether heteroscedasticity is present or not and you can only test for heteroscedasticity if there is no serial correlation).  
> **username_1**: It suddenly came up to my mind that y(t-1) and serial correlation in u(t) cannot exist together because then the slope parameters are not identified (due to correlation of regressor and error). So it's not very meaningful to apply NW in that case because the coefficient estimator is inconsistent. In the presence of serial correlation in the error term (and y(t-1) on the RHS), it would be better to increase the lag order until you are happy. I would not use OLS+NW when the (robust) BG test is rejected.  
> **username_1**: Regarding your remarks on the robust testing, I agree with you, username_0, and I am impressed by you. To proceed from that point, perhaps you would want to think about what we can do and what we can't. With only time series (not panel), it is not easy to handle general heteroskedasticity, so (I think) the literature has developed toward conditional heteroskedasticity (like GARCH) which provides parametric models for heteroskedasticity. E.g., instead of saying that u(t) is Het, they _model_ it as u(t) = y(t-1)*e(t).  
> **username_0**: Thank you for your comments. Regarding your comment on autocorrelation and the correlation of the regressor and the error term - you are right *if* we assume that the error term follows a specific autoregressive process. But autoregressive does not equal autocorrelation. So I would say that the general statement you are making is wrong. Although it definetly is a point to consider. Practically one can still have autocorrelated errors in an AR model and use NW estimators, *if he assumes the errors do not follow an autoregressive process*.  
> **username_0**: Regarding your comment on GARCH models - thank you! I am currently working on a regression model for time series and I am just starting to learn all about it (I only had basic statistics lectures at university) and I came accross GARCH models. Yet, I probably wont implement such a method at the moment, simply because it would be a bit *too much* for the things I am aiming to pursue. In addition, it is actually quite interesting to go all the way from doing a simple regression model to modelling ARDL models and such. I feel like its a good way to learn about the deficits and so on.  
> **username_1**: Well, what I mean is the model y(t) = alpha + beta*y(t-1) + u(t), where u(t) is autocorrelated. If u(t) is autocorrelated, then y(t-1) is likely correlated with u(t) and you have endogeneity. In very special cases (e.g., where there is no y(t-1) and u(t) is AR(1)), you can rewrite the model as an AR model with serially uncorrelated errors, but that's not what econometricians usually pursue. So you would want to be rather careful when you say "the __general__ statement you are making is wrong."  
> **username_1**: Please let me know if you see any examples in which y(t-1) is on the RHS and NW is used. That would be interesting.  
> **username_0**: Econometrics by Wooldridge (2013) pp. 401. He shows that a model y(t) = alpha + beta*y(t-1) + u(t) is still consistent if one can assume the error does not follow an autoregressive process. If you do not have the book at hand: http://fmwww.bc.edu/ec-c/f2010/228/EC228.f2010.nn12.pdf those are lecture notes which directly refer to the book I am mentioning. Slide 5,... discusses the topic.  
> **username_0**: So when you (can) assume the errors do not follow an autoregressive process - what should prohibit you from using NW estimators for "tackling" the issue of autocorrelation in the error term?  
> **username_1**: First, thanks for the link. The assumption that $E(u_{t} | y_{t-1})=0$ does the trick. Yes, it is possible that $u_t$ is serially correlated but the above zero mean is true, but I would say it is rather a special case, and I believe many will agree with me. The cases (or time series models) where $u_t$ is serially correlated and satisfy the zero mean assumption would be very interesting. Please let me know if you know a real example.  
> **username_1**: If $E(u_t | y_{t-1})=0$ and $u_t$ is serially correlated, then (I haven't thought much but) I think you are right and can use NW. (Let me emphasize that I haven't thought enough about this.)  
> **username_0**: I agree with you, I also do not know a real example though.  

---

