Skip to contents

Quantile loss evaluates a prediction for a specified conditional quantile. With quantile level tau, it is

Usage

pinball_loss(obs, pred, level = 0.5, na.rm = TRUE)

Arguments

obs

Numeric observation vector.

pred

Numeric prediction vector paired with obs.

level

Quantile level strictly between zero and one.

na.rm

Logical; remove incomplete pairs?

Value

One numeric loss; lower is better.

Details

$$L_\tau = \frac{1}{n}\sum_{i=1}^{n} \begin{cases}\tau(obs_i-pred_i), & obs_i-pred_i \geq 0\\ (\tau-1)(obs_i-pred_i), & obs_i-pred_i < 0.\end{cases}$$

It is non-negative and zero is ideal. Underprediction is penalized more when level is high; overprediction is penalized more when level is low. At level = 0.5, it equals one-half of mae(). Missing-value handling follows bias(). It returns NA with a warning when no valid pairs remain.

References

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