calculate_MASE: Calculate MASE values

Description Usage Arguments Value Examples

View source: R/HELPER_calculate_MASE.R

Description

calculate_MASE is a function to calculate the Mean Absolute Scaled Error (MASE) values for a specific forecast with a given horizon. To do this, the time series object that was used for training is reused to create a seasonal naive forecast, which is then used as a base line in the comparison with the specified set of fc_errors. This results in a set of scaled errors (the MASE values), which were proposed by Hyndman & Koehler (2006) as an alternative to using percentage errors when comparing forecast accuracy across series with different units. For more information, check out [this page](https://otexts.com/fpp2/accuracy.html).

Usage

1
calculate_MASE(ts_object_train, fc_error)

Arguments

ts_object_train

A time series object, which contains only the training data.

fc_error

A numeric vector, which corresponds to the forecast error values for which the MASE values need to be calculated.

Value

A numeric vector of MASE values

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
main_forecasting_table <- tstools::initialize_ts_forecast_data(
      data = dummy_gasprice,
      date_col = "year_month",
      col_of_interest = "gasprice",
      group_cols = c("state", "oil_company")
   ) %>%
   create_main_forecasting_table() %>%
   head(1) %>%
   add_fc_models_to_main_forecasting_table(
      periods_ahead = 12,
      fc_methods = c("linear")
   )
calculate_MASE(
   ts_object_train = main_forecasting_table$ts_object_train[[1]],
   fc_error = main_forecasting_table$fc_errors[[1]] %>% 
      dplyr::filter(fc_model == "fc_linear_trend_seasonal") %>% 
      dplyr::pull(fc_error)
)

ing-bank/tsforecast documentation built on Sept. 18, 2020, 9:40 a.m.