Package 'scoringfunctions'

Title: A Collection of Loss Functions for Assessing Point Forecasts
Description: Implements multiple consistent scoring functions (Gneiting T (2011) <doi:10.1198/jasa.2011.r10138>) for assessing point forecasts and point predictions. Detailed documentation of scoring functions' properties is included for facilitating interpretation of results.
Authors: Hristos Tyralis [aut, cre] , Georgia Papacharalampous [aut]
Maintainer: Hristos Tyralis <[email protected]>
License: GPL-3
Version: 1.1
Built: 2025-03-03 18:44:25 UTC
Source: https://github.com/cran/scoringfunctions

Help Index


Overview of the functions in the scoringfunctions package

Description

The scoringfunctions package implements consistent scoring (loss) functions and identification functions

Details

The package functions are categorized into the following classes:

  • 1. Scoring functions

  • 1.1. Consistent scoring functions for one-dimensional functionals

  • 1.2. Consistent scoring functions for two-dimensional functionals

  • 1.3. Consistent scoring functions for multi-dimensional functionals

  • 2. Realised (average) score functions

  • 2.1 Realised (average) score functions for one-dimensional functionals

  • 3. Skill score functions

  • 3.1 Skill score functions for one-dimensional functionals

  • 4. Identification functions

  • 4.1. Identification functions for one-dimensional functionals

  • 4.2. Identification functions for two-dimensional functionals

  • 5. Functions for sample levels

  • 6. Supporting functions

.

1. Scoring functions

1.1. Consistent scoring functions for one-dimensional functionals

1.1.1. Consistent scoring functions for the mean\textit{1.1.1. Consistent scoring functions for the mean}

bregman1_sf: Bregman scoring function (type 1)

bregman2_sf: Bregman scoring function (type 2, Patton scoring function)

bregman3_sf: Bregman scoring function (type 3, QLIKE scoring function)

bregman4_sf: Bregman scoring function (type 4, Patton scoring function)

serr_sf: Squared error scoring function

1.1.2. Consistent scoring functions for expectiles\textit{1.1.2. Consistent scoring functions for expectiles}

expectile_sf: Asymmetric piecewise quadratic scoring function (expectile scoring function, expectile loss function)

1.1.3. Consistent scoring functions for the median\textit{1.1.3. Consistent scoring functions for the median}

aerr_sf: Absolute error scoring function

maelog_sf: MAE-LOG scoring function

maesd_sf: MAE-SD scoring function

1.1.4. Consistent scoring functions for quantiles\textit{1.1.4. Consistent scoring functions for quantiles}

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

gpl2_sf: Generalized piecewise linear power scoring function (type 2)

quantile_sf: Asymmetric piecewise linear scoring function (quantile scoring function, quantile loss function)

1.1.5. Consistent scoring functions for Huber functionals\textit{1.1.5. Consistent scoring functions for Huber functionals}

ghuber_sf: Generalized Huber scoring function

huber_sf: Huber scoring function

1.1.6. Consistent scoring functions for other functionals\textit{1.1.6. Consistent scoring functions for other functionals}

aperr_sf: Absolute percentage error scoring function

bmedian_sf: β\beta-median scoring function

linex_sf: LINEX scoring function

lqmean_sf: LqL_q-mean scoring function

lqquantile_sf: LqL_q-quantile scoring function

nmoment_sf: nn-th moment scoring function

obsweighted_sf: Observation-weighted scoring function

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

serrexp_sf: Squared error exp scoring function

serrlog_sf: Squared error log scoring function

serrpower_sf: Squared error of power transformations scoring function

serrsq_sf: Squared error of squares scoring function

sperr_sf: Squared percentage error scoring function

srelerr_sf: Squared relative error scoring function

1.2. Consistent scoring functions for two-dimensional functionals

interval_sf: Interval scoring function (Winkler scoring function)

mv_sf: Mean - variance scoring function

1.3. Consistent scoring functions for multi-dimensional functionals

errorspread_sf: Error - spread scoring function

2. Realised (average) score functions

2.1. Realised (average) score functions for one-dimensional functionals

2.1.1. Realised (average) score functions for the mean\textit{2.1.1. Realised (average) score functions for the mean}

mse: Mean squared error (MSE)

2.1.2. Realised (average) score functions for expectiles\textit{2.1.2. Realised (average) score functions for expectiles}

expectile_rs: Realised expectile score

2.1.3. Realised (average) score functions for the median\textit{2.1.3. Realised (average) score functions for the median}

mae: Mean absolute error (MAE)

2.1.4. Realised (average) score functions for quantiles\textit{2.1.4. Realised (average) score functions for quantiles}

quantile_rs: Realised quantile score

2.1.5. Realised (average) score functions for Huber functionals\textit{2.1.5. Realised (average) score functions for Huber functionals}

huber_rs: Mean Huber score

2.1.6. Realised (average) score functions for other functionals\textit{2.1.6. Realised (average) score functions for other functionals}

mape: Mean absolute percentage error (MAPE)

mre: Mean relative error (MRE)

mspe: Mean squared percentage error (MSPE)

msre: Mean squared relative error (MSRE)

3. Skill score functions

3.1. Skill score functions for one-dimensional functionals

3.1.1. Skill score functions for the mean\textit{3.1.1. Skill score functions for the mean}

nse: Nash-Sutcliffe efficiency (NSE)

4. Identification functions

4.1. Identification functions for one-dimensional functionals

expectile_if: Expectile identification function

hubermean_if: Huber mean identification function

huberquantile_if: Huber quantile identification function

mean_if: Mean identification function

meanlog_if: Log-transformed identification function

nmoment_if: nn-th moment identification function

quantile_if: Quantile identification function

4.2. Identification functions for two-dimensional functionals

mv_if: Mean - variance identification function

5. Functions for sample levels

quantile_level: Sample quantile level function

6. Supporting functions

capping_function: Capping function


Absolute error scoring function

Description

The function aerr_sf computes the absolute error scoring function when yy materialises and xx is the predictive median functional.

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

Usage

aerr_sf(x, y)

Arguments

x

