Skip to contents

Calculate absolute error as

$$ \textrm{abs}(\textrm{true\_value} - \textrm{median\_prediction}) $$

Usage

abs_error(true_values, predictions)

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.

Value

vector with the absolute error

Examples

true_values <- rnorm(30, mean = 1:30)
predicted_values <- rnorm(30, mean = 1:30)
abs_error(true_values, predicted_values)
#>  [1] 1.08488753 1.15199167 1.92403149 0.62962092 0.23432616 0.13554895
#>  [7] 0.04682360 2.21378005 0.07434221 0.49067812 1.74968080 1.50222189
#> [13] 1.80551422 0.55506233 0.63298925 0.79520169 0.88816028 2.66111545
#> [19] 1.92693777 1.59019699 0.32482219 0.76722258 4.09512836 0.82533673
#> [25] 0.57657000 0.64815083 4.57113179 1.25782447 1.07543324 1.42064327