preprocessor: submodule update; introduction of on-the-fly variable declaration
parent
bf6b96a860
commit
7f3120eb2e
|
@ -221,6 +221,10 @@ The Model file
|
|||
* Verbatim inclusion::
|
||||
* Misc commands::
|
||||
|
||||
Variable declarations
|
||||
|
||||
* On-the-fly Model Variable Declaration::
|
||||
|
||||
Expressions
|
||||
|
||||
* Parameters and variables::
|
||||
|
@ -979,6 +983,7 @@ Allows Dynare to issue a warning and continue processing when
|
|||
@enumerate
|
||||
@item there are more endogenous variables than equations
|
||||
@item an undeclared symbol is assigned in @code{initval} or @code{endval}
|
||||
@item an undeclared symbol is found in the @code{model} block; in this case, it is automatically declared exogenous
|
||||
@item exogenous variables were declared but not used in the @code{model} block
|
||||
@end enumerate
|
||||
|
||||
|
@ -1614,6 +1619,50 @@ model_local_variable GDP_US $GDPUS$;
|
|||
|
||||
@end deffn
|
||||
|
||||
@menu
|
||||
* On-the-fly Model Variable Declaration::
|
||||
@end menu
|
||||
|
||||
@node On-the-fly Model Variable Declaration
|
||||
@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
|
||||
on-the-fly variable declarations must be made on contemporaneous variables.
|
||||
|
||||
As an example, the following two snippets are equivalent:
|
||||
|
||||
@emph{Using on-the-fly variable and parameter declaration}
|
||||
@example
|
||||
model;
|
||||
k(+1) = i|e + (1-delta|p)*k;
|
||||
y|e = k|e^alpha|p;
|
||||
@dots{}
|
||||
end;
|
||||
delta = 0.025;
|
||||
alpha = 0.36;
|
||||
@end example
|
||||
|
||||
@emph{Using standard variable declaration}
|
||||
@example
|
||||
var k, i, y;
|
||||
parameters delta, alpha;
|
||||
delta = 0.025;
|
||||
alpha = 0.36;
|
||||
@dots{}
|
||||
model;
|
||||
k(1) = i|e + (1-delta|p)*k;
|
||||
y|e = k|e^alpha|p;
|
||||
@dots{}
|
||||
end;
|
||||
@end example
|
||||
|
||||
@node Expressions
|
||||
@section Expressions
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 5727083865753f5abde8bdc0c20eee2b1ed5a501
|
||||
Subproject commit db1f6c2998279582da95b83a1f59cfdf1f8f8c40
|
|
@ -52,6 +52,7 @@ MODFILES = \
|
|||
ramst_a.mod \
|
||||
ramst_static_tag.mod \
|
||||
example1.mod \
|
||||
example1_on_the_fly.mod \
|
||||
example2.mod \
|
||||
example1_use_dll.mod \
|
||||
example1_with_tags.mod \
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
// Example 1 from Collard's guide to Dynare
|
||||
model;
|
||||
c|e*theta|p*h|e^(1+psi|p)=(1-alpha)*y;
|
||||
k|e = beta|p*(((exp(b)*c)/(exp(b(+1))*c(+1)))
|
||||
*(exp(b(+1))*alpha|p*y(+1)+(1-delta)*k));
|
||||
y|e = exp(a)*(k(-1)^alpha)*(h^(1-alpha));
|
||||
k = exp(b)*(y-c)+(1-delta|p)*k(-1);
|
||||
a|e = rho|p*a(-1)+tau*b(-1) + e|x;
|
||||
b|e = tau|p*a(-1)+rho*b(-1) + u|x;
|
||||
end;
|
||||
|
||||
alpha = 0.36;
|
||||
rho = 0.95;
|
||||
tau = 0.025;
|
||||
beta = 0.99;
|
||||
delta = 0.025;
|
||||
psi = 0;
|
||||
theta = 2.95;
|
||||
|
||||
phi = 0.1;
|
||||
|
||||
initval;
|
||||
y = 1.08068253095672;
|
||||
c = 0.80359242014163;
|
||||
h = 0.29175631001732;
|
||||
k = 11.08360443260358;
|
||||
a = 0;
|
||||
b = 0;
|
||||
e = 0;
|
||||
u = 0;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e; stderr 0.009;
|
||||
var u; stderr 0.009;
|
||||
var e, u = phi*0.009*0.009;
|
||||
end;
|
||||
|
||||
stoch_simul;
|
Loading…
Reference in New Issue