0
votes

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. 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

I would like to make a forecast for February 2018, even though I have that data, to test the model ability vs actual. I would then like to plot the forecasted values for march but make it much prettier.

#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)
1
Take a look at the 'forecast' package. - ulfelder
I have, didnt see anything, thanks for the help - William Bernard
Can you paste the output of dput(datats) into your post? - hpesoj626

1 Answers

0
votes

The following link provides a good tutorial about time series forecasting in R, using the forecast, tseries and ggplot2 packages : https://www.datascience.com/blog/introduction-to-forecasting-with-arima-in-r-learn-data-science-tutorials