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…
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”
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?
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… MSDSGE_level_loop_short_steadystate.m (1.9 KB)
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.
parameters eeta Y_SS
and
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. MSDSGE_level_loop_short.mod (4.24 KB)
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.
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.
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”?
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.
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 Model10_rer_short.mod (9.78 KB) search.m (31.4 KB)
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.
I am not confusing rows and columns. My matrix X is this up to 3rd row after loop is made, I am not showing other rows, sorry for bad formatting. But you see the cell (3,2) which is -36626165419.0826 under phiinf=0.5, phier=0.
Now let’s change my looping range as if my first iteration starts from that phiinf=0.5, phier=0. The three rows of matrix X will look like this then, showing that the correct number should be -229862535943.196.
You rely on stochastic simulations. Without fixing a seed with
set_dynare_seed('default')
before calling stoch_simul, you will be using different random numbers. The reason is that when calling Dynare, a seed is set. When only calling stoch_simul, this is not the case. You need to do this manually.
Let me continue on this, but in a perfect foresight model. I remember that set_dynare_seed command, as you’ve suggested earlier, helped me to fix my issue in a stochastic model.
Now I am looping over one parameter which affects my exogenous shocks path that I am feeding into a perfect foresight model. I observe that shocks path is replaced properly, yet the results of simulation are not correct after the second iteration of a parameter, if I check just the way I described in my previous post here. Obviously, set_dynare_seed is not a solution as before. What should I control for to deal with basically the same problem, but in a perfect foresight framework?
Would appreciate any helpful reply.