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(object, test, levels, ..., f = NULL)

Arguments

object

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

f

Deprecated. Please use object instead.

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

Author

Rob J Hyndman and Earo Wang

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.5175864  0.1288857 0.3887008  0.06573302   0.06315266 0.1155213
#> RMSE  0.6067434  0.1501689 0.4582254  0.08267622   0.06873023 0.1246662
#> MAE   0.5175864  0.1288857 0.3887008  0.06984219   0.06315266 0.1155213
#> MAPE 26.8125025  4.3851653 7.8647359  2.70732415  17.45099176 8.2711056
#> MPE  26.8125025 -4.3851653 7.8647359 -2.55987709 -17.45099176 8.2711056
#> MASE  1.6332610  0.7231180 2.8031103  0.46325019   2.29893333 2.5346010
#>            B40        A10A        A10B         A10C         A20A          A20B
#> ME   0.2731795  0.09542307 -0.09835074   0.06866069   0.05654830   0.006604366
#> RMSE 0.3372614  0.10595132  0.10365079   0.07887357   0.06022321   0.011265235
#> MAE  0.2731795  0.09542307  0.09835074   0.06866069   0.05654830   0.008816632
#> MAPE 7.6660385  7.64346709 12.24476912  12.74890041  18.43994906  22.297766518
#> MPE  7.6660385 -7.64346709 12.24476912 -12.74890041 -18.43994906 -20.013326734
#> MASE 2.9345749  0.90325116  3.04328419   5.36231602   4.45477238   0.596663726
#>             B30A       B30B       B30C       B40A       B40B
#> ME    0.03933843 0.03369417 0.04248867 0.03227470  0.2409048
#> RMSE  0.04155152 0.03679464 0.04710692 0.04358476  0.3257019
#> MAE   0.03933843 0.03369417 0.04248867 0.03895166  0.2409048
#> MAPE 13.24251118 7.37361308 6.59428670 2.91406938 10.7931448
#> MPE  13.24251118 7.37361308 6.59428670 2.43285014 10.7931448
#> MASE  1.61097593 3.74724838 3.49213005 0.75045087  5.8492447
accuracy(fcasts, test, levels = 1)
#>               A         B
#> ME    0.1288857 0.3887008
#> RMSE  0.1501689 0.4582254
#> MAE   0.1288857 0.3887008
#> MAPE  4.3851653 7.8647359
#> MPE  -4.3851653 7.8647359
#> MASE  0.7231180 2.8031103