r.user.05apr
r.user.05apr

Reputation: 5456

Specify seasonal ARIMA

I am having some forecast::Arima-syntax issues. If I know that a seasonal ARIMA is statistically ok because it is the result of auto.arima, how can I fix the following Arima-function to have the same order as the auto.arima result:

library(forecast)

set.seed(1)
y <- sin((1:40)) * 10 + 20 + rnorm(40, 0, 2)
my_ts <- ts(y, start = c(2000, 1), freq = 12)

fit_auto <- auto.arima(my_ts, max.order = 2)
plot(forecast(fit_auto, h = 24))
# Arima(0,0,1)(1,0,0) with non-zero mean

fit_arima <- Arima(my_ts,
                   order = c(0, 0, 1),
                   seasonal = list(c(1, 0, 0)))
#Error in if ((order[2] + seasonal$order[2]) > 1 & include.drift) { : 
#  argument is of length zero

Thx & kind regards

Upvotes: 3

Views: 934

Answers (1)

Nathan Werth
Nathan Werth

Reputation: 5263

The argument to seasonal must be either a numeric vector giving the seasonal order, or a list with two named elements: order, the numeric vector giving the seasonal order, and period, an integer giving the seasonal periodicity.

You gave a list with only the seasonal order, so Arima is complaining it couldn't find the period value. If you give a numeric vector, period will default to frequency(my_ts) like it says in the function's documentation. While it does make sense that giving just the order as a numeric or as a list should have the same result, it doesn't. Just a quirk of this function.

A rewrite of your call that works:

fit_arima <- Arima(my_ts,
                   order = c(0, 0, 1),
                   seasonal = c(1, 0, 0)) # vector, not a list

Upvotes: 4

Related Questions