Solved – Fitting multiple linear regression in R: autocorrelated residuals

autocorrelationmultiple regressionrresidualstime series

I'm trying to estimate a multiple linear regression in R with an equation like this:

regr <- lm(rate ~ constant + askings + questions + 0)

askings and questions are quarterly data time-series, constructed with askings <- ts(...).

The problem now is that I got autocorrelated residuals. I know that it is possible to fit the regression using the gls function, but I don't know how to identify the correct AR or ARMA error structure which I have to implement in the gls function.

I would try to estimate again now with,

gls(rate ~ constant + askings + questions + 0, correlation=corARMA(p=?,q=?))

but I'm unfortunately neither an R expert nor an statistical expert in general to identify p and q.

I would be pleased If someone could give me a useful hint.
Thank you very much in advance!

Jo

Best Answer

Try

library(forecast)
fit <- auto.arima(rate, xreg=cbind(askings,questions))

That will fit the linear model as will as automatically identify an ARMA structure for the errors. It uses MLE rather than GLS, but they are asymptotically equivalent.

Related Question