Skip to contents

Mean absolute error (MAE) is the average absolute difference between observations and predictions.

Usage

mae(obs, pred, na.rm = TRUE)

Arguments

obs

Numeric observation vector.

pred

Numeric prediction vector paired with obs.

na.rm

Logical; remove incomplete pairs?

Value

One numeric value.

Details

$$\mathrm{MAE} = \frac{1}{n}\sum_{i = 1}^{n}|obs_i - pred_i|$$

MAE is non-negative and has the same units as the response variable. Zero indicates perfect predictions; smaller values indicate smaller typical prediction errors. Unlike mean error (ME), positive and negative errors cannot cancel. MAE gives each error equal weight and is therefore less sensitive to unusually large errors than rmse(). Interpret MAE alongside bias() to assess both typical error magnitude and systematic over- or underprediction. Missing-value handling follows bias().

References

Willmott, C. J. and Matsuura, K. (2005). Advantages of the mean absolute error (MAE) over the root mean square error (RMSE) in assessing average model performance. Climate Research, 30, 79-82. doi:10.3354/cr030079

Hodson, T. O. (2022). Root mean square error (RMSE) or mean absolute error (MAE): When to use them or not. Geoscientific Model Development, 15, 5481-5487. doi:10.5194/gmd-15-5481-2022

Examples

mae(1:3, c(1, 3, 2))
#> [1] 0.6666667