# MdAPE - Median Absolute Percentage Error

Calculates the median absolute percentage error (MdAPE) between the forecast and the eventual outcomes.

## Syntax

MdAPE(X, F, Type)
X
is the eventual outcome time series sample data (a one-dimensional array of cells (e.g. row or column).
F
is the forecast time series data (a one-dimensional array of cells (e.g. row or column).
Type
is a switch to select the type of calculated MdAPE (0=regular (default), 1=symmetric) .
Order Description
1 MdAPE (default)
2 sMdAPE

## Remarks

1. The time series is homogeneous or equally spaced.
2. The time series X and F must be of identical size
3. The time series X or F may include observations with missing values (e.g. #N/A or blank).
4. Observations with missing values in Y or F are excluded from the MdAPE calculation.
5. The (regular) absolute percentage error (APE) for a given observation is defined as follows:

$${p_t = \left | \frac{y_t - f_t}{y_t} \right | = \left | \frac{e_t}{y_t}\right |}}$$
Where:
• $\{y_t\}$ is the actual outcome value at period t.
• $\{f_t\}$ is the forecast value at period t.
• $\{e_i\}$ is the forecast error at period t.
6. The symmetric absolute percentage error (SAPE) of a given observation is defined as follows:

$${s_t = \left | \frac{y_t - f_t}{y_t + f_t} \right | = \left | \frac{e_t}{y_t + f_t}\right |}}$$
7. The Median Absolute Percentage Error (MdAPE) is found by ordering the absolute percentage error (APE) from the smallest to the largest, and using its middle value (or the average of the middle two values if N is an even number) as the median:

$${\mathrm{MdAPE} = \mathrm{median}(p_1,p_2,\cdots,p_N)}$$
8. Similarly, the median of the symmetric absolute percentage error is found by ordering the symmetric absolute percentage errors (SAPE), and using the middle value:

$${\mathrm{sMdAPE} = \mathrm{median}(s_1,s_2,\cdots,s_N)}$$
9. MdAPE is more resilient to outliers than MAPE and sMAPE.
10. MdAPE is less intuitive, for example an MdAPE of 8% does not mean that the average absolute percentage error is 8%. Instead it means that half of the absolute percentage errors are less than 8% and half are over 8%.
11. It is difficult to combine MdAPE across horizons and/or series and when new data becomes available.
12. The MdAPE function is available starting with version 1.65 HAMMOCK.

## Examples

Example 1:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
A B C
Date Data Forecast
2008-01-01 -2.9 -2.95
2008-02-01 -2.83 -2.7
2008-03-01 -0.95 -1.00
2008-04-01 -0.88 -0.68
2008-05-01 1.21 1.50
2008-06-01 -1.67 -1.00
2008-07-01 0.83 0.90
2008-08-01 -0.27 -0.37
2008-09-01 1.36 1.26
2008-10-01 -0.34 -0.54
2008-11-01 0.48 0.58
2008-12-01 -2.83 -2.13
2009-01-01 -0.95 -0.75
2009-02-01 -0.88 -0.89
2009-03-01 1.21 1.25
2009-04-01 -1.67 -1.65
2009-05-01 -2.99 -3.20
2009-06-01 1.24 1.29
2009-07-01 0.64 0.60

Formula Description (Result)
=MAPE($B$3:$B$21,$C$3:$C$21,1) MAPE (0.157689)
=MAPE($B$3:$B$21,$C$3:$C$21,2) sMAPE (0.155052)