Re: DSGE based-on IRF from VAR's
by jpfeifer » Fri Feb 25, 2011 6:12 pm
I am not sure that you cannot directly implement it in Dynare. I guess the way to proceed is the following:
First, design a model you want to fit in Dynare. Just calibrate it to some values and see if it is in principle able to generate the kind of dynamics you are looking for. If it is not able to do so, there is no use to fitting a model to IRFs that it will never be able to generate.
Second, run Dynare with your model file once to generate the IRFs you want to match. Make sure that the IRFs are correctly displayed, and that only the time horizon you want to match is computed. Also, shut off everything in the stoch_simul command, e.g. nofunctions (see manual).
Third, rerun Dynare, but place the line
- Code: Select all
evalin('base','save level0workspace oo_ M_ options_')
before the stoch_simul-command. This will save the workspace immediately before stoch_simul is called.
Now, write a set of functions that performs the IRF-matching. Fourth, program an objective function that takes as inputs the parameters you want to estimate and as output the criterion function that gives the weighted distance between the model and the empirical IRFs. In the objective function, use
- Code: Select all
global oo_ M_ options_
load level0workspace oo_
to have available the workspace you saved and reset the results-structure in each iteration step.
Then use the Dynare function set_param_value() to set the parameters given to the function into Dynare before computing IRFs. Then extract the program code lines after the evalin command up to and including the stoch_simul command from the m-file created by Dynare in the third step. By doing this, your program runs the Dynare solver and generates IRFs which are stored in oo_. (It might be necessary to change the Dynare file stoch_simul in order to prevent each run from displaying the IRFs in a plot).
Finally in this file, compare the IRFs generated by Dynare with the set of parameters set through set_param_value with the empirical ones and give as output the value of the criterion function.Also program an outer file that loads level0workspace saved in step three and then uses a miminizer like fsolve or csminwel to minimize the objective function defined in step four over the parameters you want to estimate.
You may also want to define the empirical IRFs as global variables so they can be accessed in the objective function.