View source: R/capping_function.R
capping_function | R Documentation |
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).
capping_function(t, a, b)
t |
It can be a vector of length |
a |
It can be a vector of length |
b |
It can be a vector of length |
The capping function \kappa_{a,b}(t)
is defined by:
\kappa_{a,b}(t) := \max \lbrace \min \lbrace t,b \rbrace, -a \rbrace
or equivalently,
\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:
t \in \mathbb{R}
a \geq 0
b \geq 0
Vector of values of the capping function.
For the definition of the capping function, see Taggart (2022), p.205.
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 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.