Differences between revisions 3 and 4
Revision 3 as of 2010-11-25 14:13:25
Size: 1279
Editor: PabloWinant
Comment:
Revision 4 as of 2010-11-25 14:44:22
Size: 2007
Editor: PabloWinant
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
The feature was introduced in Dynare v.4.1. It allows user to attach arbitrary informations to each equation and to recover them at runtime. It is particularly useful to specify names of equations but can also be used to introduce other informations in the model.
Line 4: Line 6:

Before each equation in the modfile, the user can specify a list pairs (key,values) were key is any identifier and value a single-quoted string. This is demonstrated by the following example :

{{{
...preamble
model;
[name = 'Budget constraint']
c + k = k^theta*A;

[name = 'Euler condition']
beta*(c(1)/c)^(-sigma)*theta*k^(theta-1)*A(1) = 1;

[name = 'Specification of shocks']
log(A) = rho*log(A(-1)) + epsilon;
end;
...conclusion
}}}

Equations tags

The feature was introduced in Dynare v.4.1. It allows user to attach arbitrary informations to each equation and to recover them at runtime. It is particularly useful to specify names of equations but can also be used to introduce other informations in the model.

Flagging equations with tags

Before each equation in the modfile, the user can specify a list pairs (key,values) were key is any identifier and value a single-quoted string. This is demonstrated by the following example :

...preamble
model;
[name = 'Budget constraint']
c + k = k^theta*A;

[name = 'Euler condition']
beta*(c(1)/c)^(-sigma)*theta*k^(theta-1)*A(1) = 1;

[name = 'Specification of shocks']
log(A) = rho*log(A(-1))  + epsilon;
end;
...conclusion

Usecases

Find the equation corresponding to nonzero residuals

resid_with_names.m

Details about the implementation

  • Add general labels to equations. In the current prototype a list of key-values pair can be written in brackets before each equation :

[key='value',key='value',...] y = y + 1;

One may want to attach values of any type to an equation. Currently, only strings of characters are recognized but we ask the user to specify users to enter quoted strings nevertheless. Type of keys should also be restricted so that they can be used as fields in matlab structures if needed, i.e. no numeric character, no space,...

  • Structure in the preprocessor is the same as in Matlab and mimics a database table : an array with 3 columns. It is stored in M_.equations_tags as in :

M_.equations_tags = {
    1 'name' 'First equation';
    2 'name' 'Second equation';
    2 'portfolio' 'true';
};
  • It is easy to query this table in matlab as follows

tags = M_.equations_tags;
tags(cell2mat(tags(:,1))==2,2:3) % all tags for equation 2
tags(strmatch('name',tags(:,2)),[1 3]) % a vector with equations numbers and associated names

DynareWiki: EquationsTags (last edited 2010-11-25 15:25:34 by PabloWinant)