ae: Absolute Error

View source: R/ae.R

aeR Documentation

Absolute Error

Description

This function calculates the Absolute Error (AE) given observations of a univariate variable and samples of a predictive distribution.

Usage

ae(y, x, na.action = na.omit, aggregate = FALSE, ...)

Arguments

y

vector of observations

x

matrix of samples of a predictive distribution or vector containing the medians of a predictive distribution (depending on y; see details)

na.action

function to handle the NA's. Default: na.omit.

aggregate

logical or function for aggregating the single scores, e.g. sum, mean, weighted.mean, .... Default: FALSE, i.e. no aggregation function.

...

further arguments passed to the aggregate function.

Details

For a vector y of length n, x can be given as matrix of samples of a predictive distribution with n rows, where the i-th entry of y belongs to the i-th row of x. The columns of x represent the samples of a predictive distribution. The row-wise medians are determined by its sample version.

If the medians of a predictive distribution are directly available, x can be given as vector containing the medians, where the i-th entry of y belongs to the i-th entry of x.

In addition, with this function, the Mean Absolute Error (MAE) can be calculated by specifying aggregate = mean.

A lower AE indicates a better forecast.

Value

Vector of score value(s).

Author(s)

David Jobst

References

Gneiting, T. (2011). Making and Evaluating Point Forecasts. Journal of the American Statistical Association, 106(494), 746-762.

Examples

# simulated data
n <- 30
m <- 50
y <- rnorm(n)
x1 <- matrix(rnorm(n*m), ncol = m)
x2 <- apply(x1, 1, median)

# ae calculation
ae(y = y, x = x1)
ae(y = y, x = x1, aggregate = mean)

ae(y = y, x = x2)
(mae <- ae(y = y, x = x2, aggregate = mean))


jobstdavid/eppverification documentation built on May 13, 2024, 5:20 p.m.