After solving the DSGE model by dynare which have a productivity/TFP shock, I want to check if the model can account for the recession in 2008.
The TFP shock is log AR(1): ln(A) = \rho ln(A(-1) + eA

So now I have the position function solved by Dynare, and the data series of TFP.
My plan is to find out the simulated paths from the model for some important variables like output, consumption, investment. Then compare those simulated paths with the paths created from real data 10 years from the recession.

But I am still struggling with how to produce the simulated paths from the model solution and data on the TFP?

I am not sure I understand your problem here. Are you trying to simulate the model with the TFP you observe? Is TFP the only shock exogenous variable in the model?

I assume that the TFP shock is the only source of randomness in the model:

\log A_t = \rho \log A_{t-1} + e_{A,t}

If you call the stoch_simul command, Dynare will simulate the model by taking draws for e_{A,t} in a normal distribution. If my understanding of your problem is correct, you want instead to simulate the model with the observed TFP. Here is what I would do:

Compute recursively a sequence of innovations e_{A,T} consistent with your measure of TFP (assuming you have an initial condition A_0):

You need to call an internal matlab routine called simult_ (available in the matlab subfolder) providing the sequence (in a vector) obtained in the previous step as the third input (ex). You will figure out easily how to call this function by looking how we do it in Dynare (look at stoch_simul.m and simult.m in the same folder).

You need to call an internal matlab routine called simult_ (available in the matlab subfolder) providing the sequence (in a vector) obtained in the previous step as the third input ( ex ).

–> What do you mean by the “matlab subholder”, You mean I need to create it or this is available after running Dynare (i checked after running a mod file and see no matlab subfolder created)

You will figure out easily how to call this function by looking how we do it in Dynare (look at stoch_simul.m and simult.m in the same folder).

–> Again, I could not find stoch_simul.m and simult.m, since I could not find the folder as well.

I suppose that the example referenced by @jpfeifer solves your problem.

If you installed dynare in C:/dynare/4.5.6 you have a subfolder inside called matlab (and more subfolders inside C:/dynare/4.5.6/matlab where all the matlab routines are located. C:/dynare/4.5.6/matlab is the folder you must add to the matlab path, to get dynare working. In this folder you will find simult_.m, simult.m and stoch_simul.m routines.

I know that dynare can compute the variance decomposition for the contributions of the shocks.
But now if I am using real data for shocks in simulation, is there a way to compute the variance decomposition as well?

Difficult to think about this since you simulate your model conditionally on a path for the exogenous variables. So unless you have a probabilistic models for these paths, I do not see how to compute a variance (a fortiori a variance decomposition).

What you are actually trying to do is a historical decomposition. In a linear model, this boils down to simulating the model with one shock at a time and seeing how the counterfactual series looks like. Of course, if your model was not estimated using full information techniques, you have the problem outlined at

namely that the shock contributions do not sum to the observables.

Is there any source that explains how to feed in shocks into the model (2nd step)? It is still not clear after I investigated Johannes’s mod example file for the simult_ -function. Do we need to manually edit the “simult_.m” file?

Errors were because of an older version of Dynare that was using.

Now the issue is that my StEx3.mod (4.3 KB)
does not generate the intended values for the variable ‘F’. In my model ‘F’ must be calculated as: log(F)=log(F(-1))+oil_ch (given in line 56) where “oil_ch” gets values in the ‘shock_matrix’.

F is the oil revenue in my model (measured as fraction of output).
oil_ch is obtained as: oil_ch=log(F)-log(F(-1)) using the real data and I am using lines 102-116 to provide the obtained sequence.

However when I simulate, the values of F are far from what is in actual data.

None of my equations are log linerized. I assume Dynare does it automatically. Maybe my mistake is in this.