quantile_level: Sample quantile level function

View source: R/quantile_level.R

quantile_levelR Documentation

Sample quantile level function

Description

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

Usage

quantile_level(x, y)

Arguments

x

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

y

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

Details

The sample quantile level function is defined by:

P(\textbf{\textit{x}}, \textbf{\textit{y}}) := (1/n) \sum_{i = 1}^{n} \textbf{1} \lbrace x_i \geq y_i \rbrace

where

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

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

Domain of function:

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

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

Range of function:

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

Value

Value of the sample quantile level.

Note

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

The sample quantile level is directly related to the quantile identification function quantile_if, which is defined in Table 9 in Gneiting (2011). The sample quantile level equals the sample mean of V(x_i, y_i, p) + p, where V is the quantile identification function at level p.

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

References

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

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

See Also

quantile_sf, quantile_rs, quantile_if

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

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