# Mean absolute error

In statistics, mean absolute error (MAE) is a measure of errors between paired observations expressing the same phenomenon. Examples of Y versus X include comparisons of predicted versus observed, subsequent time versus initial time, and one technique of measurement versus an alternative technique of measurement. MAE is calculated as the sum of absolute errors divided by the sample size:[1]

${\displaystyle \mathrm {MAE} ={\frac {\sum _{i=1}^{n}\left|y_{i}-x_{i}\right|}{n}}={\frac {\sum _{i=1}^{n}\left|e_{i}\right|}{n}}.}$
It is thus an arithmetic average of the absolute errors ${\displaystyle |e_{i}|=|y_{i}-x_{i}|}$, where ${\displaystyle y_{i}}$ is the prediction and ${\displaystyle x_{i}}$ the true value. Note that alternative formulations may include relative frequencies as weight factors. The mean absolute error uses the same scale as the data being measured. This is known as a scale-dependent accuracy measure and therefore cannot be used to make comparisons between series using different scales.[2] The mean absolute error is a common measure of forecast error in time series analysis,[3] sometimes used in confusion with the more standard definition of mean absolute deviation. The same confusion exists more generally.

## Quantity disagreement and allocation disagreement

2 data points for which Quantity Disagreement is 0 and Allocation Disagreement is 2 for both MAE and RMSE

It is possible to express MAE as the sum of two components: Quantity Disagreement and Allocation Disagreement. Quantity Disagreement is the absolute value of the Mean Error given by:[4]

${\displaystyle \mathrm {ME} ={\frac {\sum _{i=1}^{n}y_{i}-x_{i}}{n}}.}$

Allocation Disagreement is MAE minus Quantity Disagreement.

It is also possible to identify the types of difference by looking at an ${\displaystyle (x,y)}$ plot. Quantity difference exists when the average of the X values does not equal the average of the Y values. Allocation difference exists if and only if points reside on both sides of the identity line.[4][5]

## Related measures

The mean absolute error is one of a number of ways of comparing forecasts with their eventual outcomes. Well-established alternatives are the mean absolute scaled error (MASE) and the mean squared error. These all summarize performance in ways that disregard the direction of over- or under- prediction; a measure that does place emphasis on this is the mean signed difference.

Where a prediction model is to be fitted using a selected performance measure, in the sense that the least squares approach is related to the mean squared error, the equivalent for mean absolute error is least absolute deviations.

MAE is not identical to root-mean square error (RMSE), although some researchers report and interpret it that way. MAE is conceptually simpler and also easier to interpret than RMSE: it is simply the average absolute vertical or horizontal distance between each point in a scatter plot and the Y=X line. In other words, MAE is the average absolute difference between X and Y. Furthermore, each error contributes to MAE in proportion to the absolute value of the error. This is in contrast to RMSE which involves squaring the differences, so that a few large differences will increase the RMSE to a greater degree than the MAE.[4] See the example above for an illustration of these differences.

### Optimality property

The mean absolute error of a real variable c with respect to the random variable X is

${\displaystyle E(\left|X-c\right|)}$
Provided that the probability distribution of X is such that the above expectation exists, then m is a median of X if and only if m is a minimizer of the mean absolute error with respect to X.[6] In particular, m is a sample median if and only if m minimizes the arithmetic mean of the absolute deviations.[7]

More generally, a median is defined as a minimum of

${\displaystyle E(|X-c|-|X|),}$
as discussed at Multivariate median (and specifically at Spatial median).

This optimization-based definition of the median is useful in statistical data-analysis, for example, in k-medians clustering.

#### Proof of optimality

Statement: The classifier minimising ${\displaystyle \mathbb {E} |y-{\hat {y}}|}$ is ${\displaystyle {\hat {f}}(x)={\text{Median}}(y|X=x)}$ .

Proof:

{\displaystyle {\begin{aligned}L&=\mathbb {E} [|y-a||X=x]\\&=\int _{-\infty }^{\infty }|y-a|f_{Y|X}(y)\,dy\\&=\int _{-\infty }^{a}(a-y)f_{Y|X}(y)\,dy+\int _{a}^{\infty }(y-a)f_{Y|X}(y)\,dy\\\end{aligned}}}

Differentiating with respect to a gives

${\displaystyle {\frac {\partial }{\partial a}}L=\int _{-\infty }^{a}f_{Y|X}(y)\,dy+\int _{a}^{\infty }-f_{Y|X}(y)\,dy=0}$

This means

${\displaystyle \int _{-\infty }^{a}f(y)\,dy=\int _{a}^{\infty }f(y)\,dy}$

Hence

${\displaystyle F_{Y|X}(a)=0.5}$

7. ^ Nicolas, André (2012-02-25). "The Median Minimizes the Sum of Absolute Deviations (The ${L}_{1}$ Norm)". StackExchange.