aperr_sf {scoringfunctions}R Documentation

Absolute percentage error scoring function

Description

The function aperr_sf computes the absolute percentage error scoring function when y materializes and x is the predictive \textnormal{med}^{(-1)}(F) functional.

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

Usage

aperr_sf(x, y)

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

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

Details

The absolute percentage error scoring function is defined by:

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

Domain of function:

x > 0

y > 0

Range of function:

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

Value

Vector of absolute percentage errors.

Note

For details on the absolute percentage error scoring function, see Gneiting (2011).

The \beta-median functional, \textnormal{med}^{(\beta)}(F) is the median of a probability distribution whose density is proportional to y^\beta f(y), where f is the density of the probability distribution F of y (Gneiting 2011).

The absolute percentage error scoring function is negatively oriented (i.e. the smaller, the better).

The absolute percentage error scoring function is strictly consistent for the \textnormal{med}^{(-1)}(F) functional relative to the family \mathbb{F} of potential probability distributions (whose densities are proportional to y^{-1} f(y), where f is the density of the probability distribution F for the future y) for which the first moment exists and is finite (see Theorems 5 and 9 in Gneiting 2011).

References

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

Examples

# Compute the absolute percentage error scoring function.

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

df$absolute_percentage_error <- aperr_sf(x = df$x, y = df$y)

print(df)

[Package scoringfunctions version 0.0.6 Index]