← Back to Projects

New-Keynesian DSGE: Solution, Estimation, Model Comparison

The data decisively prefer a forward-looking, interest-rate-smoothing policy rule (log Bayes factors +91 and +46), and the canonical orthogonal-shock assumption is rejected.

Capability: Structural macro
Category: Structural Macro
Date: July 2026

At a glance

Solution
Klein / QZ, BK-determinate
Log Bayes factors: smoothing, forward-looking
+91, +46
MCMC
2 chains × 12,000
Posterior predictive moments passing
9 of 10
Model comparison by marginal likelihood across policy rules
Log marginal likelihood relative to the best specification: the forward-looking smoothed rule wins by a log Bayes factor of about 46 over backward smoothing and 137 over the contemporaneous rule.

About this project

A compact, readable Python package that builds the canonical three-equation New Keynesian model from its structural equations, solves it with the Klein (2000) generalised-Schur method, and confronts it with official euro-area data pulled keyless from the ECB Data Portal at run time, then with US data from FRED. It proceeds from calibration to Kalman-filter maximum likelihood, to three policy-rule specifications, to full Bayesian estimation and Geweke marginal-likelihood model comparison, to posterior predictive checks with a measurement-error prior anchored on 84 ALFRED data vintages.

Why it matters

Structural models are how central banks and macro desks reason about policy. Most public DSGE code stops at calibration and impulse responses. This one estimates, compares and tests, and reports where the model breaks: the canonical shock structure is rejected, and the forward-looking smoothed rule repairs most, not all, of it.

Methodology

  • Blanchard-Kahn determinacy checked; structural residuals at machine zero; exact theoretical moments computed from the state-space form.
  • Kalman-filter MLE of shock standard deviations and persistences; recovered structural innovations by Kalman inversion.
  • Three policy rules (contemporaneous, backward-looking smoothed, forward-looking smoothed); random-walk Metropolis with 2 chains × 12,000 draws, 3,000 burn-in, standard Beta/Gamma/inverse-Gamma priors; R-hat diagnostics.
  • Geweke (1999) modified harmonic mean marginal likelihoods across specifications; the same pipeline run on the United States.
  • Posterior predictive checks on ten moments with a measurement-error prior anchored to ALFRED revision statistics; a prior-anchor sweep to show where identification breaks down.

Strongest findings

  • Under the contemporaneous rule the estimated cost-push / monetary shock correlation is about −0.94, so the canonical orthogonal-shock assumption is rejected by euro-area data; smoothing moves it to −0.63 and the forward-looking smoothed rule to about +0.20.
  • Log marginal likelihoods of roughly −635, −544 and −498 give log Bayes factors of about +91 for smoothing and a further +46 for making the rule forward-looking; the US ordering is the same (+65 for smoothing).
  • Posterior means are economically sensible in both economies: a Taylor coefficient clearly above one, Calvo stickiness above 0.75, and a smoothing parameter near 0.8.
  • With a revision-anchored measurement-error prior the posterior predictive checks pass on nine of ten moments; the shock correlation is still flagged (p = 0.02) in the euro area, and anchors above 1.2 break identification.

Figures

  1. Shock correlation across policy specifications
    Figure 1. Cost-push versus monetary innovations under each rule: the correlation runs −0.94, −0.63, +0.20 as the rule is made smoothed and then forward-looking.
  2. Posterior distributions with priors overlaid
    Figure 2. Posterior distributions of the structural and policy parameters with priors overlaid and the calibrated values marked.
  3. Posterior predictive checks, euro area
    Figure 3. Posterior predictive checks with a revision-anchored measurement-error prior: nine of ten moments inside the band; the shock correlation remains flagged.
  4. Structural estimates by economy
    Figure 4. Euro-area versus United States posterior means under the forward-looking rule.
  5. Impulse responses to one-standard-deviation shocks
    Figure 5. Impulse responses of the output gap, inflation and the nominal rate to demand, cost-push and monetary shocks.

Robustness and caveats

  • Three-equation model with AR(1) shocks; no capital, no labour market, no financial block.
  • Output gap measured by a full-sample HP filter of log real GDP for estimation purposes, a choice the VAR lab shows to be problematic for forecasting.
  • No written paper; the README is the complete write-up and the executed notebook walks through every stage.

Challenges

Getting a generalised-Schur solution that satisfies the model equations to machine precision, diagnosing why a textbook shock structure is rejected by the data, and building a measurement-error prior that is disciplined by actual revision statistics rather than chosen to make the checks pass.

Learnings

Bayesian estimation and model comparison for structural models, and the difference between a model that fits and a model whose failures are located.

Stack

PythonNumPySciPyECB Data PortalFREDALFRED