help looping over two parameters

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.

help looping over two parameters

Postby hakeru7 » Sun Apr 19, 2015 4:19 am

Hi all,

I'm trying to loop over two parameters by first running dynare and then looping over the stoch_simul command. Before each stoch_simul loop, I load in two new parameters.

For some reason, there are no errors and matlab takes into both new parameters each time, but I can see from the results that only one of the parameter change is being taken into account (ppsipi). The other parameter (ppibar) is being updated, but the I keep getting the same results implying that it is in fact not being updated....

Any help would be greatly appreciated.

Jae
hakeru7
 
Posts: 17
Joined: Sun Apr 19, 2015 4:10 am

Re: help looping over two parameters

Postby jpfeifer » Sun Apr 19, 2015 9:03 am

You are not taking parameter dependence into account. That’s why you should use model-local variables (the ones with the pound operator) or a steady state file. See Remark 4 (Parameter dependence and the use of model-local variables) in Pfeifer(2013): "A Guide to Specifying Observation Equations for the Estimation of DSGE Models" https://sites.google.com/site/pfeiferecon/Pfeifer_2013_Observation_Equations.pdf.
------------
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: help looping over two parameters

Postby hakeru7 » Sun Apr 19, 2015 5:13 pm

Thanks for the reply Johannes.

Just trying to understand what dynare does...in my loop I update my parameter of choice, then run an m-file that re-defines the rest of the parameters based on the changes and saves it, then dynare runs my mod file which loads and sets all the parameters each time.

Why does this logic not work if I am re-uploading the whole set of parameters each time...? Is because I am running stoch_simul instead of the whole dynare?
hakeru7
 
Posts: 17
Joined: Sun Apr 19, 2015 4:10 am

Re: help looping over two parameters

Postby hakeru7 » Sun Apr 19, 2015 5:26 pm

Also, I tried following your suggestion of creating a steady state file. I think I'm struggling to wrap my head around how to do this when I recall steady state values in my model block (like in my Taylor rule).

I'm using the attached version and getting a "steadystate file did not compute the steadystate" error....
Attachments
MSDSGE_level_loop_short_steadystate.m
(1.9 KiB) Downloaded 80 times
hakeru7
 
Posts: 17
Joined: Sun Apr 19, 2015 4:10 am

Re: help looping over two parameters

Postby jpfeifer » Mon Apr 20, 2015 9:25 pm

Where do you all get these old, outdated, and error-prone steady state files from? Its structure is deprecated since ancient times and an up-to-date example is delivered with every Dynare installation in the examples folder (NK_baseline_steady_state.m). But in your case, this is unnecessary as shown below.

To your question. The problem is the following. You have e.g.
Code: Select all
parameters eeta Y_SS

and
Code: Select all
set_param_value('eeta',eeta);
...
// Analytic Steady State
Y_SS = ((eeta-1)/eeta)^(1/ttau)*gbar;

Obviously, the parameter Y_SS depends on eeta. But when you change eeta, you do not automatically change Y_SS with it. This is why you should use model-local variables or a steady state file to handle this dependence. In your case, I would recommend using a simple steady_state_model block, which automatically creates the corresponding steady state file. You simply need to move the I attach the corresponding file.

Lastly, one remark: you are using a linearized model. order=2 will be useless in this case and welfare evaluations usually wrong.
Attachments
MSDSGE_level_loop_short.mod
Corrected file
(4.24 KiB) Downloaded 119 times
------------
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: help looping over two parameters

Postby hakeru7 » Tue Apr 21, 2015 3:39 pm

thanks again for your reply. I didn't realize these steady state files were outdated. I got them from Chris Sim's lecture notes.

Would you be able to elaborate on your last remark there? What do you mean by my using a linearized model and order=2 being useless? I did want to do welfare evaluations eventually.
hakeru7
 
Posts: 17
Joined: Sun Apr 19, 2015 4:10 am

Re: help looping over two parameters

Postby jpfeifer » Tue Apr 21, 2015 4:43 pm

You cannot do welfare computations on a purely linearized model. You should use a second order approximation. At a minimum, if certain conditions are met (see Woodford (2002)), a linear-quadratic approach might be sufficient.
------------
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: help looping over two parameters

Postby hakeru7 » Tue Apr 21, 2015 5:19 pm

Sorry Johannes, I don't think I follow.

I thought with order=2 dynare is doing a second order approximation already. It was my understanding that inserting a welfare function into the model and using order=2 to do welfare analysis is common practice.

Am I missing something here? what is the difference between dynare order=2 and your suggestion of "use a second order approximation"?
hakeru7
 
Posts: 17
Joined: Sun Apr 19, 2015 4:10 am

Re: help looping over two parameters

Postby jpfeifer » Tue Apr 21, 2015 5:30 pm

If your model is already linearized, a second order approximation of these equations will be equal to a linear approximation, because you lost the second order terms already when entering the equations linearly. You can still append the objective function nonlinearly and you will get a second order approximation of the objective. But this linear quadratic approach is only valid under particular restrictions (e.g. undistorted steady state). In general, it will be false.
------------
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: help looping over two parameters

Postby hakeru7 » Tue Apr 21, 2015 5:56 pm

Right. That makes sense.

What I'm confused about is why you think my model is already linearized. The model block contains my FOCs in its raw form.
hakeru7
 
Posts: 17
Joined: Sun Apr 19, 2015 4:10 am

Re: help looping over two parameters

Postby jpfeifer » Tue Apr 21, 2015 7:52 pm

Sorry, my mistake. I only read the heading
// model in logs

in your file and presumed it was log-linearized. I should have looked more closely.
------------
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: help looping over two parameters

Postby hakeru7 » Tue Apr 21, 2015 9:10 pm

Sorry for the confusion. My file could have been neater...

Thanks so much for the all your comments and suggestions!
hakeru7
 
Posts: 17
Joined: Sun Apr 19, 2015 4:10 am

Re: help looping over two parameters

Postby pito » Thu Apr 23, 2015 9:00 pm

Hi everyone,
Let me continue on this topic, as I used the same approach to loop over 2 parameters, yet in a different model.
My question is what exactly stoch_simul(var_list_) does. Because my output matrix X delivers the wrong results, except the very first iteration (column 1 of X). Two parameters, which I am looping over (phiinf, phier), do not affect other parameters like it was in the previous case. Yet it is obvious that the results of matrix X (rows 3-14 starting from 2nd column) are not updated, if I run it separately for each pair of looped parameters as a check.
Would appreciate any reply.
Thank you,
Aliya
Attachments
Model10_rer_short.mod
(9.78 KiB) Downloaded 79 times
search.m
(31.39 KiB) Downloaded 71 times
pito
 
Posts: 16
Joined: Mon Feb 21, 2011 6:33 pm

Re: help looping over two parameters

Postby jpfeifer » Fri Apr 24, 2015 7:48 am

As shown above and in numerous posts, you must set the structural parameters you want to vary with
Code: Select all
set_param_value('phiinf',X(1,i));
set_param_value('phier',X(2,i));

You cannot simply use
Code: Select all
phiinf=X(1,i);
phier=X(2,i);

as you did.
------------
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: help looping over two parameters

Postby pito » Fri Apr 24, 2015 8:15 am

Still it doesn't solve the problem. The matrix X has wrong results. Because the cell (3,2) of X has a number -3.6626e+10, while the correct one should be -2.2986e+11 if a first iteration is that corresponding pair of looped parameters: phiinf=0.5, phier=0.
pito
 
Posts: 16
Joined: Mon Feb 21, 2011 6:33 pm

Next

Return to Dynare help

Who is online

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