dput(Training[1:10, ])
Hopefully I've done this right, still all incredibly new and intimidating!
using the following packages:
(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"))
Struggling to generate forecasts for weekly printer demand with my Training
dataset
mam is just the Moving Average
# 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))
)
Then want to generate forecasts for 4 weeks
Printer_benchmarks <- Printer_model %>% forecast(h = 4)
This is basically the same as in chapter 5.8 of Forecasting: Principles and Practice
The Error code: Error in ets(object, lambda = lambda, biasadj = biasadj, allow.multiplicative.trend = allow.multiplicative.trend, : y should be a univariate time series
How do I resolve this issue? I'm using fable
package I believe