Learn R Programming

lfl (version 1.4.2)

errors: Compute forecast errors

Description

Compute Symmetric Mean Absolute Percentage Error (SMAPE), Mean Absolute Scaled Error (MASE), and Root Mean Squared Error (RMSE) from forecasted and validation data.

Usage

smape(forecast, validation)
mase(forecast, validation)
rmse(forecast, validation)

Arguments

forecast

A numeric vector of predicted or forecasted values. Its length must be the same as the length of the validation argument.

validation

A numeric vector of actual (real) values being forecasted. Its length must be the same as the length of the forecast argument.

Value

A numeric value.

Details

The function compute various error measures of the forecasts. Let \(v_i\), \(f_i\) be the \(i\)-th elements of validation or forecast, respectively, and \(n\) be the length of validation. Then:

  • \(SMAPE = 1/n \sum_{i=1}^n (2 |f_i - v_i|) / (|f_i| + |v_i|)\)

  • \(MASE = (\sum_{i=1}^n |v_i - f_i|) / (n/(n-1) * \sum_{i=2}^n |v_i - v_{i-1}|)\)

  • \(RMSE = sqrt(1/n * \sum_{i=1}^n (v_i - f_i)^2)\)

See Also

evalfrbe, frbe