In R I'm trying to fit a linear regression with autoregressive (AR(1)) errors. In David Ruppert's book it has the following code:
library(AER) library("Ecdat") library("forecast") data("USMacroG") MacroDiff = as.data.frame(apply(USMacroG, 2, diff)) attach(MacroDiff) fit1 = arima(unemp, order=c(1,0,0), xreg=cbind(invest, government)) fit1$aic
the above model has
aic = 86.85, however when I tried my own code, the model has a different AIC value, my code is as follows:
fit2.1 = lm( unemp ~ government + invest) fit2.2 = arima(fit2.1$residuals , order=c(1,0,0) , include.mean = FALSE) fit2.2$aic
for the above model
aic = 102.12. As far as I can tell the two models are exactly the same, but I don't understand why the two models have very different AIC value.