I am fitting a regression with ARMA errors using the base R function arima() and the Arima() function from the forecast package.

The estimated coefficients from both are identical. My problem comes from using arima.errors() on these two models, and using tsdisplay() to view these structural residuals (that is, the residuals straight from the regression, before any ARMA model is fit on them). These ARMA errors (and their corresponding ACFs, PACFs) are different between the two, and I don't know why. Even more curious is that the final residuals from both are in fact the same, which would make me think the structural residuals would have to be the same. I have put a MWE below.

data(usconsumption, package='fpp')

fit1 = arima(usconsumption[ ,1], xreg=usconsumption[ ,2], order=c(2,0,0))
tsdisplay(arima.errors(fit1), main="ARIMA errors, arima function") # not the same as the other

fit2 = Arima(usconsumption[,1], xreg=usconsumption[,2], order=c(2,0,0))
tsdisplay(arima.errors(fit2), main="ARIMA errors, Arima function") # not the same as the other

View(cbind(resid(fit1), resid(fit2))) # final residuals are the same

Note this example is from https://www.otexts.org/fpp/9/1


arima.errors looks in the object that has been passed to find the xreg information. If it finds it, it subtracts out the regression part of the model and returns the ARMA errors. If it doesn't find the xreg information, it assumes you have a pure ARIMA model and returns the original data.

It should always work correctly with objects created with Arima, but it may not work correctly if you use arima instead. Note that the book says to use Arima. There is no reason ever to use arima.

In this case, it does not find the xreg information in fit1 and so it returns the usconsumption[,1] data.

I will see if I can modify arima.errors to at least send back a warning in cases like this. But if you just use Arima all the time, and never use arima, this problem will not arise.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.