[英]R: Forecasting Time Series
I would like to make a forecast on the values of the data that I already have and plot the actual versus forecast to see how well it does and then forecast 30 periods out into the future. 我想对已经拥有的数据的值进行预测,然后将实际值与预测值作图,以查看其效果如何,然后预测未来30个周期。 As of now I have a forecast out into the future.
截至目前,我对未来进行了预测。
The data is from 1/1/2014 to 2/28/18 containing slot revenue 数据为2014年1月1日至18年2月28日,其中包含广告位收入
I would like to make a forecast for February 2018, even though I have that data, to test the model ability vs actual. 即使我有这些数据,我也希望对2018年2月做出预测,以测试模型能力与实际能力之间的关系。 I would then like to plot the forecasted values for march but make it much prettier.
然后,我想绘制3月的预测值,但要使其更漂亮。
#Load Data
datats <- read.csv("ProjectTS1.CSV")
datats$SlotTS <- ts(datats$slots, start=2014,frequency=365)
acf(datats$SlotTS, lag.max = 1, plot = FALSE)
acf(datats$SlotTS)
AR <- arima(datats$SlotTS, order = c(3, 1, 2)) #2,1,3
AR_fitted <- datats$SlotTS - residuals(AR)
points(AR_fitted, type = "l", col = 2, lty = 2)
ts.plot(AR_fitted)
predict_AR <- predict(AR)
predict(AR, n.ahead = 10)
AR_forecast <- predict(AR, n.ahead = 30)$pred
ts.plot(datats$SlotTS,xlim=c(2018,2018.2))
AR_se <- predict(AR, n.ahead = 30)$se
points(AR_forecast, type = "l", col = 2)
points(AR_forecast - 2*AR_se, type = "l", col = 2, lty = 2)
points(AR_forecast + 2*AR_se, type = "l", col = 2, lty = 2)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.