Every model is a specification: a small list that says what to fit.
It can be printed, saved, renamed and combined; it is estimated only by
fit_model(), forecast_model() or inside a
backtest().
model_log(model_airline())
#> <foresight model> log_arima_011_011
#> ARIMA(0,1,1)(0,1,1) by exact maximum likelihood, on the log scalemodel_naive(), model_drift(),
model_mean() and model_seasonal_naive() are
what any other model must beat. The seasonal naive forecast with
growth = TRUE repeats last year scaled by the growth of the
last twelve months, a strong benchmark for revenue.
model_theta() is the method that won the M3 competition,
equivalent to simple exponential smoothing with drift, on the seasonally
adjusted series. model_holt_winters() smooths level, trend
and a multiplicative seasonal pattern.
model_ets() fits one member of the family by its code
(error, trend, season); model_auto_ets() chooses by AICc
among those that suit the series.
model_arima() is estimated by exact maximum likelihood.
model_auto_arima() chooses the differences by tests and the
orders by a stepwise search.
model_prophet() fits a trend that may bend at many
places, shrinking the bends that do not matter to exactly zero, plus
Fourier seasonality:
fit <- fit_model(model_prophet(), log(y))
fit$details$changepoints
#> [1] 10 15 19 28 37 51 60 65 88 101 115Events and lasting steps are covered in
vignette("regressors").
model_tbats() handles several seasonal periods,
including periods that are not whole numbers (52.18 weeks in a year),
with trigonometric terms. Whatever is not fixed is chosen by AIC, which
takes seconds.
For series where most periods have no demand, the forecast is a rate: Croston’s method and its SBA and TSB variants.
Any model can run on the log or Box-Cox scale, and on the seasonally adjusted series:
model_name(model_log(model_decomposed(model_auto_ets())))
#> [1] "log_stl_auto_ets"
forecast_model(model_box_cox(model_theta(), "guerrero"), y, 3)
#> Jan Feb Mar
#> 1961 446.6416 437.0833 521.2054An ensemble learns its weights from its members’ errors on the end of
the series; with "stacked" weights, members that add
nothing get exactly zero.
vapply(candidates_default(), model_name, "")
#> [1] "naive" "drift" "seasonal_naive"
#> [4] "seasonal_naive_growth" "theta" "holt_winters"
#> [7] "log_linear" "arima_011_011" "log_arima_011_011"
#> [10] "prophet" "log_prophet"
length(candidates_thorough())
#> [1] 18candidates_thorough() adds the automatic choices and two
ensembles, and takes seconds rather than milliseconds in a backtest.