Skip to contents

Mean absolute percentage error (MAPE) averages absolute error relative to each observation.

Usage

mape(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{MAPE}=\frac{100}{n}\sum_{i=1}^n \left|\frac{obs_i-pred_i}{obs_i}\right|.$$

MAPE is a non-negative percentage; zero is ideal. It returns NA with a warning when any observation is zero and can disproportionately weight errors near zero. Missing-value handling follows bias().

References

Hyndman and Koehler (2006). See mdae().

See also