| 1 |
// --+ options: stochastic,transform_unary_ops,json=compute +-- |
| 2 |
|
| 3 |
var foo z x y; |
| 4 |
varexo e_x e_y e_z; |
| 5 |
parameters a b c d e f beta ; |
| 6 |
|
| 7 |
a = .9; |
| 8 |
b = -.2; |
| 9 |
c = .3; |
| 10 |
f = .8; |
| 11 |
d = .5; |
| 12 |
e = .4; |
| 13 |
|
| 14 |
@#include "example1/model/var-expectations/varexp-parameters.inc" |
| 15 |
|
| 16 |
beta = 1/(1+.02); |
| 17 |
|
| 18 |
// Define a VAR_EXPECTATION_MODEL |
| 19 |
var_model(model_name = toto, eqtags = [ 'X' 'Y' 'Z' ]); |
| 20 |
|
| 21 |
model; |
| 22 |
[ name = 'X' ] |
| 23 |
diff(x) = a*diff(x(-1)) + b*diff(x(-2)) + c*z(-2) + e_x; |
| 24 |
[ name = 'Z' ] |
| 25 |
z = f*z(-1) + e_z; |
| 26 |
[ name = 'Y' ] |
| 27 |
log(y) = d*log(y(-2)) + e*z(-1) + e_y; |
| 28 |
|
| 29 |
foo = .5*foo(-1) + |
| 30 |
@#include "example1/model/var-expectations/varexp-expression.inc" |
| 31 |
; |
| 32 |
end; |
| 33 |
|
| 34 |
shocks; |
| 35 |
var e_x = .01; |
| 36 |
var e_y = .01; |
| 37 |
var e_z = .01; |
| 38 |
end; |
| 39 |
|
| 40 |
verbatim; |
| 41 |
initialconditions =zeros(3,4); |
| 42 |
initialconditions(3,1) = .1; % foo(-1) |
| 43 |
initialconditions(:,2) = .2; % y(-1) |
| 44 |
initialconditions(3,3) = .3; % z(-1) |
| 45 |
initialconditions(2,3) = .4; % z(-2) |
| 46 |
initialconditions(3,4) = .5; % x(-1) |
| 47 |
initialconditions(2,4) = .6; % x(-2) |
| 48 |
initialconditions(1,4) = .7; % x(-3) |
| 49 |
initialconditions = ... |
| 50 |
dseries(initialconditions, dates('2000Q1'), {'foo', 'y','z', 'x'}); |
| 51 |
set_dynare_seed('default'); |
| 52 |
ts = simul_backward_model(initialconditions, 100); |
| 53 |
ex = load('example1.mat'); |
| 54 |
end; |
| 55 |
|
| 56 |
delete('example1.mat') |
| 57 |
|
| 58 |
if max(abs(ex.foo-ts.foo.data))>1e-12 |
| 59 |
error('Simulations do not match!') |
| 60 |
end |
| 61 |
|