# arima.errors() shows different errors on same model when using arima() and Arima()

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.

library('forecast')
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))
dev.new()
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.
• The latest version of the package on github (github.com/robjhyndman/forecast) will now find the xreg info in the first example. Apr 30 '14 at 1:02