Mean Absolute Error
The Mean Absolute Error (MAE) is the average absolute difference between the two series: every difference counts in proportion to its size.
The formula for the Mean Absolute Error is as follows:
\[\text{MAE} = \frac{\sum_{t=1}^{n} \left\lvert a_{t} - b_{t}\right\rvert}{n}\]Where \(a_{t}\) and \(b_{t}\) are the values of the two series on the n dates where both have one. As it does not square the differences, the Mean Absolute Error is less sensitive to occasional outliers than the Root Mean Squared Error, and it is never larger than it: the gap between the two shows how uneven the differences are.
A forecast error measure sums up how far a forecast lies from the values it forecasts in one number, in the units of the series itself. Here it compares two tickers directly, one taken as the forecast of the other: a simple, tracking-error style measure of how closely two series move together, such as a fund and its index or two listings of the same asset. A lower value means the two series track each other more closely. Both measures are per period, so a daily value is usually multiplied by the square root of 252 to annualize it.
Also known as: MAE, MAD, mean absolute deviation.
In the Finance Toolkit this is get_forecast_error with method="mae", the same function as Forecast Error.
Example · IVV, VOO · 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_forecast_error:
from financetoolkit import Toolkit
toolkit = Toolkit(
["IVV", "VOO"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2025-01-01",
end_date="2025-12-31",
)
toolkit.econometrics.get_forecast_error(method="mae", include_benchmark=True)
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The data frequency (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”. | "weekly" |
column | str | The historical data column to compare. Defaults to “Return”. | "Return" |
include_benchmark | bool | Whether to include “Benchmark” among the tickers paired up. Defaults to False. | True |
method | str | The error measure. Options are: “rmse” (Root Mean Squared Error), “mae” (Mean Absolute Error). Defaults to “rmse”. | "rmse" |
rounding | int | None | The number of decimals to round the results to. Defaults to None. | 2 |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |
Which returns:
| Item | MAE |
|---|---|
| ('IVV', 'VOO') | 0.0002 |
| ('IVV', 'Benchmark') | 0.0003 |
| ('VOO', 'Benchmark') | 0.0003 |
3 rows
Using Your Own Data
get_forecast_error runs on any data, not only prices: ratios, economic indicators, yield curves or your own dataset. Pass a DataFrame, a Series or a dictionary of them to Econometrics as data, with the dates in the rows or the columns, and set changes to how its changes are calculated: "percentage", "log", "difference" for rates and ratios, or None when the data are changes already. For example, for the monthly unemployment rates of the United States and Germany:
from financetoolkit import Economics, Econometrics
economics = Economics(start_date="2000-01-01")
unemployment = economics.get_unemployment_rate(
countries=["United States", "Germany"], period="monthly"
)
econometrics = Econometrics(data=unemployment, changes="difference")
econometrics.get_forecast_error()
References
- Paper Hyndman, R.J. and Koehler, A.B. (2006). “Another Look at Measures of Forecast Accuracy.” International Journal of Forecasting, 22(4), 679-688.
- Library Referenced against statsmodels’ meanabs (Mean Absolute Error)