I would like to extract the MASE (Hyndman et al., 2006) from the accuracy function ('forecast' package) in R.
I have 17 time series with the following hierarchical structure:
nodes <- list(2, c(7,7))
hierarchical <- hts(matrix_tseries, nodes, bnames = colnames_bottom, characters = c(1,1))
, where 'matrix_tseries' is a matrix that stores the 17 series.
I have then calculated the forecasts for each series and would like to extract the assessment metrics for the desired horizon:
fcast <- forecast(hierarchical, h = 35 ,level = c(80,95),
fmethod = "ets", method = "comb")
accuracy(fcast$bts[,1], val_matrix_tseries[,1], test=NULL, d=NULL, D=NULL)
, where 'val_matrix_tseries' is a matrix containing the actuals in the validation (out of sample) period.
Unfortunately this only produces ME, RMSE, MAE, MPE, MAPE but not MASE.
I've found a potential solution here but wasn't able to provide the historical data information in the way needed to calculate the scaling factor.
There is an
accuracy.gts
function to do this:Notes:
hts()
only requires the bottom level series. Hence, my example uses 14 series.