sperr_sf: Squared percentage error scoring function

View source: R/sperr_sf.R

sperr_sfR Documentation

Squared percentage error scoring function

Description

The function sperr_sf computes the squared percentage error scoring function when y materialises and x is the predictive \dfrac{\textnormal{E}_F [Y^{-1}]}{\textnormal{E}_F [Y^{-2}]} functional.

The squared percentage error scoring function is defined on p. 752 in Gneiting (2011).

Usage

sperr_sf(x, y)

Arguments

x

Predictive \dfrac{\textnormal{E}_F [Y^{-1}]}{\textnormal{E}_F [Y^{-2}]} 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 squared percentage error scoring function is defined by:

S(x, y) := ((x - y)/y)^{2}

Domain of function:

x > 0

y > 0

Range of function:

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

Value

Vector of squared percentage errors.

Note

For details on the squared percentage error scoring function, see Park and Stefanski (1998) and Gneiting (2011).

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

The squared percentage error scoring function is strictly \mathbb{F}-consistent for the \dfrac{\textnormal{E}_F [Y^{-1}]}{\textnormal{E}_F [Y^{-2}]} functional (Park and Stefanski 1998; Theorem 5 and eq. (11) on p. 752 in Gneiting 2011). \mathbb{F} is the family of probability distributions F for which \textnormal{E}_F[Y^{-1}] and \textnormal{E}_F[Y^{-2}] exist and are finite (Theorem 5 in Gneiting 2011).

References

Gneiting T (2011) Making and evaluating point forecasts. Journal of the American Statistical Association 106(494):746–762. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1198/jasa.2011.r10138")}.

Park H, Stefanski LA (1998) Relative-error prediction. Statistics and Probability Letters 40(3):227–236. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/S0167-7152(98)00088-1")}.

See Also

mspe

Examples

# Compute the squared percentage error scoring function.

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

df$squared_percentage_error <- sperr_sf(x = df$x, y = df$y)

print(df)

scoringfunctions documentation built on Aug. 30, 2026, 5:07 p.m.