<ol>
<li>Including time as independent variable would correct for <em>deterministic</em> time trend but that would most likely not affect autocorrelation.</li>
<li>Usually the best way how to solve autocorrelation is to explicitly model dynamics by including lagged variables as independent regressors. You can try doing that.</li>
<li>Using Newey-west errors is valid way of correcting for autocorrelation (unless you have model with lagged dependent variable). There is nothing incorrect about using non-standard errors as long as there are no other issues that might affect this. As to whether your teacher would appreciate to use it or not you have to ask him/her.</li>
</ol>

CC BY-SA 4.0
2022-11-07T16:13:52.093Z
Thanks so much for the answer. About your second point,  do i include lagged variables of the independent variables or of the dependent variable? Or both?
viktor nikiforov
CC BY-SA 4.0
2022-11-07T16:36:37.070Z
@viktornikiforov depends on what you believe the dynamic structure of the model is. You can do either of those or both
1muflon1
CC BY-SA 4.0
2022-11-07T16:49:51.283Z
sorry exactly what do you mean by the dynamic structure of a model? :'((
viktor nikiforov
CC BY-SA 4.0
2022-11-07T17:32:53.300Z
@viktornikiforov how the lag structure of the true model which you want to estimate looks like
1muflon1
CC BY-SA 4.0
2022-11-10T18:20:39.113Z
*Using Newey-west errors is valid way of correcting for autocorrelation (unless you have model with lagged dependent variable)*: could you elaborate a bit?
Richard Hardy
CC BY-SA 4.0
2022-11-10T18:28:14.387Z
@RichardHardy according to Verbeek in that case coefficients will be biased unless you get the dynamic structure right. As far as I understand that is why correct lag structure in tests such as ADF which rely on some auxiliary regression modeled as AR/ARDL  process is so important
1muflon1
CC BY-SA 4.0
2022-11-10T18:32:58.687Z
Do you remember where in Verbeek this is discussed? Wouldn't the coefficient on the lagged dependent variable be biased no matter what? I think all standard estimators (whether versions of OLS or MLE) of the slope coef. of a simple, correctly specified AR(1) model are biased. I doubt extending that with some exogenous regressors would help fix that.
Richard Hardy
CC BY-SA 4.0
2022-11-10T18:43:48.487Z
@RichardHardy I remember it was in his handbook, I think it was actually in a section about ARDL so I think that it is a general property of OLS.
1muflon1
CC BY-SA 4.0
2022-11-10T18:43:59.920Z
I guess a bigger problem might be lack of consistency of the OLS estimator in a model with lagged dep. var. and autocorrelated errors, as described in Verbeek "A Guide to Modern Econometrics" (5th edition, 2017) section 5.2 "Cases Where the OLS Estimator Cannot Be Saved" (p. 143-144). What handbook do you have in mind?
Richard Hardy
CC BY-SA 4.0
2022-11-11T00:22:36.530Z
@RichardHardy maybe I misremembered it and it was only consistency (although I still think there was some discussion about in in chapter with ARDL), but still the whole point of NW is to save consistency since regular autocorrelation also does not affect bias.
1muflon1
CC BY-SA 4.0
2022-11-11T06:20:43.637Z
NW adjusts standard errors but leaves point estimates intact. So when you say the point of NW is to save consistency, it could not mean consistency of point estimates. Do you perhaps mean consistency of standard errors? And again, I would love to check out the source, but I could not find the handbook you are mentioning. Could you please give a more concrete reference?
Richard Hardy
CC BY-SA 4.0
2022-11-11T09:20:05.553Z
@RichardHardy I am not at home this week so I cannot double check the book so I am going just by my memory
1muflon1
CC BY-SA 4.0
2022-11-11T10:00:27.177Z
Thanks. If I remember, I may ask you about this later then.
Richard Hardy
CC BY-SA 4.0
2022-11-07T16:08:28.730Z
2022-11-07T16:08:28.730Z
1muflon1
<blockquote>
<p>I've heard that a crucial problem for autocorrelation is not including an independent variable. Till now I was not including the 'year' as a variable in my regression. Would that help?</p>
</blockquote>
<p>Yes it could help. Omitting a trend as explanatory variable usually generates autocorrelation. If the true DGP is:
<span class="math-container">$$ y_t = \beta_0 + \beta_1 t + e_t, $$</span>
with <span class="math-container">$E[e_t|t]=0, V[e_t|t]=\sigma^2, Cov[e_t,e_s|t,s]=0$</span>, for <span class="math-container">$s \neq t,$</span>
but if we omit <span class="math-container">$t$</span> and consider the misspecified model
<span class="math-container">$$ y_t = \beta_0 + u_t, $$</span>
then we have <span class="math-container">$Cov(u_t,u_{t-1})=\beta_1^2 V(t)$</span> (exercise).<br />
Moreover, as discussed below @1mouflon1's answer, the OLS estimate <span class="math-container">$\hat{\beta}_0$</span> is not consistent for <span class="math-container">$\beta_0$</span> in this case (with an omitted variable bias).<br />
These properties are illustrated by the R-code below.</p>
<pre><code>library( data.table )
T = 100

