0
我正在預測時間序列數據的需求預測。在時間序列中自動尋找季節性
dput
輸出保存到Data
可變
Data <- structure(list(Yr = c(2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2011L, 2011L, 2011L,
2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L,
2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L,
2012L, 2012L, 2012L, 2013L, 2013L, 2013L, 2013L, 2013L, 2013L,
2013L, 2013L, 2013L), Month = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L), Demand = c(58L, 59L, 108L, 145L,
109L, 105L, 104L, 175L, 101L, 105L, 254L, 199L, 187L, 201L, 149L,
93L, 126L, 115L, 136L, 94L, 135L, 116L, 112L, 95L, 122L, 247L,
188L, 121L, 237L, 190L, 187L, 206L, 206L, 156L, 198L, 154L, 231L,
190L, 237L, 250L, 182L, 250L, 118L, 123L, 222L)), .Names = c("Yr",
"Month", "Demand"), class = "data.frame", row.names = c(NA, -45L
))
str(Data)
我採取的Demand
變量和Decompose
對數變換,檢查季節性
Data$Log_Demand = log(Data$Demand)
splot <- ts(Data$Log_Demand, start=c(2010, 1),end=c(2013,9),frequency=12)
fit <- stl(splot, s.window="period")
monthplot(splot)
library(forecast)
seasonplot(splot)
我一個月拿劇情和季節性的情節 - 我發現編碼觀察到的季節性模式很難。這裏
Data$Seasonal_Jan = ifelse(Data$time %in% c(1,13,25,37),1,0)
我的問題是:
從我想自動找出什麼個月的季節性模式,觀察圖表和代碼的虛擬變量(如上)對於那些季節性使用該變量lm
模型爲了擬合趨勢分量和來自lm
模型殘差,我擬合ARIMA模型來預測預測。