Hi,
Recently, I am learning on how to loop over parameters. I searched almost all posts on this topic, but I still encounterd some confusing problems that I can’t find any exact answer in the forum. So I decide to ask for help.
The example is used for OSR (optimal simple rules) analysis. To simplify, I just set two values of spectific parameter (phipi=0 or 1) to examine whether different initial values of parameter will affect the results of the optimal parameters and corresponding welfare loss. I have tried the following three methods:
- Repeatly run Dynare (osr1.mod (1.9 KB))
- Loop for Dynare block osr(osr2.mod (2.3 KB))
- Loop for Matlab rountine oo_.osr(osr3.mod (2.4 KB))
Results of several trials by using these codes:
-
Results of repeatly run Dynare
when initial value of phipi is: 0
optimal param of phipi and phiy : -0.0052839, 0.11621
welfare loss : 3.8016
when initial value of phipi is: 1
optimal param of phipi and phiy : 0.99343, 0.12251
welfare loss : 2.6148 -
Results of loop for Dynare block osr (phipi=0 in parameters block)
when initial value of phipi is: 0
optimal param of phipi and phiy : -0.0052839, 0.11621
welfare loss : 3.8016
when initial value of phipi is: 1
optimal param of phipi and phiy : 1.0378, 0.11462
welfare loss : 3.8016 -
Results of loop for Dynare block osr (phipi=1 in parameters block)
when initial value of phipi is: 0
optimal param of phipi and phiy : 0.0027466, 0.15222
welfare loss : 2.6148
when initial value of phipi is: 1
optimal param of phipi and phiy : 0.99343, 0.12251
welfare loss : 2.6148 -
Results of loop for Matlab rountine oo_.osr (phipi=0 in parameters block)
when initial value of phipi is: 0
optimal param of phipi and phiy : -0.0052839, 0.11621
welfare loss : 3.8016
Results of loop for Matlab rountine oo_.osr
when initial value of phipi is: 1
optimal param of phipi and phiy : 1.0378, 0.11462
welfare loss : 3.8016 -
Results of loop for Matlab rountine oo_.osr (phipi=1 in parameters block)
when initial value of phipi is: 0
optimal param of phipi and phiy : 0.0027466, 0.15222
welfare loss : 2.6148
Results of loop for Matlab rountine oo_.osr
when initial value of phipi is: 1
optimal param of phipi and phiy : 0.99343, 0.12251
welfare loss : 2.6148
Just change the initial value of phipi in parameters block of osr1 and repeatly run Dynare twice to get result1. Run osr2 twice to get result2 and result3. Run osr3 twice to get result4 and result5. Now my questions are as follows:
-
About the concept of OSR command. Though I have used the global optimizer (opt_algo=9) and seed command [set_dynare_seed(‘default’)], while whichever method I choose, different initial values of parameter phipi lead to different results of OSR parameters and welfare loss. Why? Doesn’t global optimal mean the same optimal parameters and welfare loss? Or does it just mean the same minimum welfare loss?
-
About the concept of ‘loop over parameters’. I know looping over parameters is efficient. I originally think the efficiency just mean less time and more convenient for comparation, but it seems the results are also different (compare result1 with result(2-5)). What is the rationale causing the different results between repeatly run Dynare (method1) and loop for Matlab rountine oo_.osr(method3)? Can I simply use the results of repeatly run Dynare?
-
Different values in parameters block affect the results. Look at the two loop codes (ors2 or ors3), when manually change the value of phipi in parameters block, the results turn out to be different. Since I have used set_param_value command to reset the initial value of parameter phipi, why that happens?
-
What’s the difference between ors2 and osr3. Why the results are same when setting identical value in parameters block (result2=result4, result3=result5). But when I delete the seed command, they turn out to be different. I just follow some examples about stoch_simul to set ors2, and I guess it may be same with repeatly run Dynare. But it’s not the case in my example, so I am not sure if ors2 is right written.
These questions have been confusing me for quite long time. I would be very grateful for any help. Thank you in advance.
Best,
Kairey