Returns a range of summary measures of the forecast accuracy. The function measures out-of-sample forecast accuracy based on (holdout data - forecasts) and in-sample accuracy at the bottom level when setting keep.fitted = TRUE in the forecast.gts. All measures are defined and discussed in Hyndman and Koehler (2006).

# S3 method for gts
accuracy(f, test, levels, ...)

Arguments

f

An object of class gts, containing the forecasted hierarchical or grouped time series. In-sample accuracy at the bottom level returns when test is missing.

test

An object of class gts, containing the holdout hierarchical time series

levels

Return the specified level(s), when carrying out out-of-sample

...

Extra arguments to be ignored

Value

Matrix giving forecast accuracy measures.

ME

Mean Error

RMSE

Root Mean Square Error

MAE

Mean Absolute Error

MAPE

Mean Absolute Percentage Error

MPE

Mean Percentage Error

MASE

Mean Absolute Scaled Error

Details

MASE calculation is scaled using MAE of in-sample naive forecasts for non-seasonal time series, and in-sample seasonal naive forecasts for seasonal time series.

References

R. J. Hyndman and A. Koehler (2006), Another look at measures of forecast accuracy, International Journal of Forecasting, 22, 679-688.

See also

hts, plot.gts, forecast.gts, accuracy

Examples

data <- window(htseg2, start = 1992, end = 2002) test <- window(htseg2, start = 2003) fcasts <- forecast(data, h = 5, method = "bu") accuracy(fcasts, test)
#> Total A B A10 A20 B30 #> ME 0.4347799 0.1281219 0.3066580 0.06567732 0.06244457 0.04230739 #> RMSE 0.5176613 0.1493112 0.3703306 0.08262583 0.06792688 0.04460145 #> MAE 0.4347799 0.1281219 0.3066580 0.06980285 0.06244457 0.04230739 #> MAPE 22.2794874 4.3592538 6.1831690 2.70578591 17.25232137 3.03986894 #> MPE 22.2794874 -4.3592538 6.1831690 -2.55775193 -17.25232137 3.03986894 #> MASE 1.3719622 0.7188327 2.2114600 0.46298924 2.27315679 0.92824774 #> B40 A10A A10B A10C A20A A20B #> ME 0.2643506 0.09542307 -0.09840644 0.06866069 0.05654830 0.005896274 #> RMSE 0.3296180 0.10595132 0.10370694 0.07887357 0.06022321 0.010578047 #> MAE 0.2643506 0.09542307 0.09840644 0.06866069 0.05654830 0.008279905 #> MAPE 7.4056459 7.64346709 12.25168527 12.74890041 18.43994914 20.877458842 #> MPE 7.4056459 -7.64346709 12.25168527 -12.74890041 -18.43994914 -18.416062568 #> MASE 2.8397323 0.90325116 3.04500770 5.36231602 4.45477240 0.560340854 #> B30A B30B B30C B40A B40B #> ME -0.03387545 0.03369417 0.04248867 0.02344581 0.2409048 #> RMSE 0.04072855 0.03679464 0.04710692 0.03797857 0.3257019 #> MAE 0.03452726 0.03369417 0.04248867 0.03416726 0.2409048 #> MAPE 11.52223630 7.37361306 6.59428670 2.54862422 10.7931448 #> MPE -11.28938443 7.37361306 6.59428670 1.77591212 10.7931448 #> MASE 1.41395014 3.74724837 3.49213005 0.65827359 5.8492447
accuracy(fcasts, test, levels = 1)
#> A B #> ME 0.1281219 0.3066580 #> RMSE 0.1493112 0.3703306 #> MAE 0.1281219 0.3066580 #> MAPE 4.3592538 6.1831690 #> MPE -4.3592538 6.1831690 #> MASE 0.7188327 2.2114600