loss function

Computes Loss Function.

Computes Loss Function.

This function computes various loss functions for given realized values of time-series and a collection of forecasts.

loss(realized,evaluated,loss.type)

Arguments

  • realized: vector of the real values of the modelled time-series
  • evaluated: matrix of the forecasts, columns correspond to time index, rows correspond to different models
  • loss.type: method to compute the loss function, loss.type="SE" will use squared errors, loss.type="AE" will use absolute errors, loss.type="SPE" will use squred proportional error (useful if errors are heteroskedastic), loss.type="ASE" will use absolute scaled error, if loss.type will be specified as some numeric, then the function of type exp(loss.type*errors)-1-loss.type*errors will be used (useful when it is more costly to underpredict realized than to overpredict)

Returns

matrix with columns corresponding to time index and rows to different models

Examples

data(MDMforecasts) ts <- MDMforecasts$ts forecasts <- MDMforecasts$forecasts l <- loss(realized=ts,evaluated=forecasts,loss.type="SE")

References

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

Taylor, S. J., 2005. Asset Price Dynamics, Volatility, and Prediction, Princeton University Press.

Triacca, U., 2018. Comparing Predictive Accuracy of Two Forecasts, https://www.lem.sssup.it/phd/documents/Lesson19.pdf.