Hi,
There's a problem with 13.4 Forecast combinations | Forecasting: Principles and Practice (3rd ed), running the following code from the book, I get the error:
Error in mutate()
:
In argument: stlf = (function (object, ...) ...
.
Caused by error in .mapply()
:
! argument "MoreArgs" is missing, with no default
Run rlang::last_trace()
to see where the error occurred.
library(fpp3)
auscafe <- aus_retail |>
filter(stringr::str_detect(Industry, "Takeaway")) |>
summarise(Turnover = sum(Turnover))
train <- auscafe |>
filter(year(Month) <= 2013)
STLF <- decomposition_model(
STL(log(Turnover) ~ season(window = Inf)),
ETS(season_adjust ~ season("N"))
)
cafe_models <- train |>
model(
ets = ETS(Turnover),
stlf = STLF,
arima = ARIMA(log(Turnover))
) |>
mutate(combination = (ets + stlf + arima) / 3)
cafe_fc <- cafe_models |>
forecast(h = "5 years")
These are the packages I have installed
> library(fpp3)
Registered S3 method overwritten by 'tsibble':
method from
as_tibble.grouped_df dplyr
── Attaching packages ──────────────────────────────────────────────────────────────────────────────── fpp3 1.0.1 ──
✔ tibble 3.2.1 ✔ tsibble 1.1.5
✔ dplyr 1.1.4 ✔ tsibbledata 0.4.1
✔ tidyr 1.3.1 ✔ feasts 0.4.1
✔ lubridate 1.9.3 ✔ fable 0.4.1
✔ ggplot2 3.5.1
── Conflicts ───────────────────────────────────────────────────────────────────────────────────── fpp3_conflicts ──
✖ lubridate::date() masks base::date()
✖ dplyr::filter() masks stats::filter()
✖ tsibble::intersect() masks base::intersect()
✖ tsibble::interval() masks lubridate::interval()
✖ dplyr::lag() masks stats::lag()
✖ tsibble::setdiff() masks base::setdiff()
✖ tsibble::union() masks base::union()
with the development version of package distributional because of the sqrt function error
remotes::install_github("mitchelloharawild/distributional")