Shortcomings of the MAPE
------------------------

 * The MAPE, as a percentage, only makes sense for values where divisions and ratios make sense. It doesn't make sense to calculate percentages of temperatures, for instance, so you shouldn't use the MAPE to calculate the accuracy of a temperature forecast.

 * If just a single actual is zero, $A_t=0$, then you divide by zero in calculating the MAPE, which is undefined.

   It turns out that some forecasting software nevertheless reports a MAPE for such series, simply by dropping periods with zero actuals ([Hoover, 2006](https://ideas.repec.org/a/for/ijafaa/y2006i4p32-35.html)). Needless to say, this is *not* a good idea, as it implies that we don't care at all about what we forecasted if the actual was zero - but a forecast of $F_t=100$ and one of $F_t=1000$ may have very different implications. So check what your software does.

   If only a few zeros occur, you can use a weighted MAPE ([Kolassa & Schütz, 2007](https://ideas.repec.org/a/for/ijafaa/y2007i6p40-43.html)), which nevertheless has problems of its own. This also applies to the symmetric MAPE ([Goodwin & Lawton, 1999](http://www.sciencedirect.com/science/article/pii/S0169207099000072?via%3Dihub)).

 * MAPEs greater than 100% can occur. If you prefer to work with accuracy, which some people define as 100%-MAPE, then this may lead to negative accuracy, which people may have a hard time understanding. ([No, truncating accuracy at zero is *not* a good idea.](https://stats.stackexchange.com/q/248317/1352))

 * Model fitting relies on minimizing errors, which is often done using numerical optimizers that use first or second derivatives. [The MAPE is not everywhere differentiable, and its Hessian is zero wherever it *is* defined.](https://stats.stackexchange.com/q/316076/1352) This can throw optimizers off if we want to use the MAPE as an in-sample fit criterion.

   A possible mitigation may be [to use the log cosh loss function](https://stats.stackexchange.com/questions/316076/gradient-and-hessian-of-the-mape?noredirect=1#comment858709_316076), which is similar to the MAE but twice differentiable. Alternatively, [Zheng (2011)](https://doi.org/10.1007/s13042-011-0031-2) offer a way to approximate the MAE (or any other quantile loss) to arbitrary precision using a smooth function. If we know bounds on the actuals (which we do when fitting strictly positive historical data), we can therefore smoothly approximate the MAPE to arbitrary precision.

 * The MAPE treats overforecasts differently than underforecasts. Suppose our forecast is $F_t=2$, then an actual of $A_t=1$ will contribute $\text{APE}_t=100\%$ to the MAPE, but an actual of $A_t=3$ will contribute $\text{APE}_t=33\%$. Minimizing the MAPE thus creates an incentive towards smaller $F_t$ - if our actuals have an equal chance of being $A_t=1$ or $A_t=3$, then we will minimize the expected MAPE by forecasting $F_t=1.5$, not $F_t=2$, which is the expectation of our actuals. The MAPE thus is lower for biased than for unbiased forecasts. Minimizing it may lead to forecasts that are biased low.

Especially the last bullet point merits a little more thought. For this, we need to take a step back.

To start with, note that we don't know the future outcome perfectly, nor will we ever. So the future outcome follows a probability distribution. Our so-called *point forecast* $F_t$ is our attempt to summarize what we know about the future distribution (i.e., the *predictive distribution*) at time $t$ using a single number. The MAPE then is a quality measure of a whole sequence of such single-number-summaries of future distributions at times $t=1, \dots, n$.

The problem here is that people rarely explicitly say what a *good* one-number-summary of a future distribution is.

When you talk to forecast consumers, they will usually want $F_t$ to be correct "on average". That is, they want $F_t$ to be the expectation or the mean of the future distribution, rather than, say, its median.

Here's the problem: minimizing the MAPE will typically *not* incentivize us to output this expectation, but a quite different one-number-summary ([McKenzie, 2011](https://doi.org/10.1016/j.econlet.2011.08.010), [Kolassa, 2020](https://doi.org/10.1016/j.ijforecast.2019.02.017)). This happens for two different reasons.

 * Asymmetric future distributions. Suppose our true future distribution follows a stationary $(\mu=1,\sigma^2=1)$ lognormal distribution. The following picture shows a simulated time series, as well as the corresponding density.

 [![lognormal][1]][1]

 The horizontal lines give the optimal point forecasts, where "optimality" is defined as minimizing the expected error for various error measures.

  * The dashed line at $F_t=\exp(\mu+\frac{\sigma^2}{2})\approx 4.5$ minimizes the expected MSE. It is the expectation of the time series.
  * The dotted line at $F_t=\exp\mu\approx 2.7$ [minimizes the expected MAE. It is the median of the time series.](https://stats.stackexchange.com/q/355538/1352)
  * The dash-dotted line at $F_t=\exp(\mu-\sigma^2)=1.0$ minimizes the expected MAPE. It is the (-1)-median of the time series ([Gneiting, 2011](http://www.tandfonline.com/doi/abs/10.1198/jasa.2011.r10138), p. 752 with $\beta=-1$), which [in the specific case of a lognormal distribution happens to coincide with the mode of the distribution](https://stats.stackexchange.com/q/389315/1352).

 We see that the asymmetry of the future distribution, together with the fact that the MAPE differentially penalizes over- and underforecasts, implies that minimizing the MAPE will lead to *heavily* biased forecasts. ([Here is the calculation of optimal point forecasts in the gamma case.](https://stats.stackexchange.com/q/389318/1352))

 * Symmetric distribution with a high coefficient of variation. Suppose that $A_t$ comes from rolling a standard six-sided die at each time point $t$. The picture below again shows a simulated sample path:

 [![die roll][2]][2]

 In this case:

  * The dashed line at $F_t=3.5$ minimizes the expected MSE. It is the expectation of the time series.

  * Any forecast $3\leq F_t\leq 4$ (not shown in the graph) will minimize the expected MAE. All values in this interval are medians of the time series.
  
  * The dash-dotted line at $F_t=2$ minimizes the expected MAPE.

 We again see how minimizing the MAPE can lead to a biased forecast, because of the differential penalty it applies to over- and underforecasts. In this case, the problem does not come from an asymmetric distribution, but from the high coefficient of variation of our data-generating process.

 This is actually a simple illustration you can use to teach people about the shortcomings of the MAPE - just hand your attendees a few dice and have them roll. See [Kolassa & Martin (2011)](https://ideas.repec.org/a/for/ijafaa/y2011i23p21-27.html) for more information.

 * Finally, you should not use the MAPE, because by definition, the MAPE is a Mean APE... and *nobody* likes Mean APEs.

    [![A picture of angry chimpanzees in business suits arguing][3]][3]

    *Image credit: [Ivan Svetunkov](https://www.linkedin.com/posts/isvetunkov_stephan-kolassa-correctly-pointed-out-that-activity-7186387934671953923-7kyV/). Used with kind permission. Please attribute to him if you reuse it.*

Related CrossValidated and Data Science questions
--------------------------------

 * [The difference between MSE and MAPE](https://stats.stackexchange.com/q/11636/1352)
 * [Best way to optimize MAPE](https://stats.stackexchange.com/q/213897/1352)
 * [Mean absolute percentage error with respect to predictions](https://stats.stackexchange.com/q/508742/1352) (on using the *actual* in the denominator)
 * [Minimizing symmetric mean absolute percentage error (SMAPE)](https://stats.stackexchange.com/q/145490/1352) (on using the *average* of the forecast and the actual in the denominator)
 * [Optimal prediction under squared percentage loss](https://stats.stackexchange.com/q/555901/1352) (on using the *squared* instead of the *absolute* percentage error)
 * [MAPE vs R-squared in regression models](https://stats.stackexchange.com/q/327464/1352)
 * [Why use a certain measure of forecast error (e.g. MAD) as opposed to another (e.g. MSE)?](https://stats.stackexchange.com/q/45875/1352)
 * [Does it make sense to increment by 1 the numerator and denominator in the MAPE to avoid division by 0?](https://stats.stackexchange.com/q/588307/1352)
 * [MAD vs RMSE vs MAE vs MSLE vs R²: When to use which?](https://datascience.stackexchange.com/q/42760/2853)

R code
------

Lognormal example:
<!-- language-all: lang-r -->
    mm <- 1
    ss.sq <- 1
    SAPMediumGray <- "#999999"; SAPGold <- "#F0AB00"
    
    set.seed(2013)
    actuals <- rlnorm(100,meanlog=mm,sdlog=sqrt(ss.sq))
    
    opar <- par(mar=c(3,2,0,0)+.1)
    	plot(actuals,type="o",pch=21,cex=0.8,bg="black",xlab="",ylab="",xlim=c(0,150))
    	abline(v=101,col=SAPMediumGray)
    
    	xx <- seq(0,max(actuals),by=.1)
    	polygon(c(101+150*dlnorm(xx,meanlog=mm,sdlog=sqrt(ss.sq)),
          rep(101,length(xx))),c(xx,rev(xx)),col="lightgray",border=NA)
    
    	(min.Ese <- exp(mm+ss.sq/2))
    	lines(c(101,150),rep(min.Ese,2),col=SAPGold,lwd=3,lty=2)
    	
    	(min.Eae <- exp(mm))
    	lines(c(101,150),rep(min.Eae,2),col=SAPGold,lwd=3,lty=3)
    	
    	(min.Eape <- exp(mm-ss.sq))
    	lines(c(101,150),rep(min.Eape,2),col=SAPGold,lwd=3,lty=4)
    par(opar)

Dice rolling example:

    SAPMediumGray <- "#999999"; SAPGold <- "#F0AB00"

    set.seed(2013)
    actuals <- sample(x=1:6,size=100,replace=TRUE)
    
    opar <- par(mar=c(3,2,0,0)+.1)
    	plot(actuals,type="o",pch=21,cex=0.8,bg="black",xlab="",ylab="",xlim=c(0,150))
    	abline(v=101,col=SAPMediumGray)
    
    	min.Ese <- 3.5
    	lines(c(101,150),rep(min.Ese,2),col=SAPGold,lwd=3,lty=2)
    	
    	min.Eape <- 2
    	lines(c(101,150),rep(min.Eape,2),col=SAPGold,lwd=3,lty=4)
    par(opar)

References
----------

Gneiting, T. [Making and Evaluating Point Forecasts](http://www.tandfonline.com/doi/abs/10.1198/jasa.2011.r10138). *Journal of the American Statistical Association*, 2011, 106, 746-762

Goodwin, P. & Lawton, R. [On the asymmetry of the symmetric MAPE](http://www.sciencedirect.com/science/article/pii/S0169207099000072?via%3Dihub). *International Journal of Forecasting*, 1999, 15, 405-408

Hoover, J. [Measuring Forecast Accuracy: Omissions in Today's Forecasting Engines and Demand-Planning Software](https://ideas.repec.org/a/for/ijafaa/y2006i4p32-35.html). *Foresight: The International Journal of Applied Forecasting*, 2006, 4, 32-35

Kolassa, S. [Why the "best" point forecast depends on the error or accuracy measure (Invited commentary on the M4 forecasting competition).](https://doi.org/10.1016/j.ijforecast.2019.02.017) *International Journal of Forecasting*, 2020, 36(1), 208-211

Kolassa, S. & Martin, R. [Percentage Errors Can Ruin Your Day (and Rolling the Dice Shows How)](https://ideas.repec.org/a/for/ijafaa/y2011i23p21-27.html). Foresight: The International Journal of Applied Forecasting, 2011, 23, 21-29

Kolassa, S. & Schütz, W. [Advantages of the MAD/Mean ratio over the MAPE](https://ideas.repec.org/a/for/ijafaa/y2007i6p40-43.html). *Foresight: The International Journal of Applied Forecasting*, 2007, 6, 40-43

McKenzie, J. [Mean absolute percentage error and bias in economic forecasting](https://doi.org/10.1016/j.econlet.2011.08.010). *Economics Letters*, 2011, 113, 259-262

Zheng, S. [Gradient descent algorithms for quantile regression with smooth approximation](https://doi.org/10.1007/s13042-011-0031-2). *International Journal of Machine Learning and Cybernetics*, 2011, 2, 191-207 


  [1]: https://i.sstatic.net/OcHkV.png
  [2]: https://i.sstatic.net/Cu95X.png
  [3]: https://i.sstatic.net/8fiYD.jpg