如何在 R 中拟合季节性 ARIMA 模型

How to fit a seasonal ARIMA model in R

我想拟合季节性 ARIMA 模型,其中每 24 小时一个季节。 但是如何在 R 中包含 24 小时季节性术语?到目前为止,我已经尝试了以下方法:

arima(y, order=c(0,0,2), seasonal=c(0,0,5), method = "ML")

但如果我是正确的,那是一个 ARIMA(0,0,2)(0,0,5)_12 模型,所以我希望得到帮助使其成为 ARIMA(0, 0,2)(0,0,5)_24 模型。

您需要在 seasonal=list(order=..., period=...) 中包含 period=。如果观察是每小时一次,请使用 period=24L。如果每秒,使用period=24*60*60,等等

示例。

# reproducible example!
# download file from:
# https://trends.google.com/trends/explore?date=now%207-d&q=Whosebug
df <- read.csv('multiTimeline.csv', skip=3, header=FALSE, stringsAsFactors = FALSE)
names(df) <- c('Time','Searches')
df$Time <- as.POSIXlt.character(df$Time, tz='UTC',format = '%Y-%m-%dT%H')

plot(df, type='l')

m1 <- arima(x = df$Searches, 
            order = c(0L,0L,2L),
            seasonal=list(order=c(0L,0L,5L), period=24L )
)

> m1

Call:
arima(x = df$Searches, order = c(0L, 0L, 2L), seasonal = list(order = c(0L, 
    0L, 5L), period = 24L))

Coefficients:
         ma1     ma2    sma1    sma2     sma3    sma4    sma5  intercept
      1.0827  0.6160  0.6155  0.1403  -0.1472  0.0104  0.6807    52.1477
s.e.  0.0631  0.0566  0.2305  0.2005   0.1445  0.2210  0.2176     2.4497

sigma^2 estimated as 35.69:  log likelihood = -575.94,  aic = 1169.88

?arima:

seasonal A specification of the seasonal part of the ARIMA model, plus the period (which defaults to frequency(x)). This should be a list with components order and period, but a specification of just a numeric vector of length 3 will be turned into a suitable list with the specification as the order.