I'm looking for an example to show my class. We are covering OLS vs GLS with autocorrelated errors -- I've got the class to the point where they understand (some of them) why the the standard errors on the coefficient estimates tend to be underestimated (and the t-scores overestimated) when the autocorrelations of the errors at low lags are positive. But it would be nice to have an example where they can see how inference might change based on fitting a ``better'' model with gls.
Thus, I'd like to show an example where the residuals from an OLS model y~x have an AR1 structure that would give spurious results (std errors on the estimates, p-values, etc.). Then I would show them a gls implementation that accounts for correlated residuals. E.g.,
# example of what'd I'd like given the right x and y
ols1 <- lm(y~x) #ols model
summary(ols1) # would show a biased model
acf(residuals(ols1)) # would show AR1 structure
# vs
gls1 <- gls(y~x,correlation = corAR1())
Any ideas out there?
Edited for clarity.