How does dynare compute theoretical moments?

Specially I’m interested in knowing how Dynare computes second-moments, i.e. standard deviations and covariance matrix, particularly derived from regular stoch_simul(). This has been asked before, as in here, but I do not understand where does this simulation come from? (I’m a beginner). Since I thought Dynare only simulated irfs to orthogonalized shocks.

In the other hand, as far as I can tell, if Dynare generates some time series simulation of the variables, then it computes theoretical second-moments from this filtered data, and Dynare offer the option of HP or band-pass type filter. Now, if my empirical moments (from data) are filtered using another method, in order for both to be comparable, I should use the same cycle-extraction method, then how do I get the non-filtered simulated time series calculated by Dynare from my theoretical model?

Also, does the approximation order of the solution affect the simulation that is computed by Dynare (and consequently the theoretical second moments)?


I am not sure I understand.

  1. Once you have the model solution at the respective order, you can simulate artificial data. That is straightforward. As the model solution will depend on the approximation order, of course moments will depend on the order.
  2. The moments Dynare will display if you request simulated moments (periods>0), will be based on the filtering the simulated data if such a filter is requested. However, the actual simulated series in the workspace and in oo_.endo_simul will be unfiltered. Thus, you can apply any data treatment to these series you like.
1 Like

Then, I think my question now is more: how does Dynare generate the simulation? When having the solution, Dynare just sets initial conditions for all predetermined variables (particularly the steady state), and simulates the evolution of the economy for the number assigned to periods?

Also, specifically which components does these simulated time series have apart from cycle (e.g. irregular, trend, seasonal), and where do they actually come from?

What does this error mean? (I ask since it may be related with the previous question, actually found the way of solving it but don’t understand why it happens):

STOCH_SIMUL error: The horizon of simulation is shorter than the number of observations to be dropped.
STOCH_SIMUL error: Either increase options_.periods or decrease options_.drop.

And, once Dynare simulated those paths, the resultant “matrix” oo_.endo_simul should be read as rows being endogenous variables, in the order of appearance as in M_.endo_names ? (and therefore columns being each time period)

Why when using relatively high order approximation of the solution (i.e. 7) oo_.endo_simul shows first columns with numbers, second with NaN and the rest with zeros everywhere?

Lastly, if my empirical data has T observations, when comparing second moments extracted from this real data, should I simulate my model’s artificial data also T with periods, or is it more suitable to simulate as much periods as I can, in order to get like “asymptotic” values of second moments?

Many thanks!!

  1. Yes, you start with the steady state and then simulate for the number of periods.
  2. The series contains whatever the DSGE model contains. Usually, that will mostly be the cycle. Dynare does not offer to model irregular or seasonal components.
  3. Dynare will simulate for periods, but will drop drop-periods at the beginning for computing moments. That assures that the role of the initial condition has typically died out. The message appears if e.g. you want to simulate 100 periods but drop 200 initial data points.
  4. oo_.endo_simul has the variables arranged row by row, in order of declaration (as in M_.endo_names). Columns are the time periods.
  5. At higher order, simulations can be explosive. To prevent this, you may need pruning.
  6. There is no general answer here. That being said, if you are interested in asymptotics, you may want to use theoretical moments. When using simulated moments, people usually simulate the same number of periods as the empirical data, but repeat this for a number of samples. See e.g. DSGE_mod/Hansen_1985 at master · JohannesPfeifer/DSGE_mod · GitHub
1 Like

If your model is linear and stationary so that the state dynamics can be described using s_t = \mu + T s_{t-1} + R \varepsilon_{t}, then it is possible to compute analytically the mean and variance of s_t

To compute the mean, solve the equation \bar{s} = \mu + T \bar{s} for \bar{s}, which if such a solution exists is equal to (I-T)^{-1}\mu

To compute the variance, let the variance of s_t be \Sigma_s and the variance of the shocks \varepsilon_t be \Sigma_{\varepsilon} and solve the equation \Sigma_s = T \Sigma_s T' + R \Sigma_{\varepsilon}R'

Letting the vec operator be an operator that reshapes an n\times m matrix into an nm\times 1 column, one can solve the equation for \Sigma_s thusly:

vec(\Sigma_s) = (T \otimes T)vec(\Sigma_s) + (R\otimes R)vec(\Sigma_{\varepsilon}) which implies that

vec(\Sigma_s) = (I - T \otimes T)^{-1}(R\otimes R)vec(\Sigma_{\varepsilon})

Solving for \Sigma_s can be very time-consuming, so Dynare uses the function lyapunov_symm instead, which is many times faster than inverting a matrix as large as I-T\otimes T


@jthomp10 That is correct for unfiltered theoretical moments. But the question here was about simulated moments with filtering.

1 Like