
394 Data Analysis and Statistics for Geography, Environmental Science, and Engineering
You can forecast from the end of the series up to a future time by using the function predict. Use
this function to forecast for the two cycles (10 days) ahead from day 50 of the data series, calculate
upper and lower limit based on the double of the standard error se. Usually, the forecast is made
for a relatively short time horizon.
Xt.pred <- predict(ar.Xt, ts(Xt[1:50]), n.ahead=10)
# plot
up <- Xt.pred$pred + 2*Xt.pred$se
low <- Xt.pred$pred - 2*Xt.pred$se
Now we will plot and plot the data together with the forecast. First, we plot the forecast by itself for ...