Skip to contents

Mean error (ME; also called bias) is the mean signed difference between observations and predictions, calculated as observation minus prediction.

Usage

bias(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{ME} = \frac{1}{n}\sum_{i = 1}^{n}(obs_i - pred_i)$$

An ME of zero indicates no average systematic error. Negative values indicate overprediction on average, whereas positive values indicate underprediction on average. ME has the same units as the response variable. Opposing errors can cancel, so interpret ME together with an unsigned error measure such as mae() or rmse(). Missing pairs are removed when na.rm = TRUE; otherwise the result is NA when any pair is missing.

References

Legates, D. R. and McCabe, G. J. (1999). Evaluating the use of goodness-of-fit measures in hydrologic and hydroclimatic model validation. Water Resources Research, 35(1), 233-241. doi:10.1029/1998WR900018

Examples

bias(c(1, 2, 3), c(1, 3, 2))
#> [1] 0