capping_function {scoringfunctions} | R Documentation |
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 |
a |
It can be a vector of length |
b |
It can be a vector of length |
Details
The capping function \kappa_{a,b}(t)
is defined by:
\kappa_{a,b}(t) := \max \lbrace \min \lbrace t,b \rbrace, -a \rbrace
Domain of function:
t \in \R
a \geq 0
b \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)