【发布时间】:2017-03-27 22:05:37
【问题描述】:
我正在尝试在 R 中重新创建论文“Box-Jenkins 季节性预测:案例研究中的问题”(1973 年)。现在我几乎完成了,但遇到了预测问题。
为了使数据平稳并去除季节性,对销售数据日志(df)的差异进行了两次。
# required lib
require(forecast);
# transform data
df=read.table("Sample.txt", header = TRUE)
df
ts<-ts(df, frequency=12, start=c(1965,1))
ts
ts_log10 <- log10(ts)
ts_log10
dd12zt <- diff(diff(ts_log10, 12))
dd12zt
(对不起,我知道还有更漂亮的写法。)在我检查了最合适的ARIMA模型后,我预测了未来12个月的销售额。
# Best fitting ARIMA
ARIMAfit <- auto.arima(dd12zt)
summary(ARIMAfit)
# Forecast
fcast <- forecast(ARIMAfit, h=12)
plot(fcast)
summary(fcast)
当然,预测值与样本值不匹配。我现在的问题是如何最好地将预测数据“转换回”,以便将其与原始时间序列一起绘制?
数据(Sample.txt): 销售量 154 96 73 49 36 59 95 169 210 278 298 245 200 118 90 79 78 91 167 169 289 347 375 203 223 104 107 85 75 99 135 211 335 460 488 326 346 261 224 141 148 145 223 272 445 560 612 467 518 404 300 210 196 186 247 343 464 680 711 610 613 392 273 322 189 257 324 404 677 858 895 664 628 308 324 248 272
附:如果我发布了错误的内容,我很抱歉。我对stackoverflow的习惯还不是很熟悉。我期待着提示和建议。
【问题讨论】:
标签: r plot time-series forecasting