# DGP
t = seq(1:T)
e = rnorm(T)
beta_0 = 2
beta_1 = 1/2
y = beta_0 + beta_1*t + e
Dat = data.table( y, t, e  )
reg  = lm( y ~ 1 , data=Dat )
summary( reg ) # Illustrates that OLS is not consistent for beta_0

# Residuals
Dat_e = data.table( e_hat = reg<span class="math-container">$residuals ) 
Dat_e$</span>e_hat_1 = shift( Dat_e$e_hat, type=&quot;lag&quot; ) 

autocor_e  = lm( e_hat ~ e_hat_1, data=Dat_e )
summary( autocor_e ) # illustrates that residuals are AR1

# True error terms
u =  beta_1*t + e
Dat_u = data.table( u ) 
Dat_u<span class="math-container">$u_1 = shift( Dat_u$</span>u, type=&quot;lag&quot; ) 
# Check whether the theoretical result is (approximately) satisfied
cov( Dat_u<span class="math-container">$u, Dat_u$</span>u_1, use=&quot;complete.obs&quot; )
(beta_1)^2 * var( Dat$t )

autocor_u  = lm( u ~ u_1, data=Dat_u )
summary( autocor_u )
</code></pre>

CC BY-SA 4.0
2022-11-12T20:35:17.647Z
2022-11-12T20:35:17.647Z
Bertrand
<p>I'm working on an econometrics project for which I'm trying to study the impact of factors such as p.c. GDP growth, exports, inflation and interest rate on the debt-to-GDP ratio of a country, for 4 countries over a period of 20 years. I am using an LSDV model for this. And I have run into the problem of autocorrelation. I tried to correct for it using the method of subtracting p times the lagged variables for every observation, but even after this, after plotting the residual against its lag, I still see autocorrelation. How do I fix this?</p>
<p>I've heard that a crucial problem for autocorrelation is not including an independent variable. Till now I was not including the 'year' as a variable in my regression. Would that help? Also, is there any way I could deseasonalize the data or something similar? Please help as I'm not sure how to correct this.</p>
<p>I've heard of a Newey-West or something function in R that gives AC corrected errors? But I feel like our teacher wouldn't appreciate if I just did that without actually correctly the problem? I'd be grateful for any help. Thank you!!</p>

<econometrics><time-series><paneldata><autocorrelation>
Include 'year' as an independent variable to deal with autocorrelation?
viktor nikiforov
# Include 'year' as an independent variable to deal with autocorrelation?

(Asked by: username_0 on 2022-11-07)

I'm working on an econometrics project for which I'm trying to study the impact of factors such as p.c. GDP growth, exports, inflation and interest rate on the debt-to-GDP ratio of a country, for 4 countries over a period of 20 years. I am using an LSDV model for this. And I have run into the problem of autocorrelation. I tried to correct for it using the method of subtracting p times the lagged variables for every observation, but even after this, after plotting the residual against its lag, I still see autocorrelation. How do I fix this?

I've heard that a crucial problem for autocorrelation is not including an independent variable. Till now I was not including the 'year' as a variable in my regression. Would that help? Also, is there any way I could deseasonalize the data or something similar? Please help as I'm not sure how to correct this.

I've heard of a Newey-West or something function in R that gives AC corrected errors? But I feel like our teacher wouldn't appreciate if I just did that without actually correctly the problem? I'd be grateful for any help. Thank you!!

**Tags:** econometrics, time-series, paneldata, autocorrelation

---

## 2 answers

### Answer by username_1 on 2022-11-07. Score: 1 | Accepted answer

1. Including time as independent variable would correct for *deterministic* time trend but that would most likely not affect autocorrelation.
2. Usually the best way how to solve autocorrelation is to explicitly model dynamics by including lagged variables as independent regressors. You can try doing that.
3. Using Newey-west errors is valid way of correcting for autocorrelation (unless you have model with lagged dependent variable). There is nothing incorrect about using non-standard errors as long as there are no other issues that might affect this. As to whether your teacher would appreciate to use it or not you have to ask him/her.

> **Comments:**
> **username_0**: Thanks so much for the answer. About your second point,  do i include lagged variables of the independent variables or of the dependent variable? Or both?  
> **username_1**: @viktornikiforov depends on what you believe the dynamic structure of the model is. You can do either of those or both  
> **username_0**: sorry exactly what do you mean by the dynamic structure of a model? :'((  
> **username_1**: @viktornikiforov how the lag structure of the true model which you want to estimate looks like  
> **username_2**: *Using Newey-west errors is valid way of correcting for autocorrelation (unless you have model with lagged dependent variable)*: could you elaborate a bit?  
> **username_1**: @RichardHardy according to Verbeek in that case coefficients will be biased unless you get the dynamic structure right. As far as I understand that is why correct lag structure in tests such as ADF which rely on some auxiliary regression modeled as AR/ARDL  process is so important  
> **username_2**: Do you remember where in Verbeek this is discussed? Wouldn't the coefficient on the lagged dependent variable be biased no matter what? I think all standard estimators (whether versions of OLS or MLE) of the slope coef. of a simple, correctly specified AR(1) model are biased. I doubt extending that with some exogenous regressors would help fix that.  
> **username_1**: @RichardHardy I remember it was in his handbook, I think it was actually in a section about ARDL so I think that it is a general property of OLS.  
> **username_2**: I guess a bigger problem might be lack of consistency of the OLS estimator in a model with lagged dep. var. and autocorrelated errors, as described in Verbeek "A Guide to Modern Econometrics" (5th edition, 2017) section 5.2 "Cases Where the OLS Estimator Cannot Be Saved" (p. 143-144). What handbook do you have in mind?  
> **username_1**: @RichardHardy maybe I misremembered it and it was only consistency (although I still think there was some discussion about in in chapter with ARDL), but still the whole point of NW is to save consistency since regular autocorrelation also does not affect bias.  
> **username_2**: NW adjusts standard errors but leaves point estimates intact. So when you say the point of NW is to save consistency, it could not mean consistency of point estimates. Do you perhaps mean consistency of standard errors? And again, I would love to check out the source, but I could not find the handbook you are mentioning. Could you please give a more concrete reference?  
> **username_1**: @RichardHardy I am not at home this week so I cannot double check the book so I am going just by my memory  
> **username_2**: Thanks. If I remember, I may ask you about this later then.  

---

### Answer by username_3 on 2022-11-12. Score: 1

I've heard that a crucial problem for autocorrelation is not including an independent variable. Till now I was not including the 'year' as a variable in my regression. Would that help?

Yes it could help. Omitting a trend as explanatory variable usually generates autocorrelation. If the true DGP is:
$$ y_t = \beta_0 + \beta_1 t + e_t, $$
with $E[e_t|t]=0, V[e_t|t]=\sigma^2, Cov[e_t,e_s|t,s]=0$, for $s \neq t,$
but if we omit $t$ and consider the misspecified model
$$ y_t = \beta_0 + u_t, $$
then we have $Cov(u_t,u_{t-1})=\beta_1^2 V(t)$ (exercise).
Moreover, as discussed below @1mouflon1's answer, the OLS estimate $\hat{\beta}_0$ is not consistent for $\beta_0$ in this case (with an omitted variable bias).
These properties are illustrated by the R-code below.
library( data.table )
T = 100

# DGP
t = seq(1:T)
e = rnorm(T)
beta_0 = 2
beta_1 = 1/2
y = beta_0 + beta_1*t + e
Dat = data.table( y, t, e  )
reg  = lm( y ~ 1 , data=Dat )
summary( reg ) # Illustrates that OLS is not consistent for beta_0

# Residuals
Dat_e = data.table( e_hat = reg$residuals ) 
Dat_e$e_hat_1 = shift( Dat_e$e_hat, type="lag" ) 

autocor_e  = lm( e_hat ~ e_hat_1, data=Dat_e )
summary( autocor_e ) # illustrates that residuals are AR1

# True error terms
u =  beta_1*t + e
Dat_u = data.table( u ) 
Dat_u$u_1 = shift( Dat_u$u, type="lag" ) 
# Check whether the theoretical result is (approximately) satisfied
cov( Dat_u$u, Dat_u$u_1, use="complete.obs" )
(beta_1)^2 * var( Dat$t )

autocor_u  = lm( u ~ u_1, data=Dat_u )
summary( autocor_u )


---

