【问题标题】:how to show predictions on test data from multiple models in time series forecasting如何在时间序列预测中显示来自多个模型的测试数据的预测
【发布时间】:2018-08-19 04:22:07
【问题描述】:

我将 AirPassenger 数据拆分为 train 和 test,在 train 上拟合三个不同的指数平滑模型,然后在 test 上进行预测。我需要的是在测试数据上绘制所有模型的预测结果以及原始数据。任何人都可以帮助将它们全部绘制在一个情节上吗?提前非常感谢。

train <- window(AirPassengers, end=1957)
test <- window(AirPassengers, start=1958)
fc1 <- ses(train, h=5)
fc2 <- holt(train, h=5)
fc3 <- hw(train, seasonal='additive')

autoplot(AirPassengers)+??????

【问题讨论】:

  • @Rob Hyndman 非常感谢你,教授。这就是我需要的。但是如果我需要对测试数据进行预测,我怎样才能得到测试数据的预测值呢?有predict(fc, testdata)之类的吗?
  • 设置 h=length(testdata)

标签: r time-series forecasting


【解决方案1】:

试试这个:

AP <- cbind(AirPassengers, train, test, 
        as.ts(fc1)[, 1], as.ts(fc2)[, 1], as.ts(fc3)[, 1])
autoplot(AP)

【讨论】:

  • 看起来不像我想要的。如何从每个模型中获取测试数据的预测值? @G。格洛腾迪克
  • 它显示了所有 6 个系列。我添加了输出图像,因此您可以看到它确实显示了所有内容。如果您只希望其中一些从 AP 的定义中删除。
  • 谢谢,@G.Grothendieck 我需要的是根据测试数据预测的多条线图。 Hyndman教授评论中的链接有一些很好的例子
  • 它确实显示了这一点。 fct1、fct2 和 fct3 是显示三个预测的三个不同的线。
  • 我的意思是对整个测试数据的预测。
猜你喜欢
  • 2019-12-01
  • 2020-09-03
  • 1970-01-01
  • 2020-04-30
  • 2020-04-14
  • 2020-09-06
  • 1970-01-01
  • 1970-01-01
  • 2021-08-29
相关资源
最近更新 更多