I am trying to create a combination model using the R fable
and/or fable.tools
packages. However, instead of the mean I want to use the median.
I cannot find any examples where the cmbn_fn or cmbn_args were used where it isn't mean or weighted, but I'm thinking it must be possible.
I've tried multiple variations of something like the below without success. Hoping someone knows how to return the median of models.
comb1 = combination_model(
TSLM(log(y) ~ trend() + season()),
ARIMA(log(y), stepwise = TRUE, approximation = TRUE)),
THETA(log(y)),
ETS(log(y)),
cmbn_fn = combination_ensemble,
cmbn_args = list(median)
Thank you, Brian
If the component models of the combination are not normally distributed, you can obtain median forecasts of combination models from bootstrapped paths. I've needed to make a slight addition to fabletools to make this possible, so you will need to install the latest development version from GitHub with
remotes::install_github("tidyverts/fabletools")
.Here's an example for how it works.
Created on 2023-10-18 with reprex v2.0.2
Note that
cmbn_args
are arguments passed on to thecmbn_fn
, which doesn't accept the median as an input. This is for things like custom weights for the combination. The point forecasts to be produced are specified in thepoint_forecast
argument of theforecast()
function.