Skip to contents

Specify a median benchmark model for use with fabletools::model().

Usage

MEDIAN(formula, ...)

Arguments

formula

A model formula specifying the response and optional window() special, for example value ~ window().

...

Further arguments.

Value

A model definition that can be used inside fabletools::model().

Details

MEDIAN() forecasts future values using the median of the observed response. The window() special controls whether the median is estimated using all observations, a fixed trailing window, or a rolling window.

Examples

library(dplyr)
library(tsibble)
library(fabletools)

train_frame <- M4_monthly_data |>
  filter(series == first(series)) |>
  as_tsibble(index = index)

model_frame <- train_frame |>
  model("MEDIAN" = MEDIAN(value ~ window()))

model_frame
#> # A mable: 1 x 1
#>     MEDIAN
#>    <model>
#> 1 <MEDIAN>