mape: MAPE

Description Usage Arguments Value Examples

Description

Calculates the Mean Absolute Percentage Error(MAPE) between x and the target.

Usage

1
mape(x, target, na.rm = FALSE)

Arguments

x

numeric vector; the forecast to evaluate

target

numeric vector; the target values

na.rm

logical; should NAs be removed before calculation?

Value

An atomic numeric vector containing the calculated MAPE

Examples

1
2
3
4
5
6
## Not run: mape(c(1, 2, 3))            #> Error: different lengths (3, 0)
mape(c(1, 2, 3), c(1, 4, 4))          #> 25.0
mape(c(1, 2, NA, 4), c(2, 2, 5, NA))  #> NA
mape(c(1, 2, NA, 4),
     c(2, 2, 5, NA),
     na.rm = TRUE)                    #> 12.5

max-graham/metrics documentation built on May 5, 2019, 5:53 p.m.