ghuber_sf | R Documentation |
The function ghuber_sf computes the generalized Huber scoring function at a
specific level p
and parameters a
and b
, when y
materialises and x
is the predictive Huber functional at level p
.
The generalized Huber scoring function is defined by eq. (4.7) in Taggart (2022)
for \phi(t) = t^2
.
ghuber_sf(x, y, p, a, b)
x |
Predictive Huber functional (prediction) at level |
y |
Realisation (true value) of process. It can be a vector of length
|
p |
It can be a vector of length |
a |
It can be a vector of length |
b |
It can be a vector of length |
The generalized Huber scoring function is defined by:
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) :=
|\textbf{1} \lbrace x \geq y \rbrace - p| f_{a,b}(x - y)
or
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
f_{a,b}(t) := \kappa_{a,b}(t) (2 t - \kappa_{a,b}(t))
and \kappa_{a,b}(t)
is the capping function defined by:
\kappa_{a,b}(t) := \max \lbrace \min \lbrace t,b \rbrace, -a \rbrace
Domain of function:
x \in \mathbb{R}
y \in \mathbb{R}
0 < p < 1
a > 0
b > 0
Range of function:
S(x, y, p, a, b) \geq 0, \forall x, y \in \mathbb{R}, p \in (0, 1), a, b > 0
Vector of generalized Huber losses.
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 \mathbb{F}
-consistent
for the p
-Huber functional. \mathbb{F}
is the family of probability
distributions F
for which \textnormal{E}_F[Y^2 - (Y - a)^2]
and
\textnormal{E}_F[Y^2 - (Y + b)^2]
(or equivalently
\textnormal{E}_F[Y]
) exist and are finite (Taggart 2022).
Taggart RJ (2022) Point forecasting and forecast evaluation with generalized Huber loss. Electronic Journal of Statistics 16:201–231. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1214/21-EJS1957")}.
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.