preprocessor: submodule update: on-the-fly variable declaration in equation tags

time-shift
Houtan Bastani 2018-07-09 15:36:10 +02:00
parent cfee93b080
commit 01d5a13082
3 changed files with 24 additions and 10 deletions

View File

@ -1618,22 +1618,34 @@ model_local_variable GDP_US $GDPUS$;
@subsection On-the-fly Model Variable Declaration
Endogenous variables, exogenous variables, and parameters can also be declared
inside the model block. To do this, simply follow the symbol name with a
vertical line (@code{|}) and either an @code{e}, an @code{x}, or a
@code{p}. For example, to declare a parameter named @code{alphaa} in the model
block, you could write @code{alphaa|p} directly in an equation where it
appears. Similarly, to declare an endogenous variable @code{c} in the model
block you could write @code{c|e}. These on-the-fly variable declarations do not
have to appear in the first place where this variable is encountered. Note that
inside the model block. You can do this in two different ways: either via the
equation tag or directly in an equation.
To declare a variable on-the-fly in an equation tag, simply state the type of
variable to be declared (@code{endogenous}, @code{exogenous}, or
@code{parameter} followed by an equal sign and the variable name in single
quotes. Hence, to declare a variable @code{c} as endogenous in an equation tag,
you can type @code{[endogenous='c']}.
To perform on-the-fly variable declaration in an equtaion, simply follow the
symbol name with a vertical line (@code{|}) and either an @code{e}, an
@code{x}, or a @code{p}. For example, to declare a parameter named
@code{alphaa} in the model block, you could write @code{alphaa|p} directly in
an equation where it appears. Similarly, to declare an endogenous variable
@code{c} in the model block you could write @code{c|e}. Note that in-equation
on-the-fly variable declarations must be made on contemporaneous variables.
On-the-fly variable declarations do not have to appear in the first place where
this variable is encountered.
As an example, the following two snippets are equivalent:
@emph{Using on-the-fly variable and parameter declaration}
@example
model;
[endogenous='k',name='law of motion of capital']
k(+1) = i|e + (1-delta|p)*k;
y|e = k|e^alpha|p;
y|e = k^alpha|p;
@dots{}
end;
delta = 0.025;
@ -1648,6 +1660,7 @@ delta = 0.025;
alpha = 0.36;
@dots{}
model;
[name='law of motion of capital']
k(1) = i|e + (1-delta|p)*k;
y|e = k|e^alpha|p;
@dots{}

@ -1 +1 @@
Subproject commit 244552393baec541e0d02a2c378a21a6c9409989
Subproject commit e0bf2b60b65814f66c4009f2e36cfcdabdb7f913

View File

@ -1,5 +1,5 @@
// Example 1 from Collard's guide to Dynare
var y, c, k, a, h, b;
var y, k, a, h, b;
varexo e, u;
verbatim;
@ -22,6 +22,7 @@ theta = 2.95;
phi = 0.1;
model;
[endogenous='c',name='law of motion of capital']
c*theta*h^(1+psi)=(1-alpha)*y;
k = beta*(((exp(b)*c)/(exp(b(+1))*c(+1)))
*(exp(b(+1))*alpha*y(+1)+(1-delta)*k));