A time series of yearly data, I want to compare the AIC and BIC values by auto.arima and manual ARIMA.
library(forecast)
drink <- c(188,301,451,504,630,855,883,1078,1099,1008,1050,1058)
drink_ts <- ts(drink, frequency = 1, start=c(1950))
auto.arima(drink_ts)
# Series: drink_ts
# ARIMA(0,1,0) with drift
# Coefficients:
# drift
# 79.0909
# s.e. 26.5245
# sigma^2 estimated as 8513: log likelihood=-64.86
# AIC=133.71 AICc=135.21 BIC=134.51
I want to replicate it, so do a manual with same ARIMA(0,1,0):
drink.fit <- arima(drink_ts, order = c(0,1,0))
drink.fit
To get the AIC and BIC values:
AIC(drink.fit)
BIC = AIC(drink.fit,k = log(length(drink_ts)))
BIC
# AIC: 138.7121
# BIC: 138.2272
The AIC and BIC values by auto.arima and manual ARIMA are slightly different.
Does it matter? Am I missing anything in the manual ARIMA?
(by the way, if there’s a direct way to get the AIC and BIC from the manual ARIMA)
Thank you.
Best Answer
You are missing one thing. Note that
auto.arima()
fits an ARIMA(0,1,0) model with drift. This is the following model:$$ (1-B)(y_t-\mu t) = e_t, $$
or after rearranging,
$$ y_t = y_{t-1}+\mu+e_t. $$
The estimated value of $\mu$ is the
79.0909
you get.So if you wanted to reconstruct your
auto.arima()
results, you would first have to "correct" your time seriesdrink_ts
by this drift term. Unfortunately, it's not clear how thet
parameter runs - does it start from 1950 (being the first year in your series), or from 1 (which sounds more reasonable - but would yield a nonzero intercept).I played around a bit, but couldn't fully reconstruct your AIC values. Part of the problem is of course accounting for the degree of freedom expended in estimating the drift parameter, similarly whether to allow a mean or constrain it, and finally likely slight differences in estimating methods between
arima()
andauto.arima()
.In general, I would trust
auto.arima()
more than a hand-crafted call toarima
. (And regarding your parenthetical question, you can extract the AIC byarima(drink_ts)$aic
, but I don't know of a way to get the BIC, or the AICc.)If your question is still open, maybe you could either ask a new question that avoids the drift complications (possibly linking the two questions), or edit to explain why you are trying to do what you are trying to do?