预测图-添加拟合和验证区域

时间:2018-11-04 12:22:01

标签: r

请参阅链接:http://kourentzes.com/forecasting/2016/06/17/how-to-choose-a-forecast-for-your-time-series/#comments

根据图2:应如何在验证图中添加拟合和验证区域:ETS和ARIMA预测。这些模型仅适用于时间序列的第一部分,而验证集仅用于评估其性能。 enter image description here

我的数据集(zz)如下:

    X dataid meter_value
 2015-10-27 19:50:00   1103      183138
 2015-10-27 19:51:00   1103      183138
 2015-10-27 19:52:00   1103      183138
 2015-10-27 19:53:00   1103      183138
 2015-10-27 19:54:00   1103      183138
 2015-10-27 19:55:00   1103      183138
 2015-10-27 19:56:00   1103      183138
 2015-10-27 19:57:00   1103      183138
 2015-10-27 19:58:00   1103      183138
 2015-10-27 19:59:00   1103      183138
 2015-10-27 20:00:00   1103      183138
 2015-10-27 20:01:00   1103      183138
 2015-10-27 20:02:00   1103      183138
 2015-10-27 20:03:00   1103      183138
 2015-10-27 20:04:00   1103      183138
 2015-10-27 20:05:00   1103      183138
 2015-10-27 20:06:00   1103      183138
 2015-10-27 20:07:00   1103      183138
 2015-10-27 20:08:00   1103      183138
 2015-10-27 20:09:00   1103      183138
 :
 2015-12-31 23:59:00   1103      183139.3

我的R代码如下:

    start_time <- as.POSIXct("2015-10-27 19:50",format="%Y-%m-%d %H:%M")
    end_time   <- as.POSIXct("2015-10-27 23:59",format="%Y-%m-%d %H:%M")

    zoo_obj <- zoo(zz$meter_value,
      order.by = seq.POSIXt(from = start_time, to = end_time ,by = "min"))

    str(zoo_obj)
    #‘zoo’ series from 2015-10-27 19:50:00 to 2015-10-27 20:09:00
    #  Data: num [1:20] 183138 183138 183138 183138 183138 ...
    #  Index:  POSIXct[1:20], format: "2015-10-27 19:50:00" "2015-10-27 19:51:00" ...

    mytsTT2 <- ts(zoo_obj)

str(mytsTT2)
#Time-Series [1:20] from 1 to 20: 183138 183138 183138 183138 183138 ...
# - attr(*, "index")= POSIXct[1:20], format: "2015-10-27 19:50:00" ...

我尝试使用“自动绘图”

autoplot(forecast(mytsTT2,1000)) 

enter image description here

我应该如何在自动绘图中添加拟合和验证区域?

0 个答案:

没有答案