Logo Lanfrica

ALebakhr/morocco-cpi-forecasting

Domain:

socioeconomic

Record type:

project
Creator:
ALe
Host:
# Forecasting Moroccan CPI Inflation A time-series study of Morocco's headline consumer price inflation, built end to end from public data and benchmarked against Bank Al-Maghrib's own published forecasts. The pipeline collects CPI from the Haut-Commissariat au Plan, Brent crude from FRED and dirham exchange rates from Bank Al-Maghrib; decomposes and tests the series; detects structural breaks; fits SARIMA and SARIMAX models; validates them with rolling-origin backtesting; and tests the oil-to-inflation transmission channel. Across seven real-time forecast vintages the model's mean absolute error on annual-average inflation is 0.583 percentage points against Bank Al-Maghrib's 0.655 — competitive with the central bank's published forecasts rather than better than them. Everything lives in one notebook, `morocco_cpi_forecasting.ipynb`, which runs top to bottom. ## Key findings - **Inflation is I(1).** ADF and KPSS disagree on the raw year-over-year series — the signature of a short sample containing a regime shift — but agree unanimously after one difference, fixing d=1 for every model that follows. PELT change-point detection independently locates the crisis window at 2022-02 to 2023-05, stable across penalty settings. - **Rolling-origin backtesting reversed the single-window verdict.** On one calm 18-month hold-out the naive random walk beat everything (MAE 0.728 against SARIMA's 1.103). Across 40 expanding-window origins, SARIMA and SARIMAX beat naive at every horizon tested: 0.511 and 0.517 against 0.631 at one month, 1.707 and 1.655 against 1.802 at six. A single test window measures the window as much as it measures the model. - **Oil pass-through is real, fast and short-lived.** Dirham-denominated Brent and inflation are both I(1) but not cointegrated (Engle-Granger p=0.27), so the relationship is estimated in first differences to avoid a spurious regression. Oil lags are jointly significant (F=6.09, p cd morocco-cpi-forecasting python -m venv .venv source …