# Can you solve (avoid) an autocorrelation problem by adding an independent variable?

I am working on modeling what amounts to a time series, the DV is measured 40 times a day on 40 different days--- the actual timing of measurements on a given day varies, and the number of days between these sessions also varies.

I am told that with such data (this is a single participant case study) autocorrelation is expected to be a problem, and so we should 'worry' about it and try to account for it. However, in my regression model I see no signs of autocorrelation in the residuals-- either when looking at an ACF plot or when using the Durbin-Watson test. I thought--- how can this be, if apparently its 'always' a problem? Then I saw that if I remove a certain independent variable, namely the session # itself, then I do see serious autocorrelation. Compare the models and ACF plots below:

You can see that in the first ACF plot, lag-1 is significant, and there is a clear decreasing trend, whereas in the second the lag-1 is tiny and there is no obvious trend. The different between these models of course, as you can see at the heading, is that the latter includes session # as an independent variable.

Is it WRONG for any reason to include that variable (session)?? It is of interest-- we want to know if the dv is changing with session, so a priori this is the model I designed. And if that is okay, which I can't see why it wouldn't be, then I don't understand why everyone doesn't just "solve" autocorrelation issues in regression by including an independent variable that 'captures' the non-independent nature of the trial structure. Any thoughts/comments on this are VERY welcome, I have to wrap my head around all of this before I can start writing a paper about our results!

• You have bands at +/- 0.3. Is this particular to your problem or is that just a good convention to know if the errors are autocorrelated? – Naz Mar 7 '19 at 16:33
• That's to do with my sample size-- see this thread here: stats.stackexchange.com/questions/185425/… – reddawg50 Mar 7 '19 at 20:12
• Thanks for the link. So I assume those bands above are for $d=1$? – Naz Mar 7 '19 at 20:15

## 2 Answers

Yes, you can sometimes solve an autocorrelation problem in a regression model by adding a variable, if it's the right variable.

Or, as you've demonstrated, you can create autocorrelation problems by dropping a variable.

Most forecasting books are likely to have an example. If you want a specific reference, Hanke and Wichern, Business Forecasting, 9th edition, page 347.

When there is a concern about autocorrelation, a common approach is typically to adjust the standard errors. Newey-West errors are built in most regression packages. With your adjusted standard errors, you can compute new t statistics and perform any hypothesis testing you need to do.

In terms of suggesting whether to add a variable or not, I don't have a very good sense of what these variables are. I take it the session number is like a time trend. Including time trends is a common approach in the literature.

• thanks John-- session number is a time trend, there were 40 sessions (each on a different day) and the dv was measured on each of these. If adding a time trend results in there not being any detectable autocorrelation, is there any reason to adjust the standard errors or use ARIMA model, etc? It seems to me like if the time trend predictor is "doings a good job", then one can proceed with standard regression procedures... because the assumption of independent errors is not violated, no? – reddawg50 May 11 '15 at 21:35
• It can't hurt to show a few different specifications. Strictly speaking, if there are no autocorrelation effects, then you don't need Newey West errors (assuming no other effects either). However, someone might ask if you correct for it anyway. – John May 11 '15 at 22:44