如何避免使用系列绘图R进行绘图预测中的漏洞

如何避免使用系列绘图R进行绘图预测中的漏洞,r,plot,forecast,R,Plot,Forecast,我写这个问题是因为我无法将(我尝试了很多次)情节、系列与预测联系起来 这里是我使用的代码 AA1<-AA_1 str(AA1)#OUTPUT: Time-Series [1:60] from 2013 to 2018: 309 368 1602 6742 19396 Serie1<-Serie_1 str(Serie1) ##OUTPUT:Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 60 obs. of 7 variables: X

我写这个问题是因为我无法将(我尝试了很多次)情节、系列与预测联系起来

这里是我使用的代码

AA1<-AA_1
str(AA1)#OUTPUT: Time-Series [1:60] from 2013 to 2018: 309 368 1602 6742 19396


Serie1<-Serie_1
str(Serie1) ##OUTPUT:Classes ‘tbl_df’, ‘tbl’ and 'data.frame':  60 obs. of  7 variables:


X_Reg_Mod_Completo <- cbind(A=ts(Serie1$A),B=ts(Serie1$B), 
                     C=ts(Serie1$C), D=ts(Serie1$D),
                     E=ts(Google1$E), F=ts(Serie1$F))

Mod_Completo<-auto.arima(AA1, xreg=X_Reg_Mod_Completo, trace = TRUE, test = "kpss", ic="aic", seasonal = TRUE)
AIC(Mod_Completo)
FOR_Mod_Completo<-forecast(Mod_Completo,xreg=X_Reg_Mod_Completo)
plot(FOR_Mod_Completo,xlim=c(2016, 2019))

AA1我尝试了一些使用
ggplot2
的方法,但没有把预测搞得太糟,也许它可以作为一个开始:

library(forecast)
library(tidyverse)
fit <- auto.arima(WWWusage)
forec <- forecast(fit,h = 10)
现在您可以绘制它:

  ggplot(tot) + geom_line(aes(time,Point.Forecast))+
                geom_line(aes(time, Lo.95))+
                geom_line(aes(time, Hi.95))+
                geom_line(aes(time, Lo.80))+
                geom_line(aes(time, Hi.80))+
                geom_vline(xintercept=tot$time[nrow(ts_)], color = 'red') + theme_light()

你好,弗朗西斯科,也许你能解释一下这个问题。@s-t谢谢你的回答和链接。这非常有帮助。欢迎您:如果您能找到建议的解决方案(复制并添加绘图中ts的最后一个值),您可以在此处发布答案并将其标记为正确。@s\t非常感谢。:)我很快就会做的。非常感谢你!!!!我很高兴你的帮助。它工作!!!现在我只需要自定义绘图。再次感谢你。
  ggplot(tot) + geom_line(aes(time,Point.Forecast))+
                geom_line(aes(time, Lo.95))+
                geom_line(aes(time, Hi.95))+
                geom_line(aes(time, Lo.80))+
                geom_line(aes(time, Hi.80))+
                geom_vline(xintercept=tot$time[nrow(ts_)], color = 'red') + theme_light()