LoslegenKostenlos loslegen

Confidence Intervals for Forecast

Your forecast object forecast_MET_t not only has the forecast, but also margin of error calculations for the forecast called confidence intervals. These confidence intervals show us a wiggle room on our forecasts since no forecast is ever perfect.

The forecast was stored as the object forecast_MET_t$mean. The upper and lower limit of this interval is stored similarly. The second column of the upper confidence interval is the 95% confidence interval and can be accessed via forecast_MET_t$upper[,2]. To get the lower limit replace the word upper with lower.

Diese Übung ist Teil des Kurses

Forecasting Product Demand in R

Kurs anzeigen

Anleitung zur Übung

  • Convert both the upper and lower 95% confidence limits to xts objects upper and lower. Your date index is stored as for_dates.
  • Add these to the plot of the forecast and the validation data set.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Plot the validation data set
plot(MET_t_valid, main = 'Forecast Comparison', ylim = c(4000, 8500))

# Overlay the forecast of 2017
lines(for_MET_t_xts, col = "blue")

# Convert the limits to xts objects
lower <- xts(forecast_MET_t$___[,2], order.by = ___)
upper <- xts(___$___[,___], order.by = for_dates)

# Adding confidence intervals of forecast to plot
lines(lower, col = "blue", lty = "dashed")
lines(___, col = "blue", lty = "dashed")
Code bearbeiten und ausführen