Page 1 of 1

Obtaining optimal values for policy function

PostPosted: Fri Sep 25, 2015 11:14 am
by dphm
Hi everyone

I am really in need of help right now because I've been searching but there seems to be no clear documentation on this. Hence, I'd really appreciate it if anyone can help me on this.

It's basically the same old problem of expressing welfare as: W = U + W(+1) and for this objective function W, I wish to find the optimal parameters in my policy rule that will maximize the welfare. There are two parameters in my policy rule now and one of them has a lower bound of 0 and an upper bound of 1 while the other is not bounded. I have read that I need to solve the model to second-order to do so which does make sense mathematically.

However, I think Dynare can neither search through a range of parameters nor return me the set of parameters that achieves the maximum welfare. So I believe I have to implement this in an m file. But the big problem is I've no idea how I can link m files to mod files except through the steady; command.

Can anyone help me with this?

Thank you very much.

Re: Obtaining optimal values for policy function

PostPosted: Sun Sep 27, 2015 8:24 am
by jpfeifer
Basically, you have to operate a minimizer over the stoch_simul-command at order=2. For looping in general, see http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=4891

Re: Obtaining optimal values for policy function

PostPosted: Sun Sep 27, 2015 9:35 am
by dphm
Hey jpfeifer

Thank you for your reply! I really appreciate it because I could desperately use some help now.

Are you referring to this code?
rhos = 0.8:0.05:1.05;
first_time = 1;
for i=1:length(rhos)
if first_time
set_param_value('rho',rhos(i));
dynare your_mod_file_here noclearall;
first_time = 0;
else
set_param_value('rho',rhos(i));
info = stoch_simul(var_list_);
if info;
disp(['Computation fails for rho = ' num2str(rho)]);
end;
end
end


Sorry but I don't see the optimization part in this code. I mean how can Matlab find the optimal utility from this code?

Also, another question is I do have to insert the welfare function as well as the utility function into my mod file as two additional endogenous variables right?

Thank you.

Re: Obtaining optimal values for policy function

PostPosted: Mon Sep 28, 2015 9:13 pm
by jpfeifer
For how to use an optimizer in the context of Dynare, see the replication files to Born/Pfeifer (2014): Risk matters: a comment

Re: Obtaining optimal values for policy function

PostPosted: Tue Sep 29, 2015 12:57 am
by dphm
Hey jpfeifer

Thank you for referring me to the resources!

Sorry I'm really new to this but do you mean the mod file in the zip file?

Thanks.

Re: Obtaining optimal values for policy function

PostPosted: Tue Sep 29, 2015 6:07 am
by jpfeifer
Yes, the mod-file at the bottom calls an optimizer. There you can also see the objective function called.