Thanks for your kind reply. When I have a stoch_simul-command in the mod-file, which is put right before the maximization code, the results are a little different. The first is that the running time is much less when I have the stoch_simul-command. In your tested code, Dynare runs about 10 minutes in my computer. However, if I have stoch_simul-command right before the maximization code in the mod-file, Dynare just runs about several seconds. Why is the running time so different?
Another difference is that the welfare values which is stored in âfhatâ, is exactly the same with or without the stoch-simul command. But the optimal parameter values are very different. In your tested code, the two parameter values which is stored in âx_opt_hatâ, are 1.1583 and 7.6269, but 1.3077 and 86.8614 if having the stoch-simul command in the mod-file. Which result should I trust and why?
Besides, could you please show me how to write a loop to do the grid search? Is the code just inside the mod-file, or I have to write a separate m-file about the loop?
Sorry about that I have asked so many questions. I understand that it must spend you much time in answering my questions. Thank you very much. I am looking forward to your reply.
There should be no difference, except for different random numbers being used for the optimizer. Have you compared the value of the objective function for the two cases? Which one is lower?
Yes, that code for the grid search needs to encase the current call to the optimizer.
For example:
rho_grid_values=0.01:0.01:1;
n_grid_points=length(rho_grid_values);
fvalues=NaN(n_grid_points,1);
for ii=1:n_grid_points
set_param_value('rho',rho_grid_values(ii));
[fhat,x_opt_hat] = csminwel(@welfare_objective,x_start,H0,[],crit,nit,x_opt_name);
fvalues(ii)=fval;
x_optvalues(:,ii)=x_opt_hat;
end
Thanks for your reply. I have checked the value of the objective function for the two cases, one is that I put the maximization codes after the stoch_simul command, the other one is that I put the maximization codes right before the stoch_simul command. The âfhatâ is the same across the two cases, which is -5.4732. But the optimal parameter values are different. Could you please help me see whether there exists some mistakes?
When I put options_.irf=0;
in the mod-file, I donât get a difference with or without stoch_simul. Your model seems to feature local maxima that are found by the stochastic optimizer when you generate IRFs using random numbers. You should:
Try using a global optimizer
Potentially restrict the parameter space. Big values like 80 are often unreasonable.
Thanks for your reply. Could you please show me how to use a global optimizer in the mod-file? Besides, I have set irf=o after the stoch_simul command. Whatâs the difference using options_.irf=0?
Thanks for your kindly help. Based on your posted code, I write a loop within the mod-file, in order to do the grid search. Could you please help me check whether it is correct?
You obviously cannot use a grid to specify two parameter values and then for these given parameters find the optimal value for those parameters. What then is the point of having the outer loop?
Thanks for your reply. You previous post showed me about the grid search code with only one parameter. I thought it can also work for two parameters. However, could you please show me how to do grid search with multiple parameters in Dynare?
The parameters which I want to optimize over is rho_pi and rho_y, which are the coefficients of the Taylor rule. To be more specific, I want to search over a two dimensional grid, with the ranges for the three parameters being [1, 3] for rho_pi. [0, 3] for rho_y. And the grid step for each parameter is 0.1. The Taylor is standard as r=(1/beta_s)pi_c^rho_pi(y/steady_state(y))^rho_y. I want to find the optimized parameters values which can generate the highest welfare. The welfare is defined as the utility of the household, which is v in my code.
Could you please show me how to write the code for the grid search? Thank you very much!
Please find the attached paper. What I want to do is exactly the same as that in the paper. At the first paragraph of page 1512, it is stated that âWe search over a four-dimensional grid over the parameters rangesâŚâ, and also the footnote 25 of page 1512. Leaning against boom bust cycles in credit and housing prices.pdf (742.4 KB)
Could you please show me about how to do the grid search in Dynare? Thank you very much!
Again, there is no point in doing a grid search. You can simply find the optimal parameter combinations using a numerical optimizer as in the code I wrote above. Why do you want to find the maximum over a coarse grid instead?
Thanks for your explanation. However, when I run my mod-file using the optimizer code you posted, I find a problem: no matter how I change the parameters which are needed to be optimized, the maximized welfare always remain the same without any changes. The âfhatâ is always the same in many different cases. I have tried the optimizer with only one parameter - rho_pi, two parameters - rho_pi and rho_y, three parameters- rho_r, rho_pi and rho_y, and other scenarios. The âfhatâ always keeps fixed. Could you please help me check what the problem is and how to fix it? Here attached the code.
Moreover, I know that âfhatâ stores the maximized welfare value in my case. It is conditional or unconditional welfare?
I am not sure I understand. Running your code, I get an fhat of -5.567347243835366. Commenting out the optimization over rho_y, leaving only three parameters, I get -5.567345262735201, which is similar, but not identical.
You are computing unconditional welfare as you are reading out the unconditional mean of welfare.
Thanks for your reply. Could you please show me how to compute conditional welfare in Dynare?
You posted that I should âUse theoretical moments for welfare evaluationâ. My understanding is that I should compare the mean of âapproximated theoretical momentsâ shown in Matlab. If I am right, is the âapproximated theoretical momentsâ conditional or unconditional welfare for welfare comparison between different policy rules?
Thanks for your reply. I have one more question: Since I need to use the theoretical moments for welfare evaluation which is shown as the mean of âapproximated theoretical momentsâ shown in Matlab window, is it just the value in âfhatâ?