ae | R Documentation |
This function calculates the Absolute Error (AE) given observations of a univariate variable and samples of a predictive distribution.
ae(y, x, na.action = na.omit, aggregate = FALSE, ...)
y |
vector of observations |
x |
matrix of samples of a predictive distribution or vector containing the medians of a predictive distribution (depending on |
na.action |
function to handle the NA's. Default: |
aggregate |
logical or function for aggregating the single scores, e.g. |
... |
further arguments passed to the |
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.
Vector of score value(s).
David Jobst
Gneiting, T. (2011). Making and Evaluating Point Forecasts. Journal of the American Statistical Association, 106(494), 746-762.
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.