ae_median_quantile: Absolute error of the median (quantile-based version)

View source: R/metrics-quantile.R

ae_median_quantileR Documentation

Absolute error of the median (quantile-based version)

Description

Compute the absolute error of the median calculated as

|\text{observed} - \text{median prediction}|

The median prediction is the predicted value for which quantile_level == 0.5. The function requires 0.5 to be among the quantile levels in quantile_level.

Usage

ae_median_quantile(observed, predicted, quantile_level)

Arguments

observed

Numeric vector of size n with the observed values.

predicted

Numeric nxN matrix of predictive quantiles, n (number of rows) being the number of forecasts (corresponding to the number of observed values) and N (number of columns) the number of quantiles per forecast. If observed is just a single number, then predicted can just be a vector of size N.

quantile_level

Vector of of size N with the quantile levels for which predictions were made.

Value

Numeric vector of length N with the absolute error of the median.

Input format

metrics-quantile.png

Overview of required input format for quantile-based forecasts

See Also

ae_median_sample()

Examples

observed <- rnorm(30, mean = 1:30)
predicted_values <- replicate(3, rnorm(30, mean = 1:30))
ae_median_quantile(
  observed, predicted_values, quantile_level = c(0.2, 0.5, 0.8)
)

epiforecasts/scoringutils documentation built on Dec. 11, 2024, 11:12 a.m.