Absolute Error of the Median (Quantile-based Version)
Source:R/metrics_point_forecasts.R
ae_median_quantile.Rd
Absolute error of the median calculated as
$$ \textrm{abs}(\textrm{true\_value} - \textrm{prediction}) $$
The function was created for internal use within score()
, but can also
used as a standalone function.
Arguments
- true_values
A vector with the true observed values of size n
- predictions
numeric vector with predictions, corresponding to the quantiles in a second vector,
quantiles
.- quantiles
numeric vector that denotes the quantile for the values in
predictions
. Only those predictions wherequantiles == 0.5
will be kept. Ifquantiles
isNULL
, then allpredictions
andtrue_values
will be used (this is then the same asabs_error()
)
Examples
true_values <- rnorm(30, mean = 1:30)
predicted_values <- rnorm(30, mean = 1:30)
ae_median_quantile(true_values, predicted_values, quantiles = 0.5)
#> [1] 3.47510500 0.28068184 0.93335468 1.22943836 2.84521887 0.32402719
#> [7] 0.14085455 1.04966816 0.37742118 0.79855943 0.28783060 0.65382132
#> [13] 2.40279305 0.54249387 1.81005771 1.13580169 0.14585132 0.12718608
#> [19] 0.64715597 0.91204808 1.20566210 1.03688550 0.18887701 0.86094350
#> [25] 0.33551221 3.09532994 2.33869205 0.09274994 3.35978136 2.05511945