Simulate a model using smoothed shocks

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Simulate a model using smoothed shocks

Postby Lara » Mon Mar 11, 2013 1:35 pm

Dear Dynare experts,

I really cannot solve a problem: I would like to simulate a model using the series of exogenous shocks obtained from Bayesian estimation.
How to do it?

In which part of the dynare code should I write the mat file of the smoothed shocks? Should it be in the shocks block? If so, how exactly?
Should it be in the stoch_simul command? If so, how?
Should I write additional lines in the dynare code?

Would it be possible for you to add an example in order to solve this issue?
Other users had the same problem, but answers are not satisfactory. In particular;
1) I tried with the example posted by Michel Juillard (example5.mod) on Aug 10,2006 but it does not work (viewtopic.php?f=1&t=144). I get the following error message .?? Undefined function or variable 'dr_'
2)Since the command "shocks(shocks_file=filename)" does not work (viewtopic.php?f=1&t=4307) I tried with "shocks(initval_file=filename)" but it does not work either. I get the following error message: syntax error, unexpected '(', expecting ';'. The filename is a .mat file which contains the smoothed series of the shocks.

Your help is greatly appreciated.

Thanks,
Lara
Lara
 
Posts: 33
Joined: Tue Jan 19, 2010 7:11 pm

Re: Simulate a model using smoothed shocks

Postby jpfeifer » Mon Mar 11, 2013 3:11 pm

What exactly do you want to do? The posts you cite refer to determinstic simulations under perfect foresight. Your problem, as you are referring to stoch_simul, sounds like you want to do a stochastic simulation. In that case, the best way is to use the simult_ function. The code would run along the following lines:
Code: Select all
ex_=[oo_.SmoothedShocks.Median.e_a oo_.SmoothedShocks.Median.e_m]
y0=oo_.dr.ys;
dr=oo_.dr
iorder=1;
y_=simult_(y0,dr,ex_,iorder)

where y_ now contains the simulated values (including the steady state). The shock order required in ex_ should be the one found in M_.exo_names.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Simulate a model using smoothed shocks

Postby Lara » Mon Mar 11, 2013 4:30 pm

Dear jpfeifer,
thanks for your prompt reply. You are right, I want to do a stochastic simulation. Hence I added the lines of code you suggested me and it works!
I guess that the first value in y_ is the steady state and the rest are the simulated variables.

Let me just explain the exercise I do. First I estimate a model and I get the series of the smoothed shocks (let me call this dynare code "dyn1.mod"). I save oo_dr and oo_.SmoothedShocks as results.mat. Then I simulate a model where I change the value of some parameters (compared to the estimated ones) and use the shocks I have estimated (let me call this dynare code "dyn2.mod"). So in dyn2.mod just before the simult_ command I write load results (and indeed the series of the shocks are the same as in dyn1.mod).

Thanks,
Lara
Lara
 
Posts: 33
Joined: Tue Jan 19, 2010 7:11 pm

Re: Simulate a model using smoothed shocks

Postby jpfeifer » Mon Mar 11, 2013 4:49 pm

Just be careful that loading stuff does not overwrite results from the run with changed parameters. From what you write, you should only save and load the oo_.SmoothedShocks and nothing else. E.g. use
Code: Select all
ex_=[oo_.SmoothedShocks.Median.e_a oo_.SmoothedShocks.Median.e_m];
save results ex_;

in the first mod-file and
Code: Select all
load results ex_;

in the second.
The reason is that both the steady state oo_.dr.ys and the decision rules oo_.dr should be from the recent run of Dynare with the changed parameters.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Simulate a model using smoothed shocks

Postby Lara » Mon Mar 11, 2013 5:48 pm

Thanks a lot!

Lara
Lara
 
Posts: 33
Joined: Tue Jan 19, 2010 7:11 pm

Re: Simulate a model using smoothed shocks

Postby theta23 » Sat May 30, 2015 11:59 am

I'm also interested in model Simulation using estimated shocks. So if I perform Bayesian estimation, then I manually change parameter values to the values I got from estimation (also persistence and standard deviations of shocks) does not it mean that I simulate the model with estimated parameters?
Or should I explicitly load smoothed shocks series into the code?

Best,
Theta
theta23
 
Posts: 20
Joined: Mon Apr 27, 2015 3:20 pm

Re: Simulate a model using smoothed shocks

Postby jpfeifer » Sun May 31, 2015 11:14 am

Those are different things: parameters and shocks. If you are interested in a historical counterfactual, you also need the shock values. If you are only interested in simulating the estimated model with arbitrary shocks, you only need to set the parameters.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Simulate a model using smoothed shocks

Postby leolee » Thu Nov 12, 2015 11:08 pm

Dear Prof. jpfeifer

Does the result from the following code you suggested give the same result as those are in "oo_.SmoothedVariables" when you do not change any parameters and shocks?

Code: Select all
ex_=[oo_.SmoothedShocks.Median.e_a oo_.SmoothedShocks.Median.e_m]
y0=oo_.dr.ys;
dr=oo_.dr
iorder=1;
y_=simult_(y0,dr,ex_,iorder)


I recently tried this using Smet and Wouters (2007), dynare code from the link below, I found there are some (small and very smoothly curved) gaps between the two results, couldn't find why.
https://sites.google.com/a/nyu.edu/jerome-williams/smets-and-wouters-aer-2007

Code: Select all
y0=oo_.dr.ys;
dr=oo_.dr;
iorder=1;
ex_=[oo_.SmoothedShocks.eta_a oo_.SmoothedShocks.eta_b oo_.SmoothedShocks.eta_g oo_.SmoothedShocks.eta_i oo_.SmoothedShocks.eta_r oo_.SmoothedShocks.eta_p oo_.SmoothedShocks.eta_w];
y_=simult_(y0,dr,ex_,iorder);
leolee
 
Posts: 30
Joined: Thu Mar 19, 2015 9:54 am


Return to Dynare help

Who is online

Users browsing this forum: Google [Bot] and 8 guests