Learn R Programming

SimDesign (version 0.4.1)

MAE: Compute the mean absolute error

Description

Computes the average absolute deviation of a sample estimate from the population value. Accepts observed and population values, as well as observed values which are in deviation form.

Usage

MAE(observed, population = NULL, type = "MAE")

Arguments

observed
a numeric vector or matrix/data.frame of parameter estimates. If a vector, the length is equal to the number of replications. If a matrix/data.frame, the number of rows must equal the number of replications
population
a numeric scalar/vector indicating the fixed population values. If a single value is supplied and observed is a matrix/data.frame then the value will be recycled for each column. If NULL, then it will be assumed that the observed
type
type of deviation to compute. Can be 'MAE' (default) for the mean absolute error, or 'NMSE' for the normalized MAE (MAE / (max(observed) - min(observed)))

Value

  • returns a numeric vector indicating the overall mean absolute error in the estimates

See Also

RMSE

Examples

Run this code
pop <- 1
samp <- rnorm(100, 1, sd = 0.5)
MAE(samp, pop)

dev <- samp - pop
MAE(dev)
MAE(samp, pop, type = 'NMAE')

# matrix input
mat <- cbind(M1=rnorm(100, 2, sd = 0.5), M2 = rnorm(100, 2, sd = 1))
MAE(mat, population = 2)

# same, but with data.frame
df <- data.frame(M1=rnorm(100, 2, sd = 0.5), M2 = rnorm(100, 2, sd = 1))
MAE(df, population = c(2,2))

Run the code above in your browser using DataLab