0

dput(Training[1:10, ])

希望我做对了,仍然令人难以置信的新鲜和令人生畏!使用以下软件包: (tidyverse) (fable) (feasts) (fpp3) (knitr) (rmarkdown)

structure(list(Week = structure(c(17532, 17539, 17546, 17553, 
17560, 17567, 17574, 17581, 17588, 17595), week_start = 1, class = c("yearweek", 
"vctrs_vctr")), Demand = c(48, 101, 129, 113, 116, 123, 137, 
136, 151, 87), Date = structure(c(17532, 17539, 17546, 17553, 
17560, 17567, 17574, 17581, 17588, 17595), class = "Date"), mam = c(198.784860557769, 
198.784860557769, 106.25, 117.5, 121.25, 125.125, 132.375, 132.25, 
126.375, 141.75)), row.names = c(NA, -10L), key = structure(list(
    .rows = structure(list(1:10), ptype = integer(0), class = c("vctrs_list_of", 
    "vctrs_vctr", "list"))), row.names = c(NA, -1L), class = c("tbl_df", 
"tbl", "data.frame")), index = structure("Week", ordered = TRUE), index2 = "Week", interval = structure(list(
    year = 0, quarter = 0, month = 0, week = 1, day = 0, hour = 0, 
    minute = 0, second = 0, millisecond = 0, microsecond = 0, 
    nanosecond = 0, unit = 0), .regular = TRUE, class = c("interval", 
"vctrs_rcrd", "vctrs_vctr")), class = c("tbl_ts", "tbl_df", "tbl", 
"data.frame"))

Training努力使用我的数据集生成每周打印机需求的预测

妈妈只是移动平均线

# A tsibble: 204 x 4 [1W]
       Week Demand Date         mam
     <week>  <dbl> <date>     <dbl>
 1 2018 W01     48 2018-01-01  199.
 2 2018 W02    101 2018-01-08  199.
 3 2018 W03    129 2018-01-15  106.
 4 2018 W04    113 2018-01-22  118.
 5 2018 W05    116 2018-01-29  121.
 6 2018 W06    123 2018-02-05  125.
 7 2018 W07    137 2018-02-12  132.
 8 2018 W08    136 2018-02-19  132.
 9 2018 W09    151 2018-02-26  126.
10 2018 W10     87 2018-03-05  142.
# ... with 194 more rows
Printer_model <- Training %>%
  model(
    Mean = MEAN(Demand),
    `Naïve` = NAIVE(Demand ~ lag(4)),
    `Seasonal naïve` = SNAIVE(Demand),
    `Drift` = RW(Demand ~ drift(4))
  )

然后想要生成 4 周的预测

Printer_benchmarks <- Printer_model %>% forecast(h = 4)

这与《预测:原理与实践》第5.8章基本相同

错误代码:Error in ets(object, lambda = lambda, biasadj = biasadj, allow.multiplicative.trend = allow.multiplicative.trend, : y should be a univariate time series

我该如何解决这个问题?我正在使用fable我相信的包

4

0 回答 0