descale_by_mase: Back-transform a MASE-scaled column

View source: R/descale-by-mase.R

descale_by_maseR Documentation

Back-transform a MASE-scaled column

Description

descale_by_mase() back-transforms a group time series that has been scaled by a factor derived from the MASE error function.

Usage

descale_by_mase(.tbl, .value, scale_factors, ...)

Arguments

.tbl

tibble; data with a value (class: numeric) column and group (class: character) column(s)

.value

numeric; unquoted name of the column that contains the scaled numeric values

scale_factors

tibble; tibble extracted from the scale_factors attribute of the output of scale_by_mase(). Grouping columns should match those in .tbl. (See details)

...

character; one or more unquoted grouping columns

Details

Scaling a grouped time series can be helpful for global forecasting methods when using machine learning and deep learning algorithms. Scaling by MASE and using MASE as the error function is equivalent to to minimizing the MAE in the preprocessed time series.

The scale_factors tibble can be extracted by scale_factors <- attributes(mase_scaled_tbl)$scale_factors where mase_scaled_tbl is the output of scale_by_mase().

Value

The original tibble with the .value column back-transformed to the orginal scale.

References

Pablo Montero-Manso, Rob J. Hyndman, Principles and algorithms for forecasting groups of time series: Locality and globality, International Journal of Forecasting, 2021 link

Examples


library(dplyr, warn.conflicts = FALSE)

group_ts_tbl <- tsbox::ts_tbl(fpp2::arrivals)

head(group_ts_tbl)

new_tbl <- scale_by_mase(.tbl = group_ts_tbl, .value = value, id)

glimpse(new_tbl)

scale_factors <- attributes(new_tbl)$scale_factors

orig_tbl <- descale_by_mase(new_tbl, value, scale_factors, id)

head(orig_tbl)

ercbk/ebtools documentation built on Feb. 22, 2025, 1:51 p.m.