This question is based on prof Rob's textbook: https://www.otexts.org/fpp/9/1

regarding dynamic question. In particular, the example on the insurance using lagged predictors for the regression model with arma errors



plot(insurance, main=  "Insurance advertising and quotations", xlab="Year")

Quotes <- insurance[,"Quotes"]
advents <- insurance[,2]

# Lagged predictors. Test 0, 1, 2 or 3 lags.
Advert <- cbind(insurance[,2],
colnames(Advert) <- paste("AdLag",0:3,sep="")

# Choose optimal lag length for advertising based on AIC
# Restrict data so models use same fitting period
fit1 <- auto.arima(insurance[4:40,1], xreg=Advert[4:40,1], d=0)
fit2 <- auto.arima(insurance[4:40,1], xreg=Advert[4:40,1:2], d=0)
fit3 <- auto.arima(insurance[4:40,1], xreg=Advert[4:40,1:3], d=0)
fit4 <- auto.arima(insurance[4:40,1], xreg=Advert[4:40,1:4], d=0)

# Best model fitted to all data (based on AICc)
# Refit using all data
fit <- auto.arima(insurance[,1], xreg=Advert[,1:2], d=0)

Notice for all the fitting, d=0 is specified. I did a KPSS test on all the variables ( the y as well as the xreg ) and found that they are in fact stationary.

So if we were to remove the d = 0 for all the fitting

fit1 <- auto.arima(insurance[4:40,1], xreg=Advert[4:40,1])
fit2 <- auto.arima(insurance[4:40,1], xreg=Advert[4:40,1:2])
fit3 <- auto.arima(insurance[4:40,1], xreg=Advert[4:40,1:3])
fit4 <- auto.arima(insurance[4:40,1], xreg=Advert[4:40,1:4])

# Best model fitted to all data (based on AICc)
# Refit using all data
fit <- auto.arima(insurance[,1], xreg=Advert[,1:2])

Some of the returned models will be returned with ARIMA errors of (0,1,0)

My question is: Why is auto.arima returning a model that does differencing when all the variables are already stationary. My only conclusion based on comparison is that the AICc as well as BIC is lower with (0,1,0) as opposed to the model returned with d = 0. Hopefully someone can guide me on this.

Edit: More information:

ndiffs(insurance[4:40,1], test="kpss") [1] 0

ndiffs(Advert[4:40,1], test="kpss") [1] 0

As you can see, both the data set that are input into auto.arima are non stationary. So why auto.arima choose to do a d=1?

Question 2: Based on the same link in the textbook:

ndiffs(austa, test="kpss") 

we can see that austa is non stationary and requires differencing. However, in Prof Rob's example of linear trends:

auto.arima(austa, xreg = 1:length(austa))


Series: austa Regression with ARIMA(2,0,0) errors

Coefficients: ar1 ar2 intercept 1:length(austa) 1.0371 -0.3379 0.4173 0.1715 s.e. 0.1675 0.1797 0.1866 0.0102

sigma^2 estimated as 0.02854: log likelihood=12.7 AIC=-15.4
AICc=-13 BIC=-8.23

Now why is auto.arima not applying differencing? I am very confused


Your Answer

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

Browse other questions tagged or ask your own question.