Skip to content

Build a QPM forecast for a small open economy

Take a small open economy's published data through the core of a forecasting and policy analysis system: the quarterly projection model of Berg, Karam and Laxton (2006) estimates the output gap, the real interest-rate and exchange-rate gaps and the trends behind the data, forecasts from there, and shows what a rate rise would change.

Before you start

  • Quarterly data in levels: real GDP, the CPI and the nominal exchange rate (domestic currency per unit of foreign currency) as 100 times their logs, the policy rate, and the foreign output gap, CPI (100 times its log) and interest rate. This page uses the example dataset sample_open_economy, 2000Q1 to 2024Q4, simulated from the model itself, with the series named as the template observes them (obs_l_gdp, obs_l_cpi, obs_rs, obs_l_s, obs_y_gap_rw, obs_l_cpi_rw, obs_rs_rw). With your own data, take 100*log of the levels and use these names.
  • The calibration. The template's defaults are BKL's for Canada (their how-to guide, Table 1): a lagged output gap weight of 0.85, a real-rate effect of 0.10, a weight of 0.20 on expected inflation, a policy response of 2 to expected inflation. Change any with Parameters, e.g. alpha_z=0.2 for more pass-through.
  • The forecast's periods (here 2025Q1 to 2027Q4) and the scenario: here a surprise rise of one percentage point in the policy rate in 2025Q1, BKL's own experiment.

In the app, or in code

Follow this step by step in the app

View → Guide → How do I → Build a QPM forecast for a small open economy. The Guide panel takes you through these steps one at a time: Open… opens each step's dialog filled in, Show me runs it, and each step is ticked when its result is there. In the app's help, the page's Walk me through this opens it. The Guide is in the pymetrix-guide plugin, which is experimental (pip install --pre "pymetrix[guide]"; the walkthroughs come with its release after 0.1.0a1).

  1. File → Load example data…, with Example dataset: sample_open_economy and Save as: data.
  2. Model → Template model…, with Template: Quarterly projection model (open economy) and Save as: qpm. Its window shows Equations, Parameters (each described, with BKL's values), Measurement and Shocks.
  3. Model → Analysis → State-space form…, with Model: qpm and Save as: system. Leave Measurement equations empty: the template's own observe the seven series.
  4. Model → Analysis → Kalman filter…, with State-space model: system, Data: data and Save as: filtered. The result has every model variable over the history: y_gap, rr_gap, z_gap, potential output l_gdp_bar and its growth g_bar, the equilibrium real rate rr_bar.
  5. Model → Solution → Rational expectations…, with Equations: qpm and Save as: sol. The template is solved around its balanced growth path.
  6. In View → Immediate, type the two scenarios and the baseline forecast, one line each: baseline = Scenario(), tighter = Scenario(shift={"e_rs": {"2025Q1": 1.0}}, unanticipated=["e_rs"]) and fc = sol.solve(filtered, ("2025Q1", "2027Q4")).solved().
  7. Model → Scenarios → Compare scenarios…, with Model: sol, Scenarios: baseline, tighter, Data: filtered, Start: 2025Q1, End: 2027Q4 and Save as: comparison. Less the baseline shows what the rate rise changes.
  8. Forecast → Make round…, with Forecast or solution: fc, Round name: 2025Q1 QPM baseline, Data: filtered, Variables: y_gap, pi4, rs, z_gap and Save as: qpm_round.
from pymetrix import Dataset, ForecastRound, Scenario, scenarios, templates

data = Dataset.example("sample_open_economy")
qpm = templates.qpm()                                   # BKL (2006), open economy, their calibration for Canada
system = qpm.system()                                   # the template's measurement: the seven series as levels
filtered = system.filter(data)                          # gaps and trends over 2000Q1-2024Q4
filtered["y_gap"].loc["2024Q4"]                         # 1.90: output above potential at the end of the data
sol = qpm.solve()
baseline = Scenario()
tighter = Scenario(shift={"e_rs": {"2025Q1": 1.0}}, unanticipated=["e_rs"])
fc = sol.solve(filtered, ("2025Q1", "2027Q4")).solved()    # the forecast, from the filtered state
comparison = scenarios(sol, {"baseline": baseline, "tighter": tighter}, ("2025Q1", "2027Q4"), data=filtered)
qpm_round = ForecastRound.from_forecast("2025Q1 QPM baseline", fc, variables=["y_gap", "pi4", "rs", "z_gap"],
                                        data=filtered)

What the rate rise changes, period by period:

effect = comparison.difference("tighter", "baseline").to_frame()
effect[["rs", "y_gap", "pi4", "z_gap"]].round(2)       # rs +0.93 in 2025Q1; y_gap -0.20 by 2025Q3; pi4 -0.10 by 2026Q4

Check the result

  • The steady state (qpm.steady_state()): every gap zero, inflation at the target (2), the real rate at its equilibrium (2.7), the policy rate 4.7; qpm.steady_state().growth has real GDP growing by 0.75 a quarter (3 percent a year) and the CPI by 0.5.
  • The filtered history: the observed series come back exactly (each obs_..._fitted equals the data, since they are observed without error); at the end of the data output is 1.90 percent above potential and the real exchange rate 8.01 percent stronger than its equilibrium (z_gap -8.01).
  • The baseline forecast: the gap closes during 2025 (0.12 in 2025Q4) and turns negative as policy holds the rate near 6 percent; year-on-year inflation peaks at 2.62 in 2025Q4 and is back at 2.01 by 2027Q4.
  • The rate rise, as BKL describe it (how-to guide, pp. 32-33): the policy rate is 0.93 points higher in 2025Q1, the currency appreciates at once (z_gap -0.42), output falls below the baseline for about two years (by 0.20 at the trough, in 2025Q3), and inflation falls more slowly, by 0.10 at its trough in 2026Q4; the rate is then lowered below the baseline and the currency depreciates. The difference does not depend on the data: it is the model's impulse response (sol.irf(12)).
  • The round's last period of data: 2024Q4 (qpm_round.data_end).

Pitfalls

  • Levels, not growth rates. The template observes 100 times the logs of GDP, the CPI and the exchange rate; give it growth rates and the filter reads them as levels. With raw levels, put a transform in the measurement map (obs_l_gdp from 100*log(gdp)) or derive the series first.
  • The exchange rate's direction. obs_l_s is domestic currency per unit of foreign currency: up is a depreciation, as BKL's real exchange rate. A series quoted the other way round must be negated.
  • The foreign weights set to zero. qpm(beta_zgap=0, beta_rw=0, alpha_z=0) has no unique solution (nothing then anchors the real exchange rate's level); use qpm(open=False) for a closed economy.
  • Unanticipated or anticipated. A shock in a scenario is known in advance unless named in unanticipated; an anticipated rate rise moves the exchange rate and inflation before it happens.
  • The calibration is Canada's. BKL's values are a starting point; the trends' persistence and the shock sizes are pymetrix's choices, since BKL publish none. Calibrate to your economy's transmission (the sacrifice ratio, the exchange rate's pass-through) before taking the forecast to a policy meeting.

See also