Some questions about coding involving Dynare variables

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Some questions about coding involving Dynare variables

Postby dennis0125hk » Wed Jun 06, 2012 1:32 pm

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.
dennis0125hk
 
Posts: 18
Joined: Mon Jan 19, 2009 2:28 am

Re: Some questions about coding involving Dynare variables

Postby jpfeifer » Wed Jun 06, 2012 6:53 pm

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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Some questions about coding involving Dynare variables

Postby dennis0125hk » Thu Jun 07, 2012 12:22 am

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?
dennis0125hk
 
Posts: 18
Joined: Mon Jan 19, 2009 2:28 am

Re: Some questions about coding involving Dynare variables

Postby dennis0125hk » Sun Jun 10, 2012 3:08 pm

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?
dennis0125hk
 
Posts: 18
Joined: Mon Jan 19, 2009 2:28 am


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 5 guests

cron