简体   繁体   English

在R中,auto.arima无法捕获季节性

[英]In R, auto.arima fails to capture seasonality

auto.arima() is giving me no seasonal component for my series, even though I can see that there is one present. 即使我看到有一个礼物, auto.arima()也没有给我我的系列作品任何季节性组成部分。 The function gives me a non seasonal ARIMA model of order (5,0,0). 该函数给了我一个非季节性的ARIMA阶数(5,0,0)模型。 So, when I try to forecast using that model, it just gives the mean. 因此,当我尝试使用该模型进行预测时,它只是给出平均值。 The time series is of daily minimum temperatures in Melbourne, Australia for ten years. 该时间序列是澳大利亚墨尔本十年的每日最低温度。

Click this link to see the data and the auto.arima forecast 单击此链接以查看数据和auto.arima预测

` `

library(readr)

temp <- read_csv("~/Downloads/Melbourne Minimum Temp.csv", 
                 col_types = cols(Date = col_date(format = "%m/%d/%y"), 
                                  Temp = col_number()))

t <- ts(temp$Temp, start = temp$Date\[1], end = temp$Date[nrow(temp)])

auto.arima(t, trace = T)

` `

Tried using the data as a ts object, as an xts object, and as a vector. 尝试将数据用作ts对象,xts对象和向量。

Just reporting a good well explained - as usual - blogpost by Rob Hyndman. 照常报道,Rob Hyndman发表了一篇很好的解释(与往常一样)。

https://robjhyndman.com/hyndsight/dailydata/ https://robjhyndman.com/hyndsight/dailydata/

The relevant part to your question says (blockquoting exactly the page): 您问题的相关部分说(用引号括住页面):

When the time series is long enough to take in more than a year, then it may be necessary to allow for annual seasonality as well as weekly seasonality. 当时间序列足够长以可以使用一年以上时,则可能有必要考虑年度季节性和每周季节性。 In that case, a multiple seasonal model such as TBATS is required. 在这种情况下,需要使用多个季节模型,例如TBATS。

y <- msts(x, seasonal.periods=c(7,365.25))
fit <- tbats(y)
fc <- forecast(fit)
plot(fc)

This should capture the weekly pattern as well as the longer annual pattern. 这应该捕获每周模式以及更长的年度模式。 The period 365.25 is the average length of a year allowing for leap years. 365.25期间是允许leap年的一年的平均长度。 In some countries, alternative or additional year lengths may be necessary. 在某些国家/地区,可能需要其他或更长的年限。

I think it does exactly what you want. 我认为它确实可以满足您的需求。

I also tried to simply create the time series with msts 我还尝试使用msts简单地创建时间序列

y <- msts(x[1:1800], seasonal.periods=c(7,365.25))

(I cut the time series in half to be quicker) (我将时间序列缩短了一半,以便更快)

and then run auto.arima() directly on it, forcing a seasonal component with D=1 然后直接在其上运行auto.arima(),强制使用D = 1的季节性分量

fc = auto.arima(y,D=1,trace=T,stepwise = F)

it will take a while.. because I set stepwise = FALSE (if you want it to look at all combinations without shortcuts you can set approximation=FALSE as well) 这会花点时间..因为我设置了stepwise = FALSE(如果您希望它查看所有没有快捷方式的组合,也可以设置近似值= FALSE)

Series: y 
ARIMA(1,0,3)(0,1,0)[365] 

Coefficients:
         ar1      ma1      ma2      ma3
      0.9036  -0.3647  -0.3278  -0.0733
s.e.  0.0500   0.0571   0.0405   0.0310

sigma^2 estimated as 12.63:  log likelihood=-3854.1
AIC=7718.19   AICc=7718.23   BIC=7744.54

and then the forecast 然后是预测

for_fc = forecast(fc)
plot(for_fc)

I am adding a figure with the complete time series (red) on top of the output of plot(for_fc) and it seems to work decently - but it was just a quick test. 我在plot(for_fc)的输出之上添加了一个具有完整时间序列(红色)的图形,它似乎工作得很好-但这只是一个快速测试。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM