Learn R Programming

scoringfunctions (version 1.1)

relerr_sf: Relative error scoring function (MAE-PROP scoring function)

Description

The function relerr_sf computes the relative error scoring function when \(y\) materialises and \(x\) is the predictive \(\textnormal{med}^{(1)}(F)\) functional.

The relative error scoring function is defined in Table 1 in Gneiting (2011).

The relative error scoring function is referred to as MAE-PROP scoring function in eq. (13) in Patton (2011).

Usage

relerr_sf(x, y)

Value

Vector of relative errors.

Arguments

x

Predictive \(\textnormal{med}^{(1)}(F)\) functional (prediction). It can be a vector of length \(n\) (must have the same length as \(y\)).

y

Realisation (true value) of process. It can be a vector of length \(n\) (must have the same length as \(x\)).

Details

The relative error scoring function is defined by:

$$S(x, y) := |(x - y)/x|$$

Domain of function:

$$x > 0$$

$$y > 0$$

Range of function:

$$S(x, y) \geq 0, \forall x, y > 0$$

References

Gneiting T (2011) Making and evaluating point forecasts. Journal of the American Statistical Association 106(494):746--762. tools:::Rd_expr_doi("10.1198/jasa.2011.r10138").

Patton AJ (2011) Volatility forecast comparison using imperfect volatility proxies. Journal of Econometrics 160(1):246--256. tools:::Rd_expr_doi("10.1016/j.jeconom.2010.03.034").

Examples

Run this code
# Compute the relative error scoring function.

df <- data.frame(
    y = rep(x = 2, times = 3),
    x = 1:3
)

df$relative_error <- relerr_sf(x = df$x, y = df$y)

print(df)

Run the code above in your browser using DataLab