gpl1_sf: Generalized piecewise linear power scoring function (type 1)

View source: R/gpl1_sf.R

gpl1_sfR Documentation

Generalized piecewise linear power scoring function (type 1)

Description

The function gpl1_sf computes the generalized piecewise linear power scoring function at a specific level p for g(x) = x^b/|b|, b > 0, when y materialises and x is the predictive quantile at level p.

The generalized piecewise linear power scoring function is defined by eq. (25) in Gneiting (2011) and the form implemented here for the specific g(x) is defined by eq. (26) in Gneiting (2011).

Usage

gpl1_sf(x, y, p, b)

Arguments

x

Predictive quantile (prediction) at level p. 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).

p

It can be a vector of length n (must have the same length as y).

b

It can be a vector of length n (must have the same length as y).

Details

The generalized piecewise linear power scoring function (type 1) is defined by:

S(x, y, p, b) := (1/b) (\textbf{1} \lbrace x \geq y \rbrace - p) (x^b - y^b)

or equivalently

S(x, y, p, b) := (1/b) (p | \max \lbrace -(x^b - y^b), 0 \rbrace | + (1 - p) | \max \lbrace x^b - y^b, 0 \rbrace |)

Domain of function:

x > 0

y > 0

0 < p < 1

b > 0

Range of function:

S(x, y, p, b) \geq 0, \forall x, y > 0, p \in (0, 1), b > 0

Value

Vector of generalized piecewise linear power losses.

Note

The implemented function is named type 1 because it corresponds to a specific type of g(x) of the general form of the generalized piecewise linear power scoring function defined by eq. (25) in Gneiting (2011).

Eq. (26) in Gneiting (2011) is given for b \in \mathbb{R} \setminus \lbrace 0 \rbrace. The implementation herein deliberately restricts the domain to b > 0, where |b| = b, because g(x) = x^b/|b| is strictly increasing only for b > 0, as required by Theorem 9(b) in Gneiting (2011). The two forms given above are equivalent on b > 0 only; they disagree in sign for b < 0, which is outside the domain of the function. Because no argument validation is performed, a call with b < 0 returns a value rather than an error.

For the definition of quantiles, see Koenker and Bassett Jr (1978).

The generalized piecewise linear power scoring function is negatively oriented (i.e. the smaller, the better).

The herein implemented generalized piecewise linear power scoring function is strictly \mathbb{F}-consistent for the p-quantile functional. \mathbb{F} is the family of probability distributions F for which \textnormal{E}_F[Y^b] exists and is finite (Thomson 1979; Saerens 2000; 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")}.

Koenker R, Bassett Jr G (1978) Regression quantiles. Econometrica 46(1):33–50. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2307/1913643")}.

Saerens M (2000) Building cost functions minimizing to some summary statistics. IEEE Transactions on Neural Networks 11(6):1263–1271. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1109/72.883416")}.

Thomson W (1979) Eliciting production possibilities from a well-informed manager. Journal of Economic Theory 20(3):360–380. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/0022-0531(79)90042-5")}.

See Also

gpl1_rs, quantile_if

Examples

# Compute the generalized piecewise linear scoring function (type 1).

df <- data.frame(
    y = rep(x = 2, times = 6),
    x = c(1, 2, 3, 1, 2, 3),
    p = c(rep(x = 0.05, times = 3), rep(x = 0.95, times = 3)),
    b = rep(x = 2, times = 6)
)

df$gpl1_penalty <- gpl1_sf(x = df$x, y = df$y, p = df$p, b = df$b)

print(df)

# Equivalence of generalized piecewise linear scoring function (type 1) and
# asymmetric piecewise linear scoring function (quantile scoring function), when
# b = 1.

set.seed(12345)

n <- 100

x <- runif(n = n, min = 0, max = 20)
y <- runif(n = n, min = 0, max = 20)
p <- runif(n = n, min = 0, max = 1)
b <- rep(x = 1, times = n)

u <- gpl1_sf(x = x, y = y, p = p, b = b)
v <- quantile_sf(x = x, y = y, p = p)

max(abs(u - v))

# Equivalence of generalized piecewise linear scoring function (type 1) and
# MAE-SD scoring function, when p = 1/2 and b = 1/2.

set.seed(12345)

n <- 100

x <- runif(n = n, min = 0, max = 20)
y <- runif(n = n, min = 0, max = 20)
p <- rep(x = 0.5, times = n)
b <- rep(x = 1/2, times = n)

u <- gpl1_sf(x = x, y = y, p = p, b = b)
v <- maesd_sf(x = x, y = y)

max(abs(u - v))

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