開始使用免費開始

預測的信賴區間

你的預測物件 forecast_MET_t 不僅包含預測值,還包含稱為信賴區間的誤差範圍計算。由於沒有任何預測是完美的,這些信賴區間能告訴我們預測的允許誤差範圍。

預測值已儲存在物件 forecast_MET_t$mean。此區間的上下界也以類似方式儲存。上界的第二欄是 95% 信賴區間,可透過 forecast_MET_t$upper[,2] 取得。若要取得下界,將 upper 一詞改為 lower

本練習屬於課程

用 R 預測產品需求

檢視課程

練習說明

  • 將 95% 信賴區間的上、下限各轉成 xts 物件 upperlower。你的日期索引已儲存為 for_dates
  • 將這兩者加入預測與驗證資料集的圖上。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# 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")
編輯並執行程式碼