View source: R/descale-by-mase.R
descale_by_mase | R Documentation |
descale_by_mase()
back-transforms a group time series that has been scaled by a factor derived from the MASE error function.
descale_by_mase(.tbl, .value, scale_factors, ...)
.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 |
... |
character; one or more unquoted grouping columns |
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()
.
The original tibble with the .value
column back-transformed to the orginal scale.
Pablo Montero-Manso, Rob J. Hyndman, Principles and algorithms for forecasting groups of time series: Locality and globality, International Journal of Forecasting, 2021 link
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.