Some questions about coding involving Dynare variables

Hello all,

I got a problem about coding involving Dynare variables. The situation is,

After running the dynare model file, I got something like M_, oo_. Given those, I would like to changethe parameter by locating corresponding location of “M_.params” based on “M_.param_names”, say I want to change the value of ‘BETTA’ and ‘ALPA’ defined in the model file, then what I can do is, including the following commands

par_list = strvcat(‘BETTA’,‘ALPA’);
par_value = [0.94 0.03];
par_list_ind = strmatch(par_list(i,:),M_.param_names,‘exact’);
M_.params(par_list_ind,:slight_smile: = par_value(i,:)’;

However, if the covariance matrix of shocks depends on parameter, eg,

shocks;
var epsah; stderr STD_EPSAH;
var epsaf; stderr STD_EPSAF;
var epsah, epsaf = COR_EPSAHAFSTD_EPSAHSTD_EPSAF;
end;

and after running dynare model file, we can get the below commands,

M_.Sigma_e(1, 1) = (M_.params(40))^2;
M_.Sigma_e(2, 2) = (M_.params(41))^2;
M_.Sigma_e(1, 2) = M_.params(41)*M_.params(40)*M_.params(42);
M_.Sigma_e(2, 1) = M_.Sigma_e(1, 2);

in abc.m if abc.mod is run by Dynare. In order to update the parameter of STD_EPSAH, STD_EPSAF, then, I need to include,

par_list = strvcat(‘STD_EPSAH’,‘STD_EPSAF’);
par_value = [0.01 0.01];
par_list_ind = strmatch(par_list(i,:),M_.param_names,‘exact’);
M_.params(par_list_ind,:slight_smile: = par_value(i,:)’;

On the other hands, Sigma_e should also be updated correspondingly but I want to ask is that, can I make the code to update Sigma_e flexibly by some commands instead of copying the commands in abc.m?

Furthermore, can I capture the commands

M_.Sigma_e(1, 1) = (M_.params(40))^2;
M_.Sigma_e(2, 2) = (M_.params(41))^2;
M_.Sigma_e(1, 2) = M_.params(41)*M_.params(40)*M_.params(42);
M_.Sigma_e(2, 1) = M_.Sigma_e(1, 2);

in abc.m fleixbly by including appropriate commands in .mod file?

Thanks for your kind attention.

For the first part, try using the set_param_value.m function provided by Dynare. That should make things easier. You should then be able to use that command in the mod file to set the parameters and then try to explicitly include the commands

M_.Sigma_e(1, 1) = (M_.params(40))^2; M_.Sigma_e(2, 2) = (M_.params(41))^2; M_.Sigma_e(1, 2) = M_.params(41)*M_.params(40)*M_.params(42); M_.Sigma_e(2, 1) = M_.Sigma_e(1, 2);
in the mod-file. That should work.

To jpfeifer,

Thanks for your reply.

I understood we can just explicitly include command

M_.Sigma_e(1, 1) = (M_.params(40))^2;
M_.Sigma_e(2, 2) = (M_.params(41))^2;
M_.Sigma_e(1, 2) = M_.params(41)*M_.params(40)*M_.params(42);
M_.Sigma_e(2, 1) = M_.Sigma_e(1, 2);

so that the covariance matrix is updated. However, if I just delete one parameter in the model file, then the corresponding parameters str no longer to be M_.params(40), M_.params(41) and M_.params(42). In this case, can I have some command to flexibly remedy such kind of situation?

Is there any way to update the covariance matrix M_.Sigma_e in a flexible way by including appropriate command when the covariance matrix depends on parameter?