I started rewriting all my code from forecast to fable. Does anybody know why the constant is different from the mean?
library("fable")
library("lubridate")
library("dplyr")
library("forecast")
# gen data
set.seed(68)
df <- data.frame(time = ymd(Sys.Date() - c(1:1000)),
V = rnorm(1000, 0.2))
df <- fabletools::as_tsibble(df, index = time, regular = TRUE) %>% dplyr::arrange(time)
# fable model
df %>% fabletools::model(fable::ARIMA(V ~ pdq(3, 0, 0) + PDQ(0, 0, 0))) %>% report()
# forecast model
as.ts(df) %>% forecast::Arima(c(3, 0, 0), include.mean = TRUE)
Series: V
Model: ARIMA(3,0,0) w/ mean
Coefficients:
ar1 ar2 ar3 constant
-0.0578 -0.0335 -0.0158 0.2141
s.e. 0.0316 0.0317 0.0317 0.0308
sigma^2 estimated as 0.9499: log likelihood=-1391.23
AIC=2792.45 AICc=2792.51 BIC=2816.99
Series: .
ARIMA(3,0,0) with non-zero mean
Coefficients:
ar1 ar2 ar3 mean
-0.0578 -0.0335 -0.0158 0.1934
s.e. 0.0316 0.0317 0.0317 0.0278
sigma^2 estimated as 0.9499: log likelihood=-1391.23
AIC=2792.45 AICc=2792.51 BIC=2816.99
and I get for some higher order models following error, which I can't interpret properly.
I am able to estimate the models with forecast
, even though the models might be silly, I can't even estimate them with fable
Warning message:
1 error encountered for ar
[1] There are no ARIMA models to choose from after imposing the `order_constraint`, please consider allowing more models.`
The models that you are specifying between fable and forecast are equivalent.
The parameterisation between the packages differ, fable::ARIMA
uses constant form whereas forecast::Arima
and stats::arima
use mean form.
This is discussed in https://otexts.com/fpp3/arima-r.html#understanding-constants-in-r
Furthermore, in your fable model specification you have not specified if the constant (or equivalently, the include.mean
) in the model. If this is not done, fable will automatically select between including and excluding the constant via an algorithm similar to auto.arima
. You should add 1
(include) or 0
(exclude) to your formula to specify the model's constant.
fable::ARIMA(V ~ 1 + pdq(3, 0, 0) + PDQ(0, 0, 0)))
is equivalent to forecast::Arima(V, c(3, 0, 0), include.mean = TRUE)
.
This is also why you're having trouble with estimating higher order models. When automatically selecting a model, fable::ARIMA
will respect the argument order_constraint = p + q + P + Q <= 6
. As the constant is not specified (and will be automatically selected), this order constraint is being enforced (giving no possible models to evaluate). You can keep automatic selection by removing the order_constraint
with order_constraint = TRUE
(this means that whenever testing the constraint, it will be TRUE, i.e. acceptable).
I have updated the package to include more informative errors and a better description of the parameterisation in ?ARIMA
.