I have run a simple linear regressions of insect counts against weather variables, e.g. total monthly rainfall. I have previously never known of autocorrelation but a reviewr of my manuscript has required me to test for autocorrelation and run models which account for its occurence.
I found suggestions by Macro on "How to test the autocorrelation of the residuals?" very easy to follow and helpful for a first timer like me to test for autocorrelation. I have found autocorrelation occuring in some of my linear regression models, but I haven't got such a simple approach to correcting for the autocorrelation. Most answers go into complex equations (with packages like "spdep", "sphet", "gmm", etc.) rather than straight forward R commands to run corrective models.
I would greatly appreciate someone who can help me out to make meaning out of my data through a simple approach.
Autocorrelated errors signal model misspecification. Ideally, model errors should be $i.i.d.$ and thus should have no patterns in them. If they do, there is some information left unextracted; some more modelling can be done to extract the pattern.
There are two ways of dealing with the problem of autocorrelated errors.
Leave the model specification as is but expand confidence intervals around the regression coefficients to account for the violation of the model assumption of non-autocorrelated errors. This can be motivated by the wish to retain the original model that may be directly derived from theory and/or have a nice interpretation. This can be done by using heteroskedasticity and autocorrelation (HAC) robust standard errors, e.g. by Newey and West (1987). HAC standard errors (as an alternative to the regular standard errors) should be available in any major statistical software package; they seem to be quite popular among practitioners, perhaps because they provide an easy solution. Pros: easy to use; can retain the original model. Cons: wider confidence intervals $\rightarrow$ lower precision, less power (harder to reject null hypotheses); model is misspecified; less accurate forecasting (due to neglecting the autocorrelation in model errors).
Change the model specification to obtain non-autocorrelated errors. For example, run a regression with ARMA errors (easy to implement by arima or auto.arima functions in R including the regressors via the parameter xreg) or -- as DJohnson suggested -- include lags of dependent variable as regressors. Pros: narrower confidence intervals $\rightarrow$ higher precision, more power (easier to reject null hypotheses); model is correctly specified (unless there are other faults, which may quite often be true); more accurate forecasting. Cons: requires more work; cannot retain the original model.
The link to this presentation develops several intuitive approaches to correcting for autocorrelation when tests show that it exists. Most of these methods are for AR(1) or first-order processes and include:
Adding/deleting variables, e.g., including 1-period lags of the response
Increasing the temporal period, e.g., from daily to weekly, and so on
Adjusting the errors by first differencing and multiplying by the autocorrelation coefficient, rho (apologies for my lack of Latex skills but the formula is on page 17 of the link):