Added on-the-fly variable declaration in equation tags.

Manually cherry-picked 01d5a13082.
time-shift
Stéphane Adjemian (Charybdis) 2019-02-18 15:20:41 +01:00
parent 5d9764dd69
commit cb61cd98bd
Signed by untrusted user who does not match committer: stepan
GPG Key ID: A6D44CB9C64CE77B
1 changed files with 22 additions and 9 deletions

View File

@ -409,14 +409,25 @@ On-the-fly Model Variable Declaration
------------------------------------- -------------------------------------
Endogenous variables, exogenous variables, and parameters can also be declared Endogenous variables, exogenous variables, and parameters can also be declared
inside the model block. To do this, simply follow the symbol name with a inside the model block. You can do this in two different ways: either via the
vertical line (``|``) and either an ``e``, an ``x``, or a equation tag or directly in an equation.
``p``. For example, to declare a parameter named ``alphaa`` in the model
block, you could write ``alphaa|p`` directly in an equation where it To declare a variable on-the-fly in an equation tag, simply state the type of
appears. Similarly, to declare an endogenous variable ``c`` in the model variable to be declared (``endogenous``, ``exogenous``, or
block you could write ``c|e``. These on-the-fly variable declarations do not ``parameter`` followed by an equal sign and the variable name in single
have to appear in the first place where this variable is encountered. Note that quotes. Hence, to declare a variable ``c`` as endogenous in an equation tag,
on-the-fly variable declarations must be made on contemporaneous variables. you can type ``[endogenous='c']``.
To perform on-the-fly variable declaration in an equtaion, simply follow the
symbol name with a vertical line (``|``, pipe character) and either an ``e``, an
``x``, or a ``p``. For example, to declare a parameter named
``alphaa`` in the model block, you could write ``alphaa|p`` directly in
an equation where it appears. Similarly, to declare an endogenous variable
``c`` in the model block you could write ``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.
*Example* *Example*
@ -425,8 +436,9 @@ on-the-fly variable declarations must be made on contemporaneous variables.
:: ::
model; model;
[endogenous='k',name='law of motion of capital']
k(+1) = i|e + (1-delta|p)*k; k(+1) = i|e + (1-delta|p)*k;
y|e = k|e^alpha|p; y|e = k^alpha|p;
... ...
end; end;
delta = 0.025; delta = 0.025;
@ -440,6 +452,7 @@ on-the-fly variable declarations must be made on contemporaneous variables.
alpha = 0.36; alpha = 0.36;
... ...
model; model;
[name='law of motion of capital']
k(1) = i|e + (1-delta|p)*k; k(1) = i|e + (1-delta|p)*k;
y|e = k|e^alpha|p; y|e = k|e^alpha|p;
... ...