MdAPE - Median Absolute Percentage Error

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


MdAPE(X, F, Type)

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


  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: $${\displaystyle {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: $${\displaystyle {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: $${\displaystyle {\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: $${\displaystyle {\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.

Files Examples

Related Links



Article is closed for comments.

Was this article helpful?
0 out of 0 found this helpful