Predictive median functional (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

Details

The absolute error scoring function is defined by:

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

Domain of function:

xRx \in \mathbb{R}

yRy \in \mathbb{R}

Range of function:

S(x,y)0,x,yRS(x, y) \geq 0, \forall x, y \in \mathbb{R}

Value

Vector of absolute errors.

Note

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

The median functional is the median of the probability distribution FF of yy (Gneiting 2011).

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

The absolute error scoring function is strictly F\mathbb{F}-consistent for the median functional. F\mathbb{F} is the family of probability distributions FF for which EF[Y]\textnormal{E}_F[Y] exists and is finite (Raiffa and Schlaifer 1961, p.196; Ferguson 1967, p.51; Thomson 1979; Saerens 2000; Gneiting 2011).

References

Ferguson TS (1967) Mathematical Statistics: A Decision-Theoretic Approach. Academic Press, New York.

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

Raiffa H,Schlaifer R (1961) Applied Statistical Decision Theory. Colonial Press, Clinton.

Saerens M (2000) Building cost functions minimizing to some summary statistics. IEEE Transactions on Neural Networks 11(6):1263–1271. doi:10.1109/72.883416.

Thomson W (1979) Eliciting production possibilities from a well-informed manager. Journal of Economic Theory 20(3):360–380. doi:10.1016/0022-0531(79)90042-5.

Examples

# Compute the absolute error scoring function.

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

df$absolute_error <- aerr_sf(x = df$x, y = df$y)

print(df)

Absolute percentage error scoring function

Description

The function aperr_sf computes the absolute percentage error scoring function when yy materialises and xx is the predictive med(1)(F)\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 med(1)(F)\textnormal{med}^{(-1)}(F) functional (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

Details

The absolute percentage error scoring function is defined by:

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

Domain of function:

x>0x > 0

y>0y > 0

Range of function:

S(x,y)0,x,y>0S(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, med(β)(F)\textnormal{med}^{(\beta)}(F) is the median of a probability distribution whose density is proportional to yβf(y)y^\beta f(y), where ff is the density of the probability distribution FF of yy (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 F(w)\mathbb{F}^{(w)}-consistent for the med(1)(F)\textnormal{med}^{(-1)}(F) functional. F\mathbb{F} is the family of probability distributions for which EF[Y]\textnormal{E}_F[Y] exists and is finite. F(w)\mathbb{F}^{(w)} is the subclass of probability distributions in F\mathbb{F}, which are such that w(y)f(y)w(y) f(y), w(y)=1/yw(y) = 1/y has finite integral over (0,)(0, \infty), and the probability distribution F(w)F^{(w)} with density proportional to w(y)f(y)w(y) f(y) belongs to F\mathbb{F} (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)

β\beta-median scoring function

Description

The function bmedian_sf computes the β\beta-median scoring function when yy materialises and xx is the predictive med(β)(F)\textnormal{med}^{(\beta)}(F) functional.

The β\beta-median scoring function is defined in eq. (4) in Gneiting (2011).

Usage

bmedian_sf(x, y, b)

Arguments

x

Predictive med(β)(F)\textnormal{med}^{(\beta)}(F) functional (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

b

It can be a vector of length nn (must have the same length as yy).

Details

The β\beta-median scoring function is defined by:

S(x,y,b):=1(y/x)bS(x, y, b) := |1 - (y/x)^b|

Domain of function:

x>0x > 0

y>0y > 0

b0b \neq 0

Range of function:

S(x,y,b)0,x,y>0,b0S(x, y, b) \geq 0, \forall x, y > 0, b \neq 0

Value

Vector of β\beta-median losses.

Note

For details on the β\beta-median scoring function, see Gneiting (2011).

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

The β\beta-median scoring function is negatively oriented (i.e. the smaller, the better).

The β\beta-median scoring function is strictly F(w)\mathbb{F}^{(w)}-consistent for the med(β)(F)\textnormal{med}^{(\beta)}(F) functional. F\mathbb{F} is the family of probability distributions for which EF[Y]\textnormal{E}_F[Y] exists and is finite. F(w)\mathbb{F}^{(w)} is the subclass of probability distributions in F\mathbb{F}, which are such that w(y)f(y)w(y) f(y), w(y)=yβw(y) = y^\beta has finite integral over (0,)(0, \infty), and the probability distribution F(w)F^{(w)} with density proportional to w(y)f(y)w(y) f(y) belongs to F\mathbb{F} (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 bmedian scoring function.

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

df$bmedian_error <- bmedian_sf(x = df$x, y = df$y, b = df$b)

print(df)

Bregman scoring function (type 1)

Description

The function bregman1_sf computes the Bregman scoring function when yy materialises and xx is the predictive mean functional.

The Bregman scoring function is defined by eq. (18) in Gneiting (2011) and the form implemented here for ϕ(x)=xa\phi(x) = |x|^a is defined by eq. (19) in Gneiting (2011).

Usage

bregman1_sf(x, y, a)

Arguments

x

Predictive mean functional (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

a

It can be a vector of length nn (must have the same length as yy).

Details

The Bregman scoring function (type 1) is defined by:

S(x,y,a):=yaxaasign(x)xa1(yx)S(x, y, a) := |y|^a - |x|^a - a \textnormal{sign}(x) |x|^{a - 1} (y - x)

Domain of function:

xRx \in \mathbb{R}

yRy \in \mathbb{R}

a>1a > 1

Range of function:

S(x,y,a)0,x,yR,a>1S(x, y, a) \geq 0, \forall x, y \in \mathbb{R}, a > 1

Value

Vector of Bregman losses.

Note

The implemented function is denoted as type 1 since it corresponds to a specific type of ϕ(x)\phi(x) of the general form of the Bregman scoring function defined by eq. (18) in Gneiting (2011).

For details on the Bregman scoring function, see Savage (1971), Banerjee et al. (2005) and Gneiting (2011).

The mean functional is the mean EF[Y]\textnormal{E}_F[Y] of the probability distribution FF of yy (Gneiting 2011).

The Bregman scoring function is negatively oriented (i.e. the smaller, the better).

The herein implemented Bregman scoring function is strictly F\mathbb{F}-consistent for the mean functional. F\mathbb{F} is the family of probability distributions for which EF[Y]\textnormal{E}_F[Y] and EF[Ya]\textnormal{E}_F[|Y|^a] exist and are finite (Savage 1971; Gneiting 2011).

References

Banerjee A, Guo X, Wang H (2005) On the optimality of conditional expectation as a Bregman predictor. IEEE Transactions on Information Theory 51(7):2664–2669. doi:10.1109/TIT.2005.850145.

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

Savage LJ (1971) Elicitation of personal probabilities and expectations. Journal of the American Statistical Association 66(337):783–810. doi:10.1080/01621459.1971.10482346.

Examples

# Compute the Bregman scoring function (type 1).

df <- data.frame(
    y = rep(x = 0, times = 7),
    x = c(-3, -2, -1, 0, 1, 2, 3),
    a = rep(x = 3, times = 7)
)

df$bregman1_penalty <- bregman1_sf(x = df$x, y = df$y, a = df$a)

print(df)

# Equivalence of Bregman scoring function (type 1) and squared error scoring
# function, when a = 2.

set.seed(12345)

n <- 100

x <- runif(n, -20, 20)
y <- runif(n, -20, 20)
a <- rep(x = 2, times = n)

u <- bregman1_sf(x = x, y = y, a = a)

v <- serr_sf(x = x, y = y)

max(abs(u - v)) # values are slightly higher than 0 due to rounding error
min(abs(u - v))

Bregman scoring function (type 2, Patton scoring function)

Description

The function bregman2_sf computes the Bregman scoring function when yy materialises and xx is the predictive mean functional.

The Bregman scoring function is defined by eq. (18) in Gneiting (2011) and the form implemented here for ϕ(x)=1b(b1)xb\phi(x) = \dfrac{1}{b (b - 1)} x^b, bR{0,1}b \in \R \setminus \lbrace 0, 1 \rbrace is defined by eq. (20) in Gneiting (2011).

Usage

bregman2_sf(x, y, b)

Arguments

x

Predictive mean functional (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

b

It can be a vector of length nn (must have the same length as yy).

Details

The Bregman scoring function (type 2) is defined by:

S(x,y,b):=1b(b1)(ybxb)1b1xb1(yx)S(x, y, b) := \dfrac{1}{b (b - 1)} (y^b - x^b) - \dfrac{1}{b - 1} x^{b - 1} (y - x)

Domain of function:

x>0x > 0

y>0y > 0

bR{0,1}b \in \mathbb{R} \setminus \lbrace 0, 1 \rbrace

Range of function:

S(x,y,b)0,x,y>0,bR{0,1}S(x, y, b) \geq 0, \forall x, y > 0, b \in \mathbb{R} \setminus \lbrace 0, 1 \rbrace

Value

Vector of Bregman losses.

Note

The implemented function is denoted as type 2 since it corresponds to a specific type of ϕ(x)\phi(x) of the general form of the Bregman scoring function defined by eq. (18) in Gneiting (2011).

For details on the Bregman scoring function, see Savage (1971), Banerjee et al. (2005) and Gneiting (2011). For details on the specific form implemented here, see Patton (2011).

The mean functional is the mean EF[Y]\textnormal{E}_F[Y] of the probability distribution FF of yy (Gneiting 2011).

The Bregman scoring function is negatively oriented (i.e. the smaller, the better).

The herein implemented Bregman scoring function is strictly F\mathbb{F}-consistent for the mean functional. F\mathbb{F} is the family of probability distributions FF for which EF[Y]\textnormal{E}_F[Y] and EF[1b(b1)Yb]\textnormal{E}_F[\dfrac{1}{b (b - 1)} Y^b] exist and are finite (Savage 1971; Gneiting 2011).

References

Banerjee A, Guo X, Wang H (2005) On the optimality of conditional expectation as a Bregman predictor. IEEE Transactions on Information Theory 51(7):2664–2669. doi:10.1109/TIT.2005.850145.

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

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

Savage LJ (1971) Elicitation of personal probabilities and expectations. Journal of the American Statistical Association 66(337):783–810. doi:10.1080/01621459.1971.10482346.

Examples

# Compute the Bregman scoring function (type 2).

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

df$bregman2_penalty <- bregman2_sf(x = df$x, y = df$y, b = df$b)

print(df)

# The Bregman scoring function (type 2) is half the squared error scoring
# function, when b = 2.

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

df$bregman2_penalty <- bregman2_sf(x = df$x, y = df$y, b = df$b)

df$squared_error <- serr_sf(x = df$x, y = df$y)

df$ratio <- df$bregman2_penalty/df$squared_error

print(df)


# When a = b > 1 the Bregman scoring function (type 2) coincides with the
# Bregman scoring function (type 1) up to a multiplicative constant.

df <- data.frame(
    y = rep(x = 5.5, times = 10),
    x = 1:10,
    b = rep(x = c(3, 4), each = 5)
)

df$bregman2_penalty <- bregman2_sf(x = df$x, y = df$y, b = df$b)

df$bregman1_penalty <- bregman1_sf(x = df$x, y = df$y, a = df$b)

df$ratio <- df$bregman2_penalty/df$bregman1_penalty

print(df)

Bregman scoring function (type 3, QLIKE scoring function)

Description

The function bregman3_sf computes the Bregman scoring function when yy materialises and xx is the predictive mean functional.

The Bregman scoring function is defined by eq. (18) in Gneiting (2011) and the form implemented here for ϕ(x)=log(x)\phi(x) = -\log(x) is defined by eq. (20) in Gneiting (2011).

Usage

bregman3_sf(x, y)

Arguments

x

Predictive mean functional (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

Details

The Bregman scoring function (type 3) is defined by:

S(x,y):=(y/x)log(y/x)1S(x, y) := (y/x) - \log(y/x) - 1

Domain of function:

x>0x > 0

y>0y > 0

Range of function:

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

Value

Vector of Bregman losses.

Note

The implemented function is denoted as type 3 since it corresponds to a specific type of ϕ(x)\phi(x) of the general form of the Bregman scoring function defined by eq. (18) in Gneiting (2011).

For details on the Bregman scoring function, see Savage (1971), Banerjee et al. (2005) and Gneiting (2011). For details on the specific form implemented here, see the QLIKE scoring function in Patton (2011).

The mean functional is the mean EF[Y]\textnormal{E}_F[Y] of the probability distribution FF of yy (Gneiting 2011).

The Bregman scoring function is negatively oriented (i.e. the smaller, the better).

The herein implemented Bregman scoring function is strictly F\mathbb{F}-consistent for the mean functional. F\mathbb{F} is the family of probability distributions FF for which EF[Y]\textnormal{E}_F[Y] and EF[log(Y)]\textnormal{E}_F[\log(Y)] exist and are finite (Savage 1971; Gneiting 2011).

References

Banerjee A, Guo X, Wang H (2005) On the optimality of conditional expectation as a Bregman predictor. IEEE Transactions on Information Theory 51(7):2664–2669. doi:10.1109/TIT.2005.850145.

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

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

Savage LJ (1971) Elicitation of personal probabilities and expectations. Journal of the American Statistical Association 66(337):783–810. doi:10.1080/01621459.1971.10482346.

Examples

# Compute the Bregman scoring function (type 3, QLIKE scoring function).

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

df$bregman3_penalty <- bregman3_sf(x = df$x, y = df$y)

print(df)

Bregman scoring function (type 4, Patton scoring function)

Description

The function bregman4_sf computes the Bregman scoring function when yy materialises and xx is the predictive mean functional.

The Bregman scoring function is defined by eq. (18) in Gneiting (2011) and the form implemented here for ϕ(x)=xlog(x)\phi(x) = x \log(x) is defined by eq. (20) in Gneiting (2011).

Usage

bregman4_sf(x, y)

Arguments

x

Predictive mean functional (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

Details

The Bregman scoring function (type 4) is defined by:

S(x,y):=ylog(y/x)y+xS(x, y) := y \log(y/x) - y + x

Domain of function:

x>0x > 0

y>0y > 0

Range of function:

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

Value

Vector of Bregman losses.

Note

The implemented function is denoted as type 4 since it corresponds to a specific type of ϕ(x)\phi(x) of the general form of the Bregman scoring function defined by eq. (18) in Gneiting (2011).

For details on the Bregman scoring function, see Savage (1971), Banerjee et al. (2005) and Gneiting (2011). For details on the specific form implemented here, see Patton (2011).

The mean functional is the mean EF[Y]\textnormal{E}_F[Y] of the probability distribution FF of yy (Gneiting 2011).

The Bregman scoring function is negatively oriented (i.e. the smaller, the better).

The herein implemented Bregman scoring function is strictly F\mathbb{F}-consistent for the mean functional. F\mathbb{F} is the family of probability distributions FF for which EF[Y]\textnormal{E}_F[Y] and EF[Ylog(Y)]\textnormal{E}_F[Y \log(Y)] exist and are finite (Savage 1971; Gneiting 2011).

References

Banerjee A, Guo X, Wang H (2005) On the optimality of conditional expectation as a Bregman predictor. IEEE Transactions on Information Theory 51(7):2664–2669. doi:10.1109/TIT.2005.850145.

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

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

Savage LJ (1971) Elicitation of personal probabilities and expectations. Journal of the American Statistical Association 66(337):783–810. doi:10.1080/01621459.1971.10482346.

Examples

# Compute the Bregman scoring function (type 4).

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

df$bregman4_penalty <- bregman4_sf(x = df$x, y = df$y)

print(df)

Capping function

Description

The function capping_function computes the value of the capping function, defined in Taggart (2022), p.205.

It is used by the generalized Huber loss function among others (see Taggart 2022).

Usage

capping_function(t, a, b)

Arguments

t

It can be a vector of length nn.

a

It can be a vector of length nn (must have the same length as tt).

b

It can be a vector of length nn (must have the same length as tt).

Details

The capping function κa,b(t)\kappa_{a,b}(t) is defined by:

κa,b(t):=max{min{t,b},a}\kappa_{a,b}(t) := \max \lbrace \min \lbrace t,b \rbrace, -a \rbrace

or equivalently,

κa,b(t):={a,tat,a<tbb,t>b\kappa_{a,b}(t) := \left\{ \begin{array}{ll} -a, & t \leq -a\\ t, & -a < t \leq b\\ b, & t > b \end{array} \right.

Domain of function:

tRt \in \mathbb{R}

a0a \geq 0

b0b \geq 0

Value

Vector of values of the capping function.

Note

For the definition of the capping function, see Taggart (2022), p.205.

References

Taggart RJ (2022) Point forecasting and forecast evaluation with generalized Huber loss. Electronic Journal of Statistics 16:201–231. doi:10.1214/21-EJS1957.

Examples

# Compute the capping function.

df <- data.frame(
    t = c(1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 2.5, 2.5, 3.5, 3.5),
    a = c(0, 0, 0, 0, Inf, Inf, Inf, Inf, 2, 3, 2, 3, 2, 3),
    b = c(0, 0, Inf, Inf, 0, 0, Inf, Inf, 3, 2, 3, 2, 3, 2)
)

df$cf <- capping_function(t = df$t, a = df$a, b = df$b)

print(df)

Error - spread scoring function

Description

The function errorspread_sf computes the error - spread scoring function, when yy materialises, x1x_1 is the predictive mean, x2x_2 is the predictive variance and x3x_3 is the predictive skewness.

The error - spread scoring function is defined by eq. (14) in Christensen et al. (2015).

Usage

errorspread_sf(x1, x2, x3, y)

Arguments

x1

Predictive mean (prediction). It can be a vector of length nn (must have the same length as yy).

x2

Predictive variance (prediction). It can be a vector of length nn (must have the same length as yy).

x3

Predictive skewness (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as x1x_1).

Details

The error - spread scoring function is defined by:

S(x1,x2,x3,y):=(x2(x1y)2(x1y)x21/2x3)2S(x_1, x_2, x_3, y) := (x_2 - (x_1 - y)^2 - (x_1 - y) x_2^{1/2} x_3)^2

Domain of function:

x1Rx_1 \in \mathbb{R}

x2>0x_2 > 0

x3Rx_3 \in \mathbb{R}

yRy \in \mathbb{R}

Value

Vector of error - spread losses.

Note

The mean functional is the mean EF[Y]\textnormal{E}_F[Y] of the probability distribution FF of yy (Christensen et al. 2015).

The variance functional is the variance VarF[Y]:=EF[Y2](EF[Y])2\textnormal{Var}_F[Y] := \textnormal{E}_F[Y^2] - (\textnormal{E}_F[Y])^{2} of the probability distribution FF of yy (Christensen et al. 2015).

The skewness functional is the skewness SkF[Y]:=EF[((YEF[Y])/(VarF[Y])1/2)3]\textnormal{Sk}_F[Y] := \textnormal{E}_F[((Y - \textnormal{E}_F[Y])/(\textnormal{Var}_F[Y])^{1/2})^3] (Christensen et al. 2015).

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

The error - spread scoring function is strictly consistent for the triple (mean, variance, skewness) functional (Christensen et al. 2015).

References

Christensen HM, Moroz IM, Palmer TN (2015) Evaluation of ensemble forecast uncertainty using a new proper score: Application to medium-range and seasonal forecasts. Quarterly Journal of the Royal Meteorological Society 141(687)(Part B):538–549. doi:10.1002/qj.2375.

Examples

# Compute the error - spread scoring function.

df <- data.frame(
    y = rep(x = 0, times = 6),
    x1 = c(2, 2, -2, -2, 0, 0),
    x2 = c(1, 2, 1, 2, 1, 2),
    x3 = c(3, 3, -3, -3, 0, 0)
)

df$errorspread_penalty <- errorspread_sf(x1 = df$x1, x2 = df$x2, x3 = df$x3,
    y = df$y)

print(df)

Expectile identification function

Description

The function expectile_if computes the expectile identification function at a specific level pp, when yy materialises and xx is the predictive expectile at level pp.

The expectile identification function is defined in Table 9 in Gneiting (2011).

Usage

expectile_if(x, y, p)

Arguments

x

Predictive expectile (prediction) at level pp. It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

p

It can be a vector of length nn (must have the same length as yy).

Details

The expectile identification function is defined by:

V(x,y,p):=21{xy}p(xy)V(x, y, p) := 2 |\textbf{1} \lbrace x \geq y \rbrace - p| (x - y)

Domain of function:

xRx \in \mathbb{R}

yRy \in \mathbb{R}

0<p<10 < p < 1

Range of function:

V(x,y,p)RV(x, y, p) \in \mathbb{R}

Value

Vector of values of the expectile identification function.

Note

For the definition of expectiles, see Newey and Powell (1987).

The expectile identification function is a strict F\mathbb{F}-identification function for the pp-expectile functional (Gneiting 2011; Fissler and Ziegel 2016; Dimitriadis et al. 2024).

F\mathbb{F} is the family of probability distributions FF for which EF[Y]\textnormal{E}_F[Y] exists and is finite (Gneiting 2011; Fissler and Ziegel 2016; Dimitriadis et al. 2024).

References

Dimitriadis T, Fissler T, Ziegel JF (2024) Osband's principle for identification functions. Statistical Papers 65:1125–1132. doi:10.1007/s00362-023-01428-x.

Fissler T, Ziegel JF (2016) Higher order elicitability and Osband's principle. The Annals of Statistics 44(4):1680–1707. doi:10.1214/16-AOS1439.

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

Newey WK, Powell JL (1987) Asymmetric least squares estimation and testing. Econometrica 55(4):819–847. doi:10.2307/1911031.

Examples

# Compute the expectile identification function.

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

df$expectile_if <- expectile_if(x = df$x, y = df$y, p = df$p)

Realised expectile score

Description

The function expectile_rs computes the realised expectile score at a specific level pp when y\textbf{\textit{y}} materialises and x\textbf{\textit{x}} is the prediction.

Realised expectile score is a realised score corresponding to the expectile scoring function expectile_sf.

Usage

expectile_rs(x, y, p)

Arguments

x

Prediction. It can be a vector of length nn (must have the same length as y\textbf{\textit{y}}).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as x\textbf{\textit{x}}).

p

It can be a vector of length nn (must have the same length as y\textbf{\textit{y}}) or a scalar value.

Details

The realized expectile score is defined by:

S(x,y,p):=(1/n)i=1nL(xi,yi,p)S(\textbf{\textit{x}}, \textbf{\textit{y}}, p) := (1/n) \sum_{i = 1}^{n} L(x_i, y_i, p)

where

x=(x1,...,xn)T\textbf{\textit{x}} = (x_1, ..., x_n)^\mathsf{T}

y=(y1,...,yn)T\textbf{\textit{y}} = (y_1, ..., y_n)^\mathsf{T}

and

L(x,y,p):=1{xy}p(xy)2L(x, y, p) := |\textbf{1} \lbrace x \geq y \rbrace - p| (x - y)^2

Domain of function:

xRn\textbf{\textit{x}} \in \mathbb{R}^n

yRn\textbf{\textit{y}} \in \mathbb{R}^n

0<p<10 < p < 1

Range of function:

S(x,y,p)0,x,yRn,p(0,1)S(\textbf{\textit{x}}, \textbf{\textit{y}}, p) \geq 0, \forall \textbf{\textit{x}}, \textbf{\textit{y}} \in \mathbb{R}^n, p \in (0, 1)

Value

Value of the realised expectile score.

Note

For details on the expectile scoring function, see expectile_sf.

The concept of realised (average) scores is defined by Gneiting (2011) and Fissler and Ziegel (2019).

The realised expectile score is the realised (average) score corresponding to the expectile scoring function.

References

Fissler T, Ziegel JF (2019) Order-sensitivity and equivariance of scoring functions. Electronic Journal of Statistics 13(1):1166–1211. doi:10.1214/19-EJS1552.

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 realised expectile score.

set.seed(12345)

x <- 0.5

y <- rnorm(n = 100, mean = 0, sd = 1)

print(expectile_rs(x = x, y = y, p = 0.7))

print(expectile_rs(x = rep(x = x, times = 100), y = y, p = 0.7))

Asymmetric piecewise quadratic scoring function (expectile scoring function, expectile loss function)

Description

The function expectile_sf computes the asymmetric piecewise quadratic scoring function (expectile scoring function) at a specific level pp, when yy materialises and xx is the predictive expectile at level pp.

The asymmetric piecewise quadratic scoring function is defined by eq. (27) in Gneiting (2011).

Usage

expectile_sf(x, y, p)

Arguments

x

Predictive expectile (prediction) at level pp. It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

p

It can be a vector of length nn (must have the same length as yy).

Details

The asymmetric piecewise quadratic scoring function is defined by:

S(x,y,p):=1{xy}p(xy)2S(x, y, p) := |\textbf{1} \lbrace x \geq y \rbrace - p| (x - y)^2

or equivalently,

S(x,y,p):=p(max{(xy),0})2+(1p)(max{xy,0})2S(x, y, p) := p (\max \lbrace -(x - y), 0 \rbrace)^2 + (1 - p) (\max \lbrace x - y, 0 \rbrace)^2

Domain of function:

xRx \in \mathbb{R}

yRy \in \mathbb{R}

0<p<10 < p < 1

Range of function:

S(x,y,p)0,x,yR,p(0,1)S(x, y, p) \geq 0, \forall x, y \in \mathbb{R}, p \in (0, 1)

Value

Vector of expectile losses.

Note

For the definition of expectiles, see Newey and Powell (1987).

The asymmetric piecewise quadratic scoring function is negatively oriented (i.e. the smaller, the better).

The asymmetric piecewise quadratic scoring function is strictly F\mathbb{F}-consistent for the pp-expectile functional. F\mathbb{F} is the family of probability distributions FF for which EF[Y2]\textnormal{E}_F[Y^2] exists and is finite (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.

Newey WK, Powell JL (1987) Asymmetric least squares estimation and testing. Econometrica 55(4):819–847. doi:10.2307/1911031.

Examples

# Compute the asymmetric piecewise quadratic scoring function (expectile scoring
# function).

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

df$expectile_penalty <- expectile_sf(x = df$x, y = df$y, p = df$p)

print(df)

# The asymmetric piecewise quadratic scoring function (expectile scoring
# function) at level p = 0.5 is half the squared error scoring function.

df <- data.frame(
    y = rep(x = 0, times = 3),
    x = c(-2, 0, 2),
    p = rep(x = c(0.5), times = 3)
)

df$expectile_penalty <- expectile_sf(x = df$x, y = df$y, p = df$p)

df$squared_error <- serr_sf(x = df$x, y = df$y)

print(df)

Generalized Huber scoring function

Description

The function ghuber_sf computes the generalized Huber scoring function at a specific level pp and parameters aa and bb, when yy materialises and xx is the predictive Huber functional at level pp.

The generalized Huber scoring function is defined by eq. (4.7) in Taggart (2022) for ϕ(t)=t2\phi(t) = t^2.

Usage

ghuber_sf(x, y, p, a, b)

Arguments

x

Predictive Huber functional (prediction) at level pp. It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

p

It can be a vector of length nn (must have the same length as yy).

a

It can be a vector of length nn (must have the same length as yy).

b

It can be a vector of length nn (must have the same length as yy).

Details

The generalized Huber scoring function is defined by:

S(x,y,p,a,b):=1{xy}p(y2(κa,b(xy)+y)2+2xκa,b(xy))S(x, y, p, a, b) := |\textbf{1} \lbrace x \geq y \rbrace - p| (y^2 - (\kappa_{a,b}(x - y) + y)^2 + 2 x \kappa_{a,b}(x - y))

or equivalently

S(x,y,p,a,b):=1{xy}pfa,b(xy)S(x, y, p, a, b) := |\textbf{1} \lbrace x \geq y \rbrace - p| f_{a,b}(x - y)

or

S(x,y,p,a,b):=pfa,b(max{(xy),0})+(1p)fa,b(max{xy,0})S(x, y, p, a, b) := p f_{a,b}(- \max \lbrace -(x - y), 0 \rbrace) + (1 - p) f_{a,b}(\max \lbrace x - y, 0 \rbrace)

where

fa,b(t):=κa,b(t)(2tκa,b(t))f_{a,b}(t) := \kappa_{a,b}(t) (2 t - \kappa_{a,b}(t))

and κa,b(t)\kappa_{a,b}(t) is the capping function defined by:

κa,b(t):=max{min{t,b},a}\kappa_{a,b}(t) := \max \lbrace \min \lbrace t,b \rbrace, -a \rbrace

Domain of function:

xRx \in \mathbb{R}

yRy \in \mathbb{R}

0<p<10 < p < 1

a>0a > 0

b>0b > 0

Range of function:

S(x,y,p,a,b)0,x,yR,p(0,1),a,b>0S(x, y, p, a, b) \geq 0, \forall x, y \in \mathbb{R}, p \in (0, 1), a, b > 0

Value

Vector of generalized Huber losses.

Note

For the definition of Huber functionals, see definition 3.3 in Taggart (2022). The value of eq. (4.7) is twice the value of the equation in definition 4.2 in Taggart (2002).

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

The generalized Huber scoring function is strictly F\mathbb{F}-consistent for the pp-Huber functional. F\mathbb{F} is the family of probability distributions FF for which EF[Y2(Ya)2]\textnormal{E}_F[Y^2 - (Y - a)^2] and EF[Y2(Y+b)2]\textnormal{E}_F[Y^2 - (Y + b)^2] (or equivalently EF[Y]\textnormal{E}_F[Y]) exist and are finite (Taggart 2022).

References

Taggart RJ (2022) Point forecasting and forecast evaluation with generalized Huber loss. Electronic Journal of Statistics 16:201–231. doi:10.1214/21-EJS1957.

Examples

# Compute the generalized Huber scoring function.

set.seed(12345)

n <- 10

df <- data.frame(
    x = runif(n, -2, 2),
    y = runif(n, -2, 2),
    p = runif(n, 0, 1),
    a = runif(n, 0, 1),
    b = runif(n, 0, 1)
)

df$ghuber_penalty <- ghuber_sf(x = df$x, y = df$y, p = df$p, a = df$a, b = df$b)

print(df)

# Equivalence of the generalized Huber scoring function and the asymmetric
# piecewise quadratic scoring function (expectile scoring function), when
# a = Inf and b = Inf.

set.seed(12345)

n <- 100

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

u <- ghuber_sf(x = x, y = y, p = p, a = a, b = b)
v <- expectile_sf(x = x, y = y, p = p)

max(abs(u - v)) # values are slightly higher than 0 due to rounding error
min(abs(u - v))

# Equivalence of the generalized Huber scoring function and the Huber scoring
# function when p = 1/2 and a = b.

set.seed(12345)

n <- 100

x <- runif(n, -20, 20)
y <- runif(n, -20, 20)
p <- rep(x = 1/2, times = n)
a <- runif(n, 0, 20)

u <- ghuber_sf(x = x, y = y, p = p, a = a, b = a)
v <- huber_sf(x = x, y = y, a = a)

max(abs(u - v)) # values are slightly higher than 0 due to rounding error
min(abs(u - v))

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 pp for g(x)=xb/bg(x) = x^b/|b|, b>0b > 0, when yy materialises and xx is the predictive quantile at level pp.

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)g(x) is defined by eq. (26) in Gneiting (2011).

Usage

gpl1_sf(x, y, p, b)

Arguments

x

Predictive quantile (prediction) at level pp. It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

p

It can be a vector of length nn (must have the same length as yy).

b

It can be a vector of length nn (must have the same length as yy).

Details

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

S(x,y,p,b):=(1/b)(1{xy}p)(xbyb)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)(pmax{(xbyb),0}+(1p)max{xbyb,0})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>0x > 0

y>0y > 0

0<p<10 < p < 1

b>0b > 0

Range of function:

S(x,y,p,b)0,x,y>0,p(0,1),b>0S(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 denoted as type 1 since it corresponds to a specific type of g(x)g(x) of the general form of the generalized piecewise linear power scoring function defined by eq. (25) in Gneiting (2011).

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

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

The herein implemented generalized piecewise linear power scoring function is strictly F\mathbb{F}-consistent for the pp-quantile functional. F\mathbb{F} is the family of probability distributions FF for which EF[Yb]\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. doi:10.1198/jasa.2011.r10138.

Koenker R, Bassett Jr G (1978) Regression quantiles. Econometrica 46(1):33–50. doi:10.2307/1913643.

Saerens M (2000) Building cost functions minimizing to some summary statistics. IEEE Transactions on Neural Networks 11(6):1263–1271. doi:10.1109/72.883416.

Thomson W (1979) Eliciting production possibilities from a well-informed manager. Journal of Economic Theory 20(3):360–380. doi:10.1016/0022-0531(79)90042-5.

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, 0, 20)
y <- runif(n, 0, 20)
p <- runif(n, 0, 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, 0, 20)
y <- runif(n, 0, 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))

Generalized piecewise linear power scoring function (type 2)

Description

The function gpl2_sf computes the generalized piecewise linea power scoring function at a specific level pp for g(x)=log(x)g(x) = \log(x), when yy materialises and xx is the predictive quantile at level pp.

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

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

Usage

gpl2_sf(x, y, p)

Arguments

x

Predictive quantile (prediction) at level pp. It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

p

It can be a vector of length nn (must have the same length as yy).

Details

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

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

or equivalently

S(x,y,p):=pmax{(log(x)log(y)),0}+(1p)max{log(x)log(y),0}S(x, y, p) := p | \max \lbrace -(\log(x) - \log(y)), 0 \rbrace | + (1 - p) | \max \lbrace \log(x) - \log(y), 0 \rbrace |

Domain of function:

x>0x > 0

y>0y > 0

0<p<10 < p < 1

Range of function:

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

Value

Vector of generalized piecewise linear losses.

Note

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

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

The herein implemented generalized piecewise linear power scoring function is strictly F\mathbb{F}-consistent for the pp-quantile functional. F\mathbb{F} is the family of probability distributions FF for which EF[log(Y)]\textnormal{E}_F[\log(Y)] 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. doi:10.1198/jasa.2011.r10138.

Koenker R, Bassett Jr G (1978) Regression quantiles. Econometrica 46(1):33–50. doi:10.2307/1913643.

Saerens M (2000) Building cost functions minimizing to some summary statistics. IEEE Transactions on Neural Networks 11(6):1263–1271. doi:10.1109/72.883416.

Thomson W (1979) Eliciting production possibilities from a well-informed manager. Journal of Economic Theory 20(3):360–380. doi:10.1016/0022-0531(79)90042-5.

Examples

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

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))
)

df$gpl2_penalty <- gpl2_sf(x = df$x, y = df$y, p = df$p)

print(df)

# The generalized piecewise linear scoring function (type 2) is half the MAE-LOG
# scoring function.

df <- data.frame(
    y = rep(x = 5.5, times = 10),
    x = 1:10,
    p = rep(x = 0.5, times = 10)
)

df$gpl2_penalty <- gpl2_sf(x = df$x, y = df$y, p = df$p)

df$mae_log_penalty <- maelog_sf(x = df$x, y = df$y)

df$ratio <- df$gpl2_penalty/df$mae_log_penalty

print(df)

Mean Huber score

Description

The function huber_rs computes the mean Huber score with parameter aa, when y\textbf{\textit{y}} materialises and x\textbf{\textit{x}} is the prediction.

Mean Huber score is a realised score corresponding to the Huber scoring function huber_sf.

Usage

huber_rs(x, y, a)

Arguments

x

Prediction. It can be a vector of length nn (must have the same length as y\textbf{\textit{y}}).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as x\textbf{\textit{x}}).

a

It can be a vector of length nn (must have the same length as yy) or a scalar.

Details

The mean Huber score is defined by:

S(x,y,a):=(1/n)i=1nL(xi,yi,a)S(\textbf{\textit{x}}, \textbf{\textit{y}}, a) := (1/n) \sum_{i = 1}^{n} L(x_i, y_i, a)

where

x=(x1,...,xn)T\textbf{\textit{x}} = (x_1, ..., x_n)^\mathsf{T}

y=(y1,...,yn)T\textbf{\textit{y}} = (y_1, ..., y_n)^\mathsf{T}

and

L(x,y,a):={12(xy)2,xyaaxy12a2,xy>aL(x, y, a) := \left\{ \begin{array}{ll} \dfrac{1}{2} (x - y)^2, & |x - y| \leq a\\ a |x - y| - \dfrac{1}{2} a^2, & |x - y| > a \end{array} \right.

Domain of function:

xRn\textbf{\textit{x}} \in \mathbb{R}^n

yRn\textbf{\textit{y}} \in \mathbb{R}^n

a>0a > 0

Range of function:

S(x,y,a)0,x,yRn,a>0S(\textbf{\textit{x}}, \textbf{\textit{y}}, a) \geq 0, \forall \textbf{\textit{x}}, \textbf{\textit{y}} \in \mathbb{R}^n, a > 0

Value

Value of the mean Huber score.

Note

For details on the Huber scoring function, see huber_sf.

The concept of realised (average) scores is defined by Gneiting (2011) and Fissler and Ziegel (2019).

The mean Huber score is the realised (average) score corresponding to the Huber scoring function.

References

Fissler T, Ziegel JF (2019) Order-sensitivity and equivariance of scoring functions. Electronic Journal of Statistics 13(1):1166–1211. doi:10.1214/19-EJS1552.

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 Huber mean score.

set.seed(12345)

a <- 0.5

x <- 0

y <- rnorm(n = 100, mean = 0, sd = 1)

print(huber_rs(x = x, y = y, a = a))

print(huber_rs(x = rep(x = x, times = 100), y = y, a = a))

Huber scoring function

Description

The function huber_sf computes the Huber scoring function with parameter aa, when yy materialises and xx is the predictive Huber mean.

The Huber scoring function is defined in Huber (1964).

Usage

huber_sf(x, y, a)

Arguments

x

Predictive Huber mean (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

a

It can be a vector of length nn (must have the same length as yy).

Details

The Huber scoring function is defined by:

S(x,y,a):={12(xy)2,xyaaxy12a2,xy>aS(x, y, a) := \left\{ \begin{array}{ll} \dfrac{1}{2} (x - y)^2, & |x - y| \leq a\\ a |x - y| - \dfrac{1}{2} a^2, & |x - y| > a \end{array} \right.

or equivalently

S(x,y,a):=(1/2)κa,a(xy)(2(xy)κa,a(xy))S(x, y, a) := (1/2) \kappa_{a,a}(x - y) (2 (x - y) - \kappa_{a,a}(x - y))

where κa,b(t)\kappa_{a,b}(t) is the capping function defined by:

κa,b(t):=max{min{t,b},a}\kappa_{a,b}(t) := \max \lbrace \min \lbrace t,b \rbrace, -a \rbrace

Domain of function:

xRx \in \mathbb{R}

yRy \in \mathbb{R}

a>0a > 0

Range of function:

S(x,y,a)0,x,yR,a>0S(x, y, a) \geq 0, \forall x, y \in \mathbb{R}, a > 0

Value

Vector of Huber losses.

Note

For the definition of Huber mean, see Taggart (2022).

The Huber scoring function is negatively oriented (i.e. the smaller, the better).

The Huber scoring function is strictly F\mathbb{F}-consistent for the Huber mean. F\mathbb{F} is the family of probability distributions FF for which EF[Y2(Ya)2]\textnormal{E}_F[Y^2 - (Y - a)^2] and EF[Y2(Y+a)2]\textnormal{E}_F[Y^2 - (Y + a)^2] (or equivalently EF[Y]\textnormal{E}_F[Y]) exist and are finite (Taggart 2022).

References

Huber PJ (1964) Robust estimation of a location parameter. Annals of Mathematical Statistics 35(1):73–101. doi:10.1214/aoms/1177703732.

Taggart RJ (2022) Point forecasting and forecast evaluation with generalized Huber loss. Electronic Journal of Statistics 16:201–231. doi:10.1214/21-EJS1957.

Examples

# Compute the Huber scoring function.

df <- data.frame(
    x = c(-3, -2, -1, 0, 1, 2, 3),
    y = c(0, 0, 0, 0, 0, 0, 0),
    a = c(2.7, 2.5, 0.6, 0.7, 0.9, 1.2, 5)
)

df$huber_penalty <- huber_sf(x = df$x, y = df$y, a = df$a)

print(df)

Huber mean identification function

Description

The function hubermean_if computes the Huber mean identification function with parameter aa, when yy materialises and xx is the predictive Huber mean.

The Huber mean identification function is defined by eq. (3.5) in Taggart (2022).

Usage

hubermean_if(x, y, a)

Arguments

x

Predictive Huber mean (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

a

It can be a vector of length nn (must have the same length as yy).

Details

The Huber mean identification function is defined by:

V(x,y,a):=(1/2)κa,a(xy)V(x, y, a) := (1/2) \kappa_{a,a}(x - y)

where κa,b(t)\kappa_{a,b}(t) is the capping function defined by:

κa,b(t):=max{min{t,b},a}\kappa_{a,b}(t) := \max \lbrace \min \lbrace t,b \rbrace, -a \rbrace

Domain of function:

xRx \in \mathbb{R}

yRy \in \mathbb{R}

a>0a > 0

Value

Vector of values of the Huber mean identification function.

Note

For the definition of Huber mean, see Taggart (2022).

The Huber mean identification function is a strict F\mathbb{F}-identification function for the Huber mean functional (Taggart 2022).

F\mathbb{F} is the family of probability distributions FF for which for which EF[Y]\textnormal{E}_F[Y] exists and is finite (Taggart 2022).

References

Taggart RJ (2022) Point forecasting and forecast evaluation with generalized Huber loss. Electronic Journal of Statistics 16:201–231. doi:10.1214/21-EJS1957.

Examples

# Compute the Huber mean identification function.

df <- data.frame(
    x = c(-3, -2, -1, 0, 1, 2, 3),
    y = c(0, 0, 0, 0, 0, 0, 0),
    a = c(2.7, 2.5, 0.6, 0.7, 0.9, 1.2, 5)
)

df$hubermean_if <- hubermean_if(x = df$x, y = df$y, a = df$a)

print(df)

Huber quantile identification function

Description

The function huberquantile_if computes the Huber quantile identification function at a specific level pp and parameters aa and bb, when yy materialises and xx is the predictive Huber functional at level pp.

The Huber quantile identification function is defined by eq. (3.5) in Taggart (2022).

Usage

huberquantile_if(x, y, p, a, b)

Arguments

x

Predictive Huber functional (prediction) at level pp. It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

p

It can be a vector of length nn (must have the same length as yy).

a

It can be a vector of length nn (must have the same length as yy).

b

It can be a vector of length nn (must have the same length as yy).

Details

The Huber quantile identification function is defined by:

V(x,y,a):=1{xy}pκa,b(xy)V(x, y, a) := |\textbf{1} \lbrace x \geq y \rbrace - p| \kappa_{a,b}(x - y)

where κa,b(t)\kappa_{a,b}(t) is the capping function defined by:

κa,b(t):=max{min{t,b},a}\kappa_{a,b}(t) := \max \lbrace \min \lbrace t,b \rbrace, -a \rbrace

Domain of function:

xRx \in \mathbb{R}

yRy \in \mathbb{R}

0<p<10 < p < 1

a>0a > 0

b>0b > 0

Value

Vector of values of the Huber quantile identification function.

Note

For the definition of Huber quantile, see Taggart (2022).

The Huber quantile identification function is a strict F\mathbb{F}-identification function for the Huber quantile functional (Taggart 2022).

F\mathbb{F} is the family of probability distributions FF for which for which EF[Y]\textnormal{E}_F[Y] exists and is finite (Taggart 2022).

References

Taggart RJ (2022) Point forecasting and forecast evaluation with generalized Huber loss. Electronic Journal of Statistics 16:201–231. doi:10.1214/21-EJS1957.

Examples

# Compute the Huber quantile identification function.

set.seed(12345)

n <- 10

df <- data.frame(
    x = runif(n, -2, 2),
    y = runif(n, -2, 2),
    p = runif(n, 0, 1),
    a = runif(n, 0, 1),
    b = runif(n, 0, 1)
)

df$huberquantile_if <- huberquantile_if(x = df$x, y = df$y, p = df$p, a = df$a,
    b = df$b)

print(df)

Interval scoring function (Winkler scoring function)

Description

The function interval_sf computes the interval scoring function (Winkler scoring function) when yy materialises and [x1,x2][x_1, x_2] is the central 1p1 - p prediction interval.

The interval scoring function is defined by eq. (43) in Gneiting and Raftery (2007).

Usage

interval_sf(x1, x2, y, p)

Arguments

x1

Predictive quantile (prediction) at level p/2p/2. It can be a vector of length nn (must have the same length as yy).

x2

Predictive quantile (prediction) at level 1p/21 - p/2. It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as x1x_1).

p

It can be a vector of length nn (must have the same length as yy).

Details

The interval scoring function is defined by:

S(x1,x2,y,p):=(x2x1)+(2/p)(x1y)1{y<x1}+(2/p)(yx2)1{y>x2}S(x_1, x_2, y, p) := (x_2 - x_1) + (2/p) (x_1 - y) \textbf{1} \lbrace y < x_1 \rbrace + (2/p) (y - x_2) \textbf{1} \lbrace y > x_2 \rbrace

Domain of function:

x1Rx_1 \in \mathbb{R}

x2Rx_2 \in \mathbb{R}

x1<x2x_1 < x_2

yRy \in \mathbb{R}

0<p<10 < p < 1

Range of function:

S(x1,x2,y,p)0,x1,x2,yR,x1<x2,p(0,1)S(x_1, x_2, y, p) \geq 0, \forall x_1, x_2, y \in \mathbb{R}, x_1 < x_2, p \in (0, 1)

Value

Vector of interval losses.

Note

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

The interval scoring function is negatively oriented (i.e. the smaller, the better).

The interval scoring function is strictly F\mathbb{F}-consistent for the central 1p1 - p prediction interval [x1,x2][x_1, x_2]. x1x_1 and x2x_2 are quantile functionals at levels p/2p/2 and 1p/21 - p/2 respectively.

F\mathbb{F} is the family of probability distributions FF for which EF[Y]\textnormal{E}_F[Y] exists and is finite (Dunsmore 1968; Winkler 1972; Gneiting and Raftery 2007; Winkler and Murphy 1979; Fissler and Ziegel 2016; Brehmer and Gneiting 2021).

References

Brehmer JR, Gneiting T (2021) Scoring interval forecasts: Equal-tailed, shortest, and modal interval. Bernoulli 27(3):1993–2010. doi:10.3150/20-BEJ1298.

Dunsmore IR (1968) A Bayesian approach to calibration. Journal of the Royal Statistical Society: Series B (Statistical Methodology) 30(2):396–405. doi:10.1111/j.2517-6161.1968.tb00740.x.

Fissler T, Ziegel JF (2016) Higher order elicitability and Osband's principle. The Annals of Statistics 44(4):1680–1707. doi:10.1214/16-AOS1439.

Gneiting T, Raftery AE (2007) Strictly proper scoring rules, prediction, and estimation. Journal of the American Statistical Association 102(477):359–378. doi:10.1198/016214506000001437.

Koenker R, Bassett Jr G (1978) Regression quantiles. Econometrica 46(1):33–50. doi:10.2307/1913643.

Winkler RL (1972) A decision-theoretic approach to interval estimation. Journal of the American Statistical Association 67(337):187–191. doi:10.1080/01621459.1972.10481224.

Winkler RL, Murphy AH (1979) The use of probabilities in forecasts of maximum and minimum temperatures.Meteorological Magazine 108(1288):317–329.

Examples

# Compute the interval scoring function (Winkler scoring function).

df <- data.frame(
    y = rep(x = 0, times = 6),
    x1 = c(-3, -2, -1, 0, 1, 2),
    x2 = c(1, 2, 3, 4, 5, 6),
    p = rep(x = c(0.05, 0.95), times = 3)
)

df$interval_penalty <- interval_sf(x1 = df$x1, x2 = df$x2, y = df$y, p = df$p)

print(df)

LINEX scoring function

Description

The function linex_sf computes the LINEX scoring function with parameter aa when yy materialises and xx is the predictive (1/a)logEF[eaY]-(1/a) \log{\textnormal{E}_F[\textnormal{e}^{-a Y}]} moment generating functional.

The LINEX scoring function is defined by Varian (1975).

Usage

linex_sf(x, y, a)

Arguments

x

Predictive (1/a)logEF[eaY]-(1/a) \log{\textnormal{E}_F[\textnormal{e}^{-a Y}]} moment generating functional (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

a

It can be a vector of length nn (must have the same length as yy).

Details

The LINEX scoring function is defined by:

S(x,y,a):=ea(xy)a(xy)1S(x, y, a) := \textnormal{e}^{a (x - y)} - a (x - y) - 1

Domain of function:

xRx \in \mathbb{R}

yRy \in \mathbb{R}

a0a \neq 0

Range of function:

S(x,y,a)0,x,yR,a0S(x, y, a) \geq 0, \forall x, y \in \mathbb{R}, a \neq 0

Value

Vector of LINEX losses.

Note

For details on the LINEX scoring function, see Varian (1975) and Zellner (1986).

The LINEX scoring function is negatively oriented (i.e. the smaller, the better).

The LINEX scoring function is strictly F\mathbb{F}-consistent for the (1/a)logEF[eaY]-(1/a) \log{\textnormal{E}_F[\textnormal{e}^{-a Y}]} moment generating functional. F\mathbb{F} is the family of probability distributions FF for which EF[eaY]\textnormal{E}_F[\textnormal{e}^{-a Y}] and EF[Y]\textnormal{E}_F[Y] exist and are finite (Varian 1975; Zellner 1986; 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.

Varian HR (1975) A Bayesian approach to real estate assessment. In: Fienberg SE, Zellner A(eds) Studies in Bayesian Econometrics and Statistics in Honor of Leonard J. Savage. Amsterdam: North-Holland, pp 195–208.

Zellner A (1986) Bayesian estimation and prediction using asymmetric loss functions. Journal of the American Statistical Association 81(394):446–451. doi:10.1080/01621459.1986.10478289.

Examples

# Compute the LINEX scoring function.

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

df$linex_loss <- linex_sf(x = df$x, y = df$y, a = df$a)

print(df)

LqL_q-mean scoring function

Description

The function lqmean_sf computes the LqL_q-mean scoring function, when yy materialises and xx is the predictive LqL_q-mean.

The LqL_q-mean scoring function is defined by Chen (1996). It is equivalent to the LqL_q-quantile scoring function at level p=1/2p = 1/2, up to a multiplicative constant.

Usage

lqmean_sf(x, y, q)

Arguments

x

Predictive LqL_q-mean. It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

q

It can be a vector of length nn (must have the same length as yy).

Details

The LqL_q-mean scoring function is defined by:

S(x,y,q):=xyqS(x, y, q) := |x - y|^q

Domain of function:

xRx \in \mathbb{R}

yRy \in \mathbb{R}

q1q \geq 1

Range of function:

S(x,y,q)0,x,yR,q1S(x, y, q) \geq 0, \forall x, y \in \mathbb{R}, q \geq 1

Value

Vector of LqL_q-mean losses.

Note

For the definition of LqL_q-means, see Chen (1996). In particular, LqL_q-means are the solution of the equation EF[V(x,Y,q)]=0\textnormal{E}_F[V(x, Y, q)] = 0, where

V(x,y,p,q):=qsign(xy)xyq1V(x, y, p, q) := q \textnormal{sign}(x - y) |x - y|^{q - 1}

LqL_q-means are LqL_q-quantiles at level p=1/2p = 1/2.

The LqL_q-mean scoring function is negatively oriented (i.e. the smaller, the better).

The LqL_q-mean scoring function is strictly F\mathbb{F}-consistent for the LqL_q-mean functional. F\mathbb{F} is the family of probability distributions FF for which EF[Yq]\textnormal{E}_F[Y^q] exists and is finite (Chen 2016; Bellini 2014).

References

Bellini F, Klar B, Muller A, Gianin ER (2014) Generalized quantiles as risk measures. Insurance: Mathematics and Economics 54:41–48. doi:10.1016/j.insmatheco.2013.10.015.

Chen Z (1996) Conditional LpL_p-quantiles and their application to the testing of symmetry in non-parametric regression. Statistics and Probability Letters 29(2):107–115. doi:10.1016/0167-7152(95)00163-8.

Examples

# Compute the Lq-mean scoring function.

df <- data.frame(
    y = rep(x = 0, times = 6),
    x = c(2, 2, -2, -2, 0, 0),
    q = c(2, 3, 2, 3, 2, 3)
)

df$lqmean_penalty <- lqmean_sf(x = df$x, y = df$y, q = df$q)

print(df)

LqL_q-quantile scoring function

Description

The function lqquantile_sf computes the LqL_q-quantile scoring function at a specific level pp, when yy materialises and xx is the predictive LqL_q-quantile at level pp.

The LqL_q-quantile scoring function is defined by Chen (1996).

Usage

lqquantile_sf(x, y, p, q)

Arguments

x

Predictive LqL_q-quantile at level pp. It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

p

It can be a vector of length nn (must have the same length as yy).

q

It can be a vector of length nn (must have the same length as yy).

Details

The LqL_q-quantile scoring function is defined by:

S(x,y,p,q):=1{xy}pxyqS(x, y, p, q) := |\textbf{1} \lbrace x \geq y \rbrace - p| |x - y|^q

or equivalently,

S(x,y,p,q):=pmax{(xy),0}q+(1p)max{xy,0}qS(x, y, p, q) := p |\max \lbrace -(x - y), 0 \rbrace|^q + (1 - p) |\max \lbrace x - y, 0 \rbrace|^q

Domain of function:

xRx \in \mathbb{R}

yRy \in \mathbb{R}

0<p<10 < p < 1

q2q \geq 2

Range of function:

S(x,y,p,q)0,x,yR,p(0,1),q2S(x, y, p, q) \geq 0, \forall x, y \in \mathbb{R}, p \in (0, 1), q \geq 2

Value

Vector of LqL_q-quantile losses.

Note

For the definition of LqL_q-quantiles, see Chen (1996). In particular, LqL_q-quantiles at level pp are the solution of the equation EF[V(x,Y,p,q)]=0\textnormal{E}_F[V(x, Y, p, q)] = 0, where

V(x,y,p,q):=q(1{xy}p)xyq1V(x, y, p, q) := q (\textbf{1} \lbrace x \geq y \rbrace - p) |x - y|^{q - 1}

The LqL_q-quantile scoring function is negatively oriented (i.e. the smaller, the better).

The LqL_q-quantile scoring function is strictly F\mathbb{F}-consistent for the LqL_q-quantile functional at level pp. F\mathbb{F} is the family of probability distributions FF for which EF[Yq]\textnormal{E}_F[Y^q] exists and is finite (Chen 2016; Bellini 2014).

References

Bellini F, Klar B, Muller A, Gianin ER (2014) Generalized quantiles as risk measures. Insurance: Mathematics and Economics 54:41–48. doi:10.1016/j.insmatheco.2013.10.015.

Chen Z (1996) Conditional LpL_p-quantiles and their application to the testing of symmetry in non-parametric regression. Statistics and Probability Letters 29(2):107–115. doi:10.1016/0167-7152(95)00163-8.

Examples

# Compute the Lq-quantile scoring function at level p.

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

df$lqquantile_penalty <- lqquantile_sf(x = df$x, y = df$y, p = df$p, q = df$q)

print(df)

Mean absolute error (MAE)

Description

The function mae computes the mean absolute error when y\textbf{\textit{y}} materialises and x\textbf{\textit{x}} is the prediction.

Mean absolute error is a realised score corresponding to the absolute error scoring function aerr_sf.

Usage

mae(x, y)

Arguments

x

Prediction. It can be a vector of length nn (must have the same length as y\textbf{\textit{y}}).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as x\textbf{\textit{x}}).

Details

The mean absolute error is defined by:

S(x,y):=(1/n)i=1nL(xi,yi)S(\textbf{\textit{x}}, \textbf{\textit{y}}) := (1/n) \sum_{i = 1}^{n} L(x_i, y_i)

where

x=(x1,...,xn)T\textbf{\textit{x}} = (x_1, ..., x_n)^\mathsf{T}

y=(y1,...,yn)T\textbf{\textit{y}} = (y_1, ..., y_n)^\mathsf{T}

and

L(x,y):=xyL(x, y) := |x - y|

Domain of function:

xRn\textbf{\textit{x}} \in \mathbb{R}^n

yRn\textbf{\textit{y}} \in \mathbb{R}^n

Range of function:

S(x,y)0,x,yRnS(\textbf{\textit{x}}, \textbf{\textit{y}}) \geq 0, \forall \textbf{\textit{x}}, \textbf{\textit{y}} \in \mathbb{R}^n

Value

Value of the mean absolute error.

Note

For details on the absolute error scoring function, see aerr_sf.

The concept of realised (average) scores is defined by Gneiting (2011) and Fissler and Ziegel (2019).

The mean absolute error is the realised (average) score corresponding to the absolute error scoring function.

References

Fissler T, Ziegel JF (2019) Order-sensitivity and equivariance of scoring functions. Electronic Journal of Statistics 13(1):1166–1211. doi:10.1214/19-EJS1552.

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 mean absolute error.

set.seed(12345)

x <- 0

y <- rnorm(n = 100, mean = 0, sd = 1)

print(mae(x = x, y = y))

print(mae(x = rep(x = x, times = 100), y = y))

MAE-LOG scoring function

Description

The function maelog_sf computes the MAE-LOG scoring function when yy materialises and xx is the predictive median functional.

The MAE-LOG scoring function is defined by eq. (11) in Patton (2011).

Usage

maelog_sf(x, y)

Arguments

x

Predictive median functional (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

Details

The MAE-LOG scoring function is defined by:

S(x,y):=log(x/y)S(x, y) := |\log(x/y)|

Domain of function:

x>0x > 0

y>0y > 0

Range of function:

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

Value

Vector of MAE-LOG losses.

Note

For details on the MAE-LOG scoring function, see Gneiting (2011) and Patton (2011).

The median functional is the median of the probability distribution FF of yy (Gneiting 2011).

The MAE-LOG scoring function is negatively oriented (i.e. the smaller, the better).

The MAE-LOG scoring function is strictly F\mathbb{F}-consistent for the median functional. F\mathbb{F} is the family of probability distributions FF for which EF[log(Y)]\textnormal{E}_F[\log(Y)] 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. doi:10.1198/jasa.2011.r10138.

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

Saerens M (2000) Building cost functions minimizing to some summary statistics. IEEE Transactions on Neural Networks 11(6):1263–1271. doi:10.1109/72.883416.

Thomson W (1979) Eliciting production possibilities from a well-informed manager. Journal of Economic Theory 20(3):360–380. doi:10.1016/0022-0531(79)90042-5.

Examples

# Compute the MAE-LOG scoring function.

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

df$mae_log_penalty <- maelog_sf(x = df$x, y = df$y)

print(df)

MAE-SD scoring function

Description

The function maesd_sf computes the MAE-SD scoring function when yy materialises and xx is the predictive median functional.

The MAE-SD scoring function is defined by eq. (12) in Patton (2011).

Usage

maesd_sf(x, y)

Arguments

x

Predictive median functional (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

Details

The MAE-SD scoring function is defined by:

S(x,y):=x1/2y1/2S(x, y) := |x^{1/2} - y^{1/2}|

Domain of function:

x>0x > 0

y>0y > 0

Range of function:

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

Value

Vector of MAE-SD losses.

Note

For details on the MAE-SD scoring function, see Gneiting (2011) and Patton (2011).

The median functional is the median of the probability distribution FF of yy (Gneiting 2011).

The MAE-SD scoring function is negatively oriented (i.e. the smaller, the better).

The MAE-SD scoring function is strictly F\mathbb{F}-consistent for the median functional. F\mathbb{F} is the family of probability distributions FF for which EF[Y1/2]\textnormal{E}_F[Y^{1/2}] 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. doi:10.1198/jasa.2011.r10138.

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

Saerens M (2000) Building cost functions minimizing to some summary statistics. IEEE Transactions on Neural Networks 11(6):1263–1271. doi:10.1109/72.883416.

Thomson W (1979) Eliciting production possibilities from a well-informed manager. Journal of Economic Theory 20(3):360–380. doi:10.1016/0022-0531(79)90042-5.

Examples

# Compute the MAE-SD scoring function.

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

df$mae_sd_penalty <- maesd_sf(x = df$x, y = df$y)

print(df)

Mean absolute percentage error (MAPE)

Description

The function mape computes the mean absolute percentage error when y\textbf{\textit{y}} materialises and x\textbf{\textit{x}} is the prediction.

Mean absolute percentage error is a realised score corresponding to the absolute percentage error scoring function aperr_sf.

Usage

mape(x, y)

Arguments

x

Prediction. It can be a vector of length nn (must have the same length as y\textbf{\textit{y}}).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as x\textbf{\textit{x}}).

Details

The mean absolute pecentage error is defined by:

S(x,y):=(1/n)i=1nL(xi,yi)S(\textbf{\textit{x}}, \textbf{\textit{y}}) := (1/n) \sum_{i = 1}^{n} L(x_i, y_i)

where

x=(x1,...,xn)T\textbf{\textit{x}} = (x_1, ..., x_n)^\mathsf{T}

y=(y1,...,yn)T\textbf{\textit{y}} = (y_1, ..., y_n)^\mathsf{T}

and

L(x,y):=(xy)/yL(x, y) := |(x - y)/y|

Domain of function:

x>0\textbf{\textit{x}} > \textbf{0}

y>0\textbf{\textit{y}} > \textbf{0}

where

0=(0,...,0)T\textbf{0} = (0, ..., 0)^\mathsf{T}

is the zero vector of length nn and the symbol >> indicates pairwise inequality.

Range of function:

S(x,y)0,x,y>0S(\textbf{\textit{x}}, \textbf{\textit{y}}) \geq 0, \forall \textbf{\textit{x}}, \textbf{\textit{y}} > \textbf{0}

Value

Value of the mean absolute percentage error.

Note

For details on the absolute percentage error scoring function, see aperr_sf.

The concept of realised (average) scores is defined by Gneiting (2011) and Fissler and Ziegel (2019).

The mean absolute percentage error is the realised (average) score corresponding to the absolute percentage error scoring function.

References

Fissler T, Ziegel JF (2019) Order-sensitivity and equivariance of scoring functions. Electronic Journal of Statistics 13(1):1166–1211. doi:10.1214/19-EJS1552.

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 mean absolute percentage error.

set.seed(12345)

x <- 0.5

y <- rlnorm(n = 100, mean = 0, sdlog = 1)

print(mape(x = x, y = y))

print(mape(x = rep(x = x, times = 100), y = y))

Mean identification function

Description

The function mean_if computes the mean identification function , when yy materialises and xx is the predictive mean.

The mean identification function is defined in Table 9 in Gneiting (2011).

Usage

mean_if(x, y)

Arguments

x

Predictive mean (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

Details

The mean identification function is defined by:

V(x,y):=xyV(x, y) := x - y

Domain of function:

xRx \in \mathbb{R}

yRy \in \mathbb{R}

Range of function:

V(x,y)RV(x, y) \in \mathbb{R}

Value

Vector of values of the mean identification function.

Note

The mean functional is the mean EF[Y]\textnormal{E}_F[Y] of the probability distribution FF of yy (Gneiting 2011).

The mean identification function is a strict F\mathbb{F}-identification function for the mean functional. (Gneiting 2011; Fissler and Ziegel 2016; Dimitriadis et al. 2024).

F\mathbb{F} is the family of probability distributions FF for which EF[Y]\textnormal{E}_F[Y] exists and is finite (Gneiting 2011; Fissler and Ziegel 2016; Dimitriadis et al. 2024).

References

Dimitriadis T, Fissler T, Ziegel JF (2024) Osband's principle for identification functions. Statistical Papers 65:1125–1132. doi:10.1007/s00362-023-01428-x.

Fissler T, Ziegel JF (2016) Higher order elicitability and Osband's principle. The Annals of Statistics 44(4):1680–1707. doi:10.1214/16-AOS1439.

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

Newey WK, Powell JL (1987) Asymmetric least squares estimation and testing. Econometrica 55(4):819–847. doi:10.2307/1911031.

Examples

# Compute the mean identification function.

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

df$mean_if <- mean_if(x = df$x, y = df$y)

Log-transformed identification function

Description

The function meanlog_if computes the log-transformed identification function, when yy materialises and exp(EF[log(Y)])\exp(\textnormal{E}_F[\log(Y)]) is the predictive functional.

The log-transformed identification function is defined in Tyralis and Papacharalampous (2025).

Usage

meanlog_if(x, y)

Arguments

x

Predictive exp(EF[log(Y)])\exp(\textnormal{E}_F[\log(Y)]) functional. It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

Details

The mean identification function is defined by:

V(x,y):=log(x)log(y)V(x, y) := \log(x) - \log(y)

Domain of function:

x>0x > 0

y>0y > 0

Range of function:

V(x,y)R,x,y>0V(x, y) \in \mathbb{R}, \forall x, y > 0

Value

Vector of values of the log-transformed identification function.

Note

The log-transformed identification function is a strict F\mathbb{F}-identification function for the log-transformed expectation exp(EF[log(Y)])\exp(\textnormal{E}_F[\log(Y)]) (Tyralis and Papacharalampous 2025).

F\mathbb{F} is the family of probability distributions FF for which EF[log(Y)]\textnormal{E}_F[\log(Y)] exists and is finite (Tyralis and Papacharalampous 2025).

References

Tyralis H, Papacharalampous G (2025) Transformations of predictions and realizations in consistent scoring functions. doi:10.48550/arXiv.2502.16542.

Examples

# Compute the log-transformed identification function.

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

df$meanlog_if <- meanlog_if(x = df$x, y = df$y)

Mean relative error (MRE)

Description

The function mre computes the mean relative error when y\textbf{\textit{y}} materialises and x\textbf{\textit{x}} is the prediction.

Mean relative error is a realised score corresponding to the relative error scoring function relerr_sf.

Usage

mre(x, y)

Arguments

x

Prediction. It can be a vector of length nn (must have the same length as y\textbf{\textit{y}}).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as x\textbf{\textit{x}}).

Details

The mean relative error is defined by:

S(x,y):=(1/n)i=1nL(xi,yi)S(\textbf{\textit{x}}, \textbf{\textit{y}}) := (1/n) \sum_{i = 1}^{n} L(x_i, y_i)

where

x=(x1,...,xn)T\textbf{\textit{x}} = (x_1, ..., x_n)^\mathsf{T}

y=(y1,...,yn)T\textbf{\textit{y}} = (y_1, ..., y_n)^\mathsf{T}

and

L(x,y):=(xy)/xL(x, y) := |(x - y)/x|

Domain of function:

x>0\textbf{\textit{x}} > \textbf{0}

y>0\textbf{\textit{y}} > \textbf{0}

where

0=(0,...,0)T\textbf{0} = (0, ..., 0)^\mathsf{T}

is the zero vector of length nn and the symbol >> indicates pairwise inequality.

Range of function:

S(x,y)0,x,y>0S(\textbf{\textit{x}}, \textbf{\textit{y}}) \geq 0, \forall \textbf{\textit{x}}, \textbf{\textit{y}} > \textbf{0}

Value

Value of the mean relative error.

Note

For details on the relative error scoring function, see relerr_sf.

The concept of realised (average) scores is defined by Gneiting (2011) and Fissler and Ziegel (2019).

The mean relative error is the realised (average) score corresponding to the relative error scoring function.

References

Fissler T, Ziegel JF (2019) Order-sensitivity and equivariance of scoring functions. Electronic Journal of Statistics 13(1):1166–1211. doi:10.1214/19-EJS1552.

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 mean relative error.

set.seed(12345)

x <- 0.5

y <- rlnorm(n = 100, mean = 0, sdlog = 1)

print(mre(x = x, y = y))

print(mre(x = rep(x = x, times = 100), y = y))

Mean squared error (MSE)

Description

The function mse computes the mean squared error when y\textbf{\textit{y}} materialises and x\textbf{\textit{x}} is the prediction.

Mean squared error is a realised score corresponding to the squared error scoring function serr_sf.

Usage

mse(x, y)

Arguments

x

Prediction. It can be a vector of length nn (must have the same length as y\textbf{\textit{y}}).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as x\textbf{\textit{x}}).

Details

The mean squared error is defined by:

S(x,y):=(1/n)i=1nL(xi,yi)S(\textbf{\textit{x}}, \textbf{\textit{y}}) := (1/n) \sum_{i = 1}^{n} L(x_i, y_i)

where

x=(x1,...,xn)T\textbf{\textit{x}} = (x_1, ..., x_n)^\mathsf{T}

y=(y1,...,yn)T\textbf{\textit{y}} = (y_1, ..., y_n)^\mathsf{T}

and

L(x,y):=(xy)2L(x, y) := (x - y)^2

Domain of function:

xRn\textbf{\textit{x}} \in \mathbb{R}^n

yRn\textbf{\textit{y}} \in \mathbb{R}^n

Range of function:

S(x,y)0,x,yRnS(\textbf{\textit{x}}, \textbf{\textit{y}}) \geq 0, \forall \textbf{\textit{x}}, \textbf{\textit{y}} \in \mathbb{R}^n

Value

Value of the mean squared error.

Note

For details on the squared error scoring function, see serr_sf.

The concept of realised (average) scores is defined by Gneiting (2011) and Fissler and Ziegel (2019).

The mean squared error is the realised (average) score corresponding to the squared error scoring function.

References

Fissler T, Ziegel JF (2019) Order-sensitivity and equivariance of scoring functions. Electronic Journal of Statistics 13(1):1166–1211. doi:10.1214/19-EJS1552.

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 mean squared error.

set.seed(12345)

x <- 0

y <- rnorm(n = 100, mean = 0, sd = 1)

print(mse(x = x, y = y))

print(mse(x = rep(x = x, times = 100), y = y))

Mean squared percentage error (MSPE)

Description

The function mspe computes the mean squared percentage error when y\textbf{\textit{y}} materialises and x\textbf{\textit{x}} is the prediction.

Mean squared percentage error is a realised score corresponding to the squared percentage error scoring function sperr_sf.

Usage

mspe(x, y)

Arguments

x

Prediction. It can be a vector of length nn (must have the same length as y\textbf{\textit{y}}).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as x\textbf{\textit{x}}).

Details

The mean squared percentage error is defined by:

S(x,y):=(1/n)i=1nL(xi,yi)S(\textbf{\textit{x}}, \textbf{\textit{y}}) := (1/n) \sum_{i = 1}^{n} L(x_i, y_i)

where

x=(x1,...,xn)T\textbf{\textit{x}} = (x_1, ..., x_n)^\mathsf{T}

y=(y1,...,yn)T\textbf{\textit{y}} = (y_1, ..., y_n)^\mathsf{T}

and

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

Domain of function:

x>0\textbf{\textit{x}} > \textbf{0}

y>0\textbf{\textit{y}} > \textbf{0}

where

0=(0,...,0)T\textbf{0} = (0, ..., 0)^\mathsf{T}

is the zero vector of length nn and the symbol >> indicates pairwise inequality.

Range of function:

S(x,y)0,x,y>0S(\textbf{\textit{x}}, \textbf{\textit{y}}) \geq 0, \forall \textbf{\textit{x}}, \textbf{\textit{y}} > \textbf{0}

Value

Value of the mean squared percentage error.

Note

For details on the squared percentage error scoring function, see sperr_sf.

The concept of realised (average) scores is defined by Gneiting (2011) and Fissler and Ziegel (2019).

The mean squared percentage error is the realised (average) score corresponding to the squared percentage error scoring function.

References

Fissler T, Ziegel JF (2019) Order-sensitivity and equivariance of scoring functions. Electronic Journal of Statistics 13(1):1166–1211. doi:10.1214/19-EJS1552.

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 mean squared percentage error.

set.seed(12345)

x <- 0.5

y <- rlnorm(n = 100, mean = 0, sdlog = 1)

print(mspe(x = x, y = y))

print(mspe(x = rep(x = x, times = 100), y = y))

Mean squared relative error (MSRE)

Description

The function msre computes the mean squared relative error when y\textbf{\textit{y}} materialises and x\textbf{\textit{x}} is the prediction.

Mean squared relative error is a realised score corresponding to the squared relative error scoring function srelerr_sf.

Usage

msre(x, y)

Arguments

x

Prediction. It can be a vector of length nn (must have the same length as y\textbf{\textit{y}}).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as x\textbf{\textit{x}}).

Details

The mean squared relative error is defined by:

S(x,y):=(1/n)i=1nL(xi,yi)S(\textbf{\textit{x}}, \textbf{\textit{y}}) := (1/n) \sum_{i = 1}^{n} L(x_i, y_i)

where

x=(x1,...,xn)T\textbf{\textit{x}} = (x_1, ..., x_n)^\mathsf{T}

y=(y1,...,yn)T\textbf{\textit{y}} = (y_1, ..., y_n)^\mathsf{T}

and

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

Domain of function:

x>0\textbf{\textit{x}} > \textbf{0}

y>0\textbf{\textit{y}} > \textbf{0}

where

0=(0,...,0)T\textbf{0} = (0, ..., 0)^\mathsf{T}

is the zero vector of length nn and the symbol >> indicates pairwise inequality.

Range of function:

S(x,y)0,x,y>0S(\textbf{\textit{x}}, \textbf{\textit{y}}) \geq 0, \forall \textbf{\textit{x}}, \textbf{\textit{y}} > \textbf{0}

Value

Value of the mean squared relative error.

Note

For details on the squared relative error scoring function, see srelerr_sf.

The concept of realised (average) scores is defined by Gneiting (2011) and Fissler and Ziegel (2019).

The mean squared relative error is the realised (average) score corresponding to the squared relative error scoring function.

References

Fissler T, Ziegel JF (2019) Order-sensitivity and equivariance of scoring functions. Electronic Journal of Statistics 13(1):1166–1211. doi:10.1214/19-EJS1552.

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 mean squared relative error.

set.seed(12345)

x <- 0.5

y <- rlnorm(n = 100, mean = 0, sdlog = 1)

print(msre(x = x, y = y))

print(msre(x = rep(x = x, times = 100), y = y))

Mean - variance identification function

Description

The function mv_if computes the mean - variance identification function, when yy materialises, x1x_1 is the predictive mean and x2x_2 is the predictive variance.

The mean - variance identification function is defined in proposition (3.11) in Fissler and Ziegel (2019).

Usage

mv_if(x1, x2, y)

Arguments

x1

Predictive mean (prediction). It can be a vector of length nn (must have the same length as yy).

x2

Predictive variance (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as x1x_1).

Details

The mean - variance identification function is defined by:

V(x1,x2,y):=(x1y,x2+x12y2)V(x_1, x_2, y) := (x_1 - y, x_2 + x_1^2 - y^2)

Domain of function:

x1Rx_1 \in \mathbb{R}

x2>0x_2 > 0

yRy \in \mathbb{R}

Value

Matrix of mean - variance values of the identification function.

Note

The mean functional is the mean EF[Y]\textnormal{E}_F[Y] of the probability distribution FF of yy (Gneiting 2011).

The variance functional is the variance VarF[Y]:=EF[Y2](EF[Y])2\textnormal{Var}_F[Y] := \textnormal{E}_F[Y^2] - (\textnormal{E}_F[Y])^{2} of the probability distribution FF of yy (Gneiting 2011)

The mean - variance identification function is a strict F\mathbb{F}-identification function for the pair (mean, variance) functional (Gneiting 2011; Fissler and Ziegel 2019; Dimitriadis et al. 2024).

F\mathbb{F} is the family of probability distributions FF for which EF[Y]\textnormal{E}_F[Y] and EF[Y2]\textnormal{E}_F[Y^2] exist and are finite (Gneiting 2011; Fissler and Ziegel 2019; Dimitriadis et al. 2024).

References

Dimitriadis T, Fissler T, Ziegel JF (2024) Osband's principle for identification functions. Statistical Papers 65:1125–1132. doi:10.1007/s00362-023-01428-x.

Fissler T, Ziegel JF (2019) Order-sensitivity and equivariance of scoring functions. Electronic Journal of Statistics 13(1):1166–1211. doi:10.1214/19-EJS1552.

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 mean - variance identification function.

df <- data.frame(
    y = rep(x = 0, times = 6),
    x1 = c(2, 2, -2, -2, 0, 0),
    x2 = c(1, 2, 1, 2, 1, 2)
)

v <- as.data.frame(mv_if(x1 = df$x1, x2 = df$x2, y = df$y))

print(cbind(df, v))

Mean - variance scoring function

Description

The function mv_sf computes the mean - variance scoring function, when yy materialises, x1x_1 is the predictive mean and x2x_2 is the predictive variance.

The mean - variance scoring function is defined by eq. (3.11) in Fissler and Ziegel (2019).

Usage

mv_sf(x1, x2, y)

Arguments

x1

Predictive mean (prediction). It can be a vector of length nn (must have the same length as yy).

x2

Predictive variance (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as x1x_1).

Details

The mean - variance scoring function is defined by:

S(x1,x2,y):=x22(x122x22x1y+y2)S(x_1, x_2, y) := x_2^{-2} (x_1^2 - 2 x_2 - 2 x_1 y + y^2)

Domain of function:

x1Rx_1 \in \mathbb{R}

x2>0x_2 > 0

yRy \in \mathbb{R}

Value

Vector of mean - variance losses.

Note

The mean functional is the mean EF[Y]\textnormal{E}_F[Y] of the probability distribution FF of yy (Gneiting 2011).

The variance functional is the variance VarF[Y]:=EF[Y2](EF[Y])2\textnormal{Var}_F[Y] := \textnormal{E}_F[Y^2] - (\textnormal{E}_F[Y])^{2} of the probability distribution FF of yy (Gneiting 2011)

The mean - variance scoring function is negatively oriented (i.e. the smaller, the better).

The mean - variance scoring function is strictly consistent for the pair (mean, variance) functional (Osband 1985, p.9; Gneiting 2011; Fissler and Ziegel 2019).

References

Fissler T, Ziegel JF (2019) Order-sensitivity and equivariance of scoring functions. Electronic Journal of Statistics 13(1):1166–1211. doi:10.1214/19-EJS1552.

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

Osband KH (1985) Providing Incentives for Better Cost Forecasting. PhD thesis, University of California, Berkeley. doi:10.5281/zenodo.4355667.

Examples

# Compute the mean - variance scoring function.

df <- data.frame(
    y = rep(x = 0, times = 6),
    x1 = c(2, 2, -2, -2, 0, 0),
    x2 = c(1, 2, 1, 2, 1, 2)
)

df$mv_penalty <- mv_sf(x1 = df$x1, x2 = df$x2, y = df$y)

print(df)

nn-th moment identification function

Description

The function nmoment_if computes the nn-th moment identification function, when yy materialises and xx is the predictive nn-th moment.

The expectile identification function is defined in Table 9 in Gneiting (2011) by setting r(t)=tnr(t) = t^n and s(t)=1s(t) = 1.

Usage

nmoment_if(x, y, n)

Arguments

x

Predictive nn-th moment. It can be a vector of length mm (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length mm (must have the same length as xx).

n

nn) is the moment order. It can be a vector of length mm (must have the same length as xx).

Details

The nn-th moment identification function is defined by:

V(x,y,n):=xynV(x, y, n) := x - y^n

Domain of function:

xRx \in \mathbb{R}

yRy \in \mathbb{R}

nNn \in \mathbb{N}

Value

Vector of values of the nn-th moment identification function.

Note

The nn-th moment functional is the expectation EF[Yn]\textnormal{E}_F[Y^n] of the probability distribution FF of yy.

The nn-th moment identification function is a strict F\mathbb{F}-identification function for the nn-th moment functional (Gneiting 2011; Fissler and Ziegel 2016).

F\mathbb{F} is the family of probability distributions FF for which EF[Yn]\textnormal{E}_F[Y^n] exists and is finite (Gneiting 2011; Fissler and Ziegel 2016).

References

Fissler T, Ziegel JF (2016) Higher order elicitability and Osband's principle. The Annals of Statistics 44(4):1680–1707. doi:10.1214/16-AOS1439.

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 n-th moment scoring function.

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

df$nmoment_if <- nmoment_if(x = df$x, y = df$y, n = df$n)

print(df)

nn-th moment scoring function

Description

The function nmoment_sf computes the nn-th moment scoring function, when yy materialises, and EF[Yn]\textnormal{E}_F[Y^n] is the predictive nn-th moment.

The nn-th moment scoring function is defined by eq. (22) in Gneiting (2011) by setting r(t)=tnr(t) = t^n, s(t)=1s(t) = 1, ϕ(t)=t2\phi(t) = t^2 and removing all terms that are not functions of xx.

Usage

nmoment_sf(x, y, n)

Arguments

x

Predictive nn-th moment. It can be a vector of length mm (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length mm (must have the same length as xx).

n

nn) is the moment order. It can be a vector of length mm (must have the same length as xx).

Details

The nn-th moment scoring function is defined by:

S(x,y,n):=x22x(ynx)S(x, y, n) := -x^2 - 2 x (y^n - x)

Domain of function:

xRx \in \mathbb{R}

yRy \in \mathbb{R}

nNn \in \mathbb{N}

Value

Vector of nn-th moment losses.

Note

The nn-th moment functional is the expectation EF[Yn]\textnormal{E}_F[Y^n] of the probability distribution FF of yy.

The nn-th moment scoring function is negatively oriented (i.e. the smaller, the better).

The nn-th moment scoring function is strictly F\mathbb{F}-consistent for the nn-th moment functional EF[Yn]\textnormal{E}_F[Y^n] (Theorem 8 in Gneiting 2011). F\mathbb{F} is the family of probability distributions FF for which EF[Y]\textnormal{E}_F[Y^], EF[Y2]\textnormal{E}_F[Y^2], EF[Yn]\textnormal{E}_F[Y^n] and EF[Yn+1]\textnormal{E}_F[Y^{n + 1}] exist and are finite (Theorem 8 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 n-th moment scoring function.

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

df$nmoment_penalty <- nmoment_sf(x = df$x, y = df$y, n = df$n)

print(df)

Nash-Sutcliffe efficiency (NSE)

Description

The function nse computes the Nash-Sutcliffe efficiency when y\textbf{\textit{y}} materialises and x\textbf{\textit{x}} is the prediction.

Nash-Sutcliffe efficiency is a skill score corresponding to the squared error scoring function serr_sf. It is defined in eq. (3) in Nash and Sutcliffe (1970).

Usage

nse(x, y)

Arguments

x

Prediction. It can be a vector of length nn (must have the same length as y\textbf{\textit{y}}).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as x\textbf{\textit{x}}).

Details

The Nash-Sutcliffe efficiency is defined by:

Sskill(x,y):=1Smeth(x,y)/Sref(x,y)S_{\textnormal{skill}}(\textbf{\textit{x}}, \textbf{\textit{y}}) := 1 - S_{\textnormal{meth}}(\textbf{\textit{x}}, \textbf{\textit{y}}) / S_{\textnormal{ref}}(\textbf{\textit{x}}, \textbf{\textit{y}})

where

x=(x1,...,xn)T\textbf{\textit{x}} = (x_1, ..., x_n)^\mathsf{T}

y=(y1,...,yn)T\textbf{\textit{y}} = (y_1, ..., y_n)^\mathsf{T}

1=(1,...,1)T\textbf{1} = (1, ..., 1)^\mathsf{T}

y:=(1/n)1Ty=(1/n)i=1nyi\overline{\textbf{\textit{y}}} := (1/n) \textbf{1}^\mathsf{T} \textbf{\textit{y}} = (1/n) \sum_{i = 1}^{n} y_i

L(x,y):=(xy)2L(x, y) := (x - y)^2

and the predictions of the method of interest as well as the reference method are evaluated respectively by:

Smeth(x,y):=(1/n)i=1nL(xi,yi)S_{\textnormal{meth}}(\textbf{\textit{x}}, \textbf{\textit{y}}) := (1/n) \sum_{i = 1}^{n} L(x_i, y_i)

Sref(x,y):=(1/n)i=1nL(y,yi)S_{\textnormal{ref}}(\textbf{\textit{x}}, \textbf{\textit{y}}) := (1/n) \sum_{i = 1}^{n} L(\overline{\textbf{\textit{y}}}, y_i)

Domain of function:

xRn\textbf{\textit{x}} \in \mathbb{R}^n

yRn\textbf{\textit{y}} \in \mathbb{R}^n

Range of function:

S(x,y)1,x,yRnS(\textbf{\textit{x}}, \textbf{\textit{y}}) \leq 1, \forall \textbf{\textit{x}}, \textbf{\textit{y}} \in \mathbb{R}^n

Value

Value of the Nash-Sutcliffe efficiency.

Note

For details on the squared error scoring function, see serr_sf.

The concept of skill scores is defined by Gneiting (2011).

The Nash-Sutcclife efficiency is defined in eq. (3) in Nash and Sutcliffe (1970).

The Nash-Sutcclife efficiency is positevely oriented (i.e. the larger, the better).

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.

Nash JE, Sutcliffe JV (1970) River flow forecasting through conceptual models part I - A discussion of principles. Journal of Hydrology 10(3):282–290. doi:10.1016/0022-1694(70)90255-6.

Examples

# Compute the Nash-Sutcliffe efficiency.

set.seed(12345)

x <- 0

y <- rnorm(n = 100, mean = 0, sd = 1)

print(nse(x = x, y = y))

print(nse(x = rep(x = x, times = 100), y = y))

print(nse(x = mean(y), y = y))

print(nse(x = y, y = y))

Observation-weighted scoring function

Description

The function obsweighted_sf computes the observation-weighted scoring function when yy materialises and xx is the predictive EF[Y2]EF[Y]\dfrac{\textnormal{E}_F [Y^{2}]}{\textnormal{E}_F [Y]} functional.

The observation-weighted scoring function is defined in p. 752 in Gneiting (2011).

Usage

obsweighted_sf(x, y)

Arguments

x

Predictive EF[Y2]EF[Y]\dfrac{\textnormal{E}_F [Y^{2}]}{\textnormal{E}_F [Y]} functional (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

Details

The observation-weighted scoring function is defined by:

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

Domain of function:

x>0x > 0

y>0y > 0

Range of function:

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

Value

Vector of observation-weighted errors.

Note

For details on the observation-weighted scoring function, see Gneiting (2011).

The observation-weighted scoring function is negatively oriented (i.e. the smaller, the better).

The observation-weighted scoring function is strictly consistent for the EF[Y2]EF[Y]\dfrac{\textnormal{E}_F [Y^{2}]}{\textnormal{E}_F [Y]} functional.

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 observation-weighted scoring function.

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

df$squared_relative_error <- obsweighted_sf(x = df$x, y = df$y)

print(df)

Quantile identification function

Description

The function quantile_if computes the quantile identification function at a specific level pp, when yy materialises and xx is the predictive quantile at level pp.

The quantile identification function is defined in Table 9 in Gneiting (2011).

Usage

quantile_if(x, y, p)

Arguments

x

Predictive quantile (prediction) at level pp. It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

p

It can be a vector of length nn (must have the same length as yy).

Details

The quantile identification function is defined by:

V(x,y,p):=1{xy}pV(x, y, p) := \textbf{1} \lbrace x \geq y \rbrace - p

Domain of function:

xRx \in \mathbb{R}

yRy \in \mathbb{R}

0<p<10 < p < 1

Range of function:

V(x,y,p)(1,1)V(x, y, p) \in (-1, 1)

Value

Vector of values of the quantile identification function.

Note

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

The quantile identification function is a strict Fp\mathbb{F}_p-identification function for the pp-quantile functional (Gneiting 2011; Fissler and Ziegel 2016; Dimitriadis et al. 2024).

Fp\mathbb{F}_p is the family of probability distributions FF for which there exists an yy with F(y)=pF(y) = p (Gneiting 2011; Fissler and Ziegel 2016; Dimitriadis et al. 2024).

References

Dimitriadis T, Fissler T, Ziegel JF (2024) Osband's principle for identification functions. Statistical Papers 65:1125–1132. doi:10.1007/s00362-023-01428-x.

Fissler T, Ziegel JF (2016) Higher order elicitability and Osband's principle. The Annals of Statistics 44(4):1680–1707. doi:10.1214/16-AOS1439.

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

Koenker R, Bassett Jr G (1978) Regression quantiles. Econometrica 46(1):33–50. doi:10.2307/1913643.

Examples

# Compute the quantile identification function.

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

df$quantile_if <- quantile_if(x = df$x, y = df$y, p = df$p)

Sample quantile level function

Description

The function quantile_level computes the sample quantile level, when y\textbf{\textit{y}} materialises and x\textbf{\textit{x}} is the predictive quantile at level pp.

Usage

quantile_level(x, y)

Arguments

x

Predictive quantile (prediction) at level pp. It can be a vector of length nn (must have the same length as y\textbf{\textit{y}}).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as x\textbf{\textit{x}}).

Details

The sample quantile level function is defined by:

P(x,y):=(1/n)i=1nV(xi,yi)P(x, y) := (1/n) \sum_{i = 1}^{n} V(x_i, y_i)

where

x=(x1,...,xn)T\textbf{\textit{x}} = (x_1, ..., x_n)^\mathsf{T}

y=(y1,...,yn)T\textbf{\textit{y}} = (y_1, ..., y_n)^\mathsf{T}

and

V(x,y):=1{xy}V(x, y) := \textbf{1} \lbrace x \geq y \rbrace

Domain of function:

xRn\textbf{\textit{x}} \in \mathbb{R}^n

yRn\textbf{\textit{y}} \in \mathbb{R}^n

Value

Value of the sample quantile level.

Note

The sample quantile level is directly related to the quantile identification function quantile_if.

If y\textbf{\textit{y}} materialises and x\textbf{\textit{x}} is the predictive quantile at level pp, then ideally, the sample quantile level should be equal to the nominal quantile level pp.

Examples

# Compute the sample quantile level.

set.seed(12345)

x <- qnorm(p = 0.75, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)

y <- rnorm(n = 1000, mean = 0, sd = 1)

print(quantile_level(x = x, y = y))

Realised quantile score

Description

The function quantile_rs computes the realised quantile score at a specific level pp when y\textbf{\textit{y}} materialises and x\textbf{\textit{x}} is the prediction.

Realised quantile score is a realised score corresponding to the quantile scoring function quantile_sf.

Usage

quantile_rs(x, y, p)

Arguments

x

Prediction. It can be a vector of length nn (must have the same length as y\textbf{\textit{y}}).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as x\textbf{\textit{x}}).

p

It can be a vector of length nn (must have the same length as y\textbf{\textit{y}}) or a scalar value.

Details

The realized quantile score is defined by:

S(x,y,p):=(1/n)i=1nL(xi,yi,p)S(\textbf{\textit{x}}, \textbf{\textit{y}}, p) := (1/n) \sum_{i = 1}^{n} L(x_i, y_i, p)

where

x=(x1,...,xn)T\textbf{\textit{x}} = (x_1, ..., x_n)^\mathsf{T}

y=(y1,...,yn)T\textbf{\textit{y}} = (y_1, ..., y_n)^\mathsf{T}

and

L(x,y,p):=(1{xy}p)(xy)L(x, y, p) := (\textbf{1} \lbrace x \geq y \rbrace - p) (x - y)

Domain of function:

xRn\textbf{\textit{x}} \in \mathbb{R}^n

yRn\textbf{\textit{y}} \in \mathbb{R}^n

0<p<10 < p < 1

Range of function:

S(x,y,p)0,x,yRn,p(0,1)S(\textbf{\textit{x}}, \textbf{\textit{y}}, p) \geq 0, \forall \textbf{\textit{x}}, \textbf{\textit{y}} \in \mathbb{R}^n, p \in (0, 1)

Value

Value of the realised quantile score.

Note

For details on the quantile scoring function, see quantile_sf.

The concept of realised (average) scores is defined by Gneiting (2011) and Fissler and Ziegel (2019).

The realised quantile score is the realised (average) score corresponding to the quantile scoring function.

References

Fissler T, Ziegel JF (2019) Order-sensitivity and equivariance of scoring functions. Electronic Journal of Statistics 13(1):1166–1211. doi:10.1214/19-EJS1552.

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 realised quantile score.

set.seed(12345)

x <- qnorm(p = 0.7, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)

y <- rnorm(n = 1000, mean = 0, sd = 1)

print(quantile_rs(x = x, y = y, p = 0.7))

print(quantile_rs(x = rep(x = x, times = 1000), y = y, p = 0.7))

print(quantile_rs(x = rep(x = x, times = 1000) - 0.1, y = y, p = 0.7))

Asymmetric piecewise linear scoring function (quantile scoring function, quantile loss function)

Description

The function quantile_sf computes the asymmetric piecewise linear scoring function (quantile scoring function) at a specific level pp, when yy materialises and xx is the predictive quantile at level pp.

The asymmetric piecewise linear scoring function is defined by eq. (24) in Gneiting (2011).

Usage

quantile_sf(x, y, p)

Arguments

x

Predictive quantile (prediction) at level pp. It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

p

It can be a vector of length nn (must have the same length as yy).

Details

The assymetric piecewise linear scoring function is defined by:

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

or equivalently,

S(x,y,p):=pmax{(xy),0}+(1p)max{xy,0}S(x, y, p) := p | \max \lbrace -(x - y), 0 \rbrace | + (1 - p) | \max \lbrace x - y, 0 \rbrace |

Domain of function:

xRx \in \mathbb{R}

yRy \in \mathbb{R}

0<p<10 < p < 1

Range of function:

S(x,y,p)0,x,yR,p(0,1)S(x, y, p) \geq 0, \forall x, y \in \mathbb{R}, p \in (0, 1)

Value

Vector of quantile losses.

Note

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

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

The asymmetric piecewise linear scoring function is strictly F\mathbb{F}-consistent for the pp-quantile functional. F\mathbb{F} is the family of probability distributions FF for which EF[Y]\textnormal{E}_F[Y] exists and is finite (Schlaifer 1961, p.196; Ferguson 1967, p.51; Thomson 1979; Saerens 2000; Gneiting 2011).

References

Ferguson TS (1967) Mathematical Statistics: A Decision-Theoretic Approach. Academic Press, New York.

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

Koenker R, Bassett Jr G (1978) Regression quantiles. Econometrica 46(1):33–50. doi:10.2307/1913643.

Raiffa H,Schlaifer R (1961) Applied Statistical Decision Theory. Colonial Press, Clinton.

Saerens M (2000) Building cost functions minimizing to some summary statistics. IEEE Transactions on Neural Networks 11(6):1263–1271. doi:10.1109/72.883416.

Thomson W (1979) Eliciting production possibilities from a well-informed manager. Journal of Economic Theory 20(3):360–380. doi:10.1016/0022-0531(79)90042-5.

Examples

# Compute the asymmetric piecewise linear scoring function (quantile scoring
# function).

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

df$quantile_penalty <- quantile_sf(x = df$x, y = df$y, p = df$p)

print(df)

# The absolute error scoring function is twice the asymmetric piecewise linear
# scoring function (quantile scoring function) at level p = 0.5.

df <- data.frame(
    y = rep(x = 0, times = 3),
    x = c(-2, 0, 2),
    p = rep(x = c(0.5), times = 3)
)

df$quantile_penalty <- quantile_sf(x = df$x, y = df$y, p = df$p)

df$absolute_error <- aerr_sf(x = df$x, y = df$y)

print(df)

Relative error scoring function (MAE-PROP scoring function)

Description

The function relerr_sf computes the relative error scoring function when yy materialises and xx is the predictive med(1)(F)\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)

Arguments

x

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

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

Details

The relative error scoring function is defined by:

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

Domain of function:

x>0x > 0

y>0y > 0

Range of function:

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

Value

Vector of relative errors.

Note

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

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

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

The relative error scoring function is strictly F(w)\mathbb{F}^{(w)}-consistent for the med(1)(F)\textnormal{med}^{(1)}(F) functional. F\mathbb{F} is the family of probability distributions for which EF[Y]\textnormal{E}_F[Y] exists and is finite. F(w)\mathbb{F}^{(w)} is the subclass of probability distributions in F\mathbb{F}, which are such that w(y)f(y)w(y) f(y), w(y)=yw(y) = y has finite integral over (0,)(0, \infty), and the probability distribution F(w)F^{(w)} with density proportional to w(y)f(y)w(y) f(y) belongs to F\mathbb{F} (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.

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

Examples

# 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)

Squared error scoring function

Description

The function serr_sf computes the squared error scoring function when yy materialises and xx is the predictive mean functional.

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

Usage

serr_sf(x, y)

Arguments

x

Predictive mean functional (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

Details

The squared error scoring function is defined by:

S(x,y):=(xy)2S(x, y) := (x - y)^2

Domain of function:

xRx \in \mathbb{R}

yRy \in \mathbb{R}

Range of function:

S(x,y)0,x,yRS(x, y) \geq 0, \forall x, y \in \mathbb{R}

Value

Vector of squared errors.

Note

For details on the squared error scoring function, see Savage (1971), Gneiting (2011).

The mean functional is the mean EF[Y]\textnormal{E}_F[Y] of the probability distribution FF of yy (Gneiting 2011).

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

The squared error scoring function is strictly F\mathbb{F}-consistent for the mean functional. F\mathbb{F} is the family of probability distributions FF for which the second moment exists and is finite (Savage 1971; 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.

Savage LJ (1971) Elicitation of personal probabilities and expectations. Journal of the American Statistical Association 66(337):783–810. doi:10.1080/01621459.1971.10482346.

Examples

# Compute the squarer error scoring function.

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

df$squared_error <- serr_sf(x = df$x, y = df$y)

print(df)

Squared error exp scoring function

Description

The function serrexp_sf computes the squared error exp scoring function when yy materialises and xx is the (1/a)log(EF[exp(aY)])(1/a) \log(\textnormal{E}_F[\exp(aY)]) predictive entropic risk measure (Gerber 1974).

The squared error exp scoring function is defined in Fissler and Pesenti (2023).

Usage

serrexp_sf(x, y, a)

Arguments

x

Predictive (1/a)log(EF[exp(aY)])(1/a) \log(\textnormal{E}_F[\exp(aY)]) functional (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

a

It can be a vector of length nn (must have the same length as yy).

Details

The squared error exp scoring function is defined by:

S(x,y):=(exp(ax)exp(ay))2S(x, y) := (\exp(ax) - \exp(ay))^2

Domain of function:

xRx \in \mathbb{R}

yRy \in \mathbb{R}

a0a \neq 0

Range of function:

S(x,y)0,x,yR,a0S(x, y) \geq 0, \forall x, y \in \mathbb{R}, a \neq 0

Value

Vector of squared errors of exp-transformed variables.

Note

For details on the squared error exp scoring function, see Fissler and Pesenti (2023).

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

The squared error exp scoring function is strictly F\mathbb{F}-consistent for the (1/a)log(EF[exp(aY)])(1/a) \log(\textnormal{E}_F[\exp(aY)]) entropic risk measure functional. F\mathbb{F} is the family of probability distributions FF for which EF[exp(aY)]\textnormal{E}_F[\exp(aY)] exists and is finite (Fissler and Pesenti 2023; Tyralis and Papacharalampous 2025).

References

Fissler T, Pesenti SM (2023) Sensitivity measures based on scoring functions. European Journal of Operational Research 307(3):1408–1423. doi:10.1016/j.ejor.2022.10.002.

Gerber HU (1974) On additive premium calculation principles. ASTIN Bulletin: The Journal of the IAA 7(3):215–222. doi:10.1017/S0515036100006061.

Tyralis H, Papacharalampous G (2025) Transformations of predictions and realizations in consistent scoring functions. doi:10.48550/arXiv.2502.16542.

Examples

# Compute the squarer error exp scoring function.

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

df$squaredexp_error <- serrexp_sf(x = df$x, y = df$y, a = df$a)

print(df)

Squared error log scoring function

Description

The function serrlog_sf computes the squared error log scoring function when yy materialises and xx is the exp(EF[log(Y)])\exp(\textnormal{E}_F[\log(Y)]) predictive functional.

The squared error log scoring function is defined in Houghton-Carr (1999).

Usage

serrlog_sf(x, y)

Arguments

x

Predictive exp(EF[log(Y)])\exp(\textnormal{E}_F[\log(Y)]) functional (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

Details

The squared error scoring function is defined by:

S(x,y):=(log(x)log(y))2S(x, y) := (\log(x) - \log(y))^2

Domain of function:

x>0x > 0

y>0y > 0

Range of function:

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

Value

Vector of squared errors of log-transformed variables.

Note

For details on the squared error log scoring function, see Houghton-Carr (1999).

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

The squared error log scoring function is strictly F\mathbb{F}-consistent for the exp(EF[log(Y)])\exp(\textnormal{E}_F[\log(Y)]) functional. F\mathbb{F} is the family of probability distributions FF for which EF[log(Y)]\textnormal{E}_F[\log(Y)] exists and is finite (Tyralis and Papacharalampous 2025).

References

Houghton-Carr HA (1999) Assessment criteria for simple conceptual daily rainfall-runoff models. Hydrological Sciences Journal 44(2):237–261. doi:10.1080/02626669909492220.

Tyralis H, Papacharalampous G (2025) Transformations of predictions and realizations in consistent scoring functions. doi:10.48550/arXiv.2502.16542.

Examples

# Compute the squarer error log scoring function.

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

df$squaredlog_error <- serrlog_sf(x = df$x, y = df$y)

print(df)

Squared error of power transformations scoring function

Description

The function serrpower_sf computes the squared error of power transformations scoring function when yy materialises and xx is the (EF[Ya])(1/a)(\textnormal{E}_F[Y^a])^{(1/a)} predictive functional.

The squared error of power transformations scoring function is defined in Tyralis and Papacharalampous (2025).

Usage

serrpower_sf(x, y, a)

Arguments

x

Predictive (EF[Ya])(1/a)(\textnormal{E}_F[Y^a])^{(1/a)} functional (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

a

It can be a vector of length nn (must have the same length as yy).

Details

The squared error of power transformations scoring function is defined by:

S(x,y):=(xaya)2S(x, y) := (x^a - y^a)^2

Domain of function:

Case #1

a>0a > 0

x0x \geq 0

y0y \geq 0

Case #2

a0a \neq 0

x>0x > 0

y>0y > 0

Range of function:

S(x,y)0,x,y,aS(x, y) \geq 0, \forall x, y, a

Value

Vector of squared errors of power-transformed variables.

Note

For details on the squared error of power tranformations scoring function, see Tyralis and Papacharalampous (2025).

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

The squared error of power transformations scoring function is strictly F\mathbb{F}-consistent for the (EF[Ya])(1/a)(\textnormal{E}_F[Y^a])^{(1/a)} functional. F\mathbb{F} is the family of probability distributions FF for which EF[Ya]\textnormal{E}_F[Y^a] exists and is finite (Tyralis and Papacharalampous 2025).

References

Tyralis H, Papacharalampous G (2025) Transformations of predictions and realizations in consistent scoring functions. doi:10.48550/arXiv.2502.16542.

Examples

# Compute the squarer error of power tranformations scoring function.

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

df$squaredpower_error <- serrpower_sf(x = df$x, y = df$y, a = df$a)

print(df)

Squared error of squares scoring function

Description

The function serrsq_sf computes the squared error of squares scoring function when yy materialises and xx is the EF[Y2]\sqrt{\textnormal{E}_F[Y^2]} predictive functional.

The squared error of squares scoring function is defined in Thirel et al. (2024).

Usage

serrsq_sf(x, y)

Arguments

x

Predictive EF[Y2]\sqrt{\textnormal{E}_F[Y^2]} functional (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

Details

The squared error of squares scoring function is defined by:

S(x,y):=(x2y2)2S(x, y) := (x^2 - y^2)^2

Domain of function:

x0x \geq 0

y0y \geq 0

Range of function:

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

Value

Vector of squared errors of squared-transformed variables.

Note

For details on the squared error of squares scoring function, see Thirel et al. (2024).

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

The squared error of squares scoring function is strictly F\mathbb{F}-consistent for the EF[Y2]\sqrt{\textnormal{E}_F[Y^2]} functional. F\mathbb{F} is the family of probability distributions FF for which EF[Y2]\textnormal{E}_F[Y^2] exists and is finite (Tyralis and Papacharalampous 2025).

References

Thirel G, Santos L, Delaigue O, Perrin C (2024) On the use of streamflow transformations for hydrological model calibration. Hydrology and Earth System Sciences 28(21):4837–4860. doi:10.5194/hess-28-4837-2024.

Tyralis H, Papacharalampous G (2025) Transformations of predictions and realizations in consistent scoring functions. doi:10.48550/arXiv.2502.16542.

Examples

# Compute the squarer error of squares scoring function.

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

df$squaredsq_error <- serrsq_sf(x = df$x, y = df$y)

print(df)

Squared percentage error scoring function

Description

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

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

Usage

sperr_sf(x, y)

Arguments

x

Predictive EF[Y1]EF[Y2]\dfrac{\textnormal{E}_F [Y^{-1}]}{\textnormal{E}_F [Y^{-2}]} functional (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

Details

The squared percentage error scoring function is defined by:

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

Domain of function:

x>0x > 0

y>0y > 0

Range of function:

S(x,y)0,x,y>0S(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 consistent for the EF[Y1]EF[Y2]\dfrac{\textnormal{E}_F [Y^{-1}]}{\textnormal{E}_F [Y^{-2}]} functional.

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.

Park H, Stefanski LA (1998) Relative-error prediction. Statistics and Probability Letters 40(3):227–236. doi:10.1016/S0167-7152(98)00088-1.

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)

Squared relative error scoring function

Description

The function srelerr_sf computes the squared relative error scoring function when yy materialises and xx is the predictive EF[Y2]EF[Y]\dfrac{\textnormal{E}_F [Y^{2}]}{\textnormal{E}_F [Y]} functional.

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

Usage

srelerr_sf(x, y)

Arguments

x

Predictive EF[Y2]EF[Y]\dfrac{\textnormal{E}_F [Y^{2}]}{\textnormal{E}_F [Y]} functional (prediction). It can be a vector of length nn (must have the same length as yy).

y

Realisation (true value) of process. It can be a vector of length nn (must have the same length as xx).

Details

The squared relative error scoring function is defined by:

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

Domain of function:

x>0x > 0

y>0y > 0

Range of function:

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

Value

Vector of squared relative errors.

Note

For details on the squared relative error scoring function, see Gneiting (2011).

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

The squared relative error scoring function is strictly consistent for the EF[Y2]EF[Y]\dfrac{\textnormal{E}_F [Y^{2}]}{\textnormal{E}_F [Y]} functional.

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 squared percentage error scoring function.

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

df$squared_relative_error <- srelerr_sf(x = df$x, y = df$y)

print(df)