Page 1 of 1

Some questions about coding involving Dynare variables

PostPosted: Wed Jun 06, 2012 1:32 pm
by dennis0125hk
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,:) = 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_EPSAHAF*STD_EPSAH*STD_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,:) = 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.

Re: Some questions about coding involving Dynare variables

PostPosted: Wed Jun 06, 2012 6:53 pm
by jpfeifer
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

Code: Select all
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.

Re: Some questions about coding involving Dynare variables

PostPosted: Thu Jun 07, 2012 12:22 am
by dennis0125hk
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?

Re: Some questions about coding involving Dynare variables

PostPosted: Sun Jun 10, 2012 3:08 pm
by dennis0125hk
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?