Hello all,

How does Dynare solve a DSGE model? To be more specific, how does Dynare solve a DSGE model after it has been linearized around a steady state? I’ve tried to replicate Smets Wouters ‘07 both with and without Dynare by using a single-chained MHRW algorithm with 250k draws. My own code takes about a day to do this but Dynare takes less than an hour. I’m using Chris Sims’ Gensys code but would like to improve the speed of my own MHRW algorithm

You should profile your code in Matlab (“Run and time”) to see where most time is spent. My guess would be the Kalman filter initialization.

disregard: Gensys only takes .01 seconds to solve the Smets Wouters model. You are correct that the initialization of the covariance matrix for the Kalman filter is the most time-consuming step.

The code I am using is

VAR_ST = inv(eye(2401)-kron(G1,G1))*kron(impact,impact)*reshape(SIG_E,49,1)

Where G1 is the matrix of auto-correlations, impact is the matrix relating the state variables to the shocks, and SIG_E contains the standard deviations of those shocks.

Do you have any suggestions for speeding up the initialization of the Kalman filter?

Use Dynare’s `lyapunov_symm.m`

. See the Chapter 3 codes of my Kobe lecture at Johannes Pfeifer - Teaching

1 Like

You’re a gentleman and a scholar. My algorithm used to take about 16 hours to run, now it takes well under 1 hour