2015-10-14 75 views
1

我需要绘制Dygraph中的时间序列,其中多个时间序列一起绘制。R dygraph预测与原始值一起绘制

随着数据我们可以使用

df <- cbind(mdeaths, fdeaths) 

如在dygraphs网站完成:https://rstudio.github.io/dygraphs/

不过,我想提出两个时间序列继续相同的图像与原始数据的预测。我做了什么,我想实现

enter image description here

一种方法自然是单独用做即auto.arima的预测,然后再结合数据粗图。我想知道是否有功能,可以一次完成所有功能?

+0

在你的情况我会同步排行榜[像这样](http://dygraphs.com /tests/synchronize.html): 在任何图表上缩放和平移将缩放和平移所有其他图表。选择一个点将选择其他点。 – hvollmeier

回答

0

我想你的意思是在同一网站上的“上/下酒吧”部分回答:https://rstudio.github.io/dygraphs/gallery-upper-lower-bars.html。 你需要让你的预测模型,例如:

hw <- HoltWinters(mdeaths) 
p <- predict(hw, n.ahead = 36, prediction.interval = TRUE) 
all <- cbind(ldeaths, p) 

和情节德图:

dygraph(all, "Deaths from Lung Disease (UK)") %>% 
    dySeries("mdeaths", label = "Actual") %>% 
    dySeries(c("p.lwr", "p.fit", "p.upr"), label = "Predicted")