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.

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?