dynare/tests/var-expectations/7/substitution.mod

53 lines
1.2 KiB
Modula-2
Raw Normal View History

// --+ options: stochastic,transform_unary_ops,json=compute +--
var foo z x y;
varexo e_x e_y e_z;
parameters a b c d e f beta ;
a = .9;
b = -.2;
c = .3;
f = .8;
d = .5;
e = .4;
@#include "example/model/var-expectations/varexp-parameters.inc"
beta = 1/(1+.02);
// Define a VAR_EXPECTATION_MODEL
var_model(model_name = toto, eqtags = [ 'X' 'Y' 'Z' ]);
model;
[ name = 'X' ]
diff(x) = a*diff(x(-1)) + b*diff(x(-2)) + c*z(-2) + e_x;
[ name = 'Z' ]
z = f*z(-1) + e_z;
[ name = 'Y' ]
log(y) = d*log(y(-2)) + e*z(-1) + e_y;
foo = .5*foo(-1) +
@#include "example/model/var-expectations/varexp-expression.inc"
;
end;
verbatim;
set_dynare_seed('default');
y = zeros(M_.endo_nbr,1);
y(1:M_.orig_endo_nbr) = rand(M_.orig_endo_nbr, 1);
x = randn(M_.exo_nbr,1);
y = substitution.set_auxiliary_variables(y, x, M_.params);
y = [y(find(M_.lead_lag_incidence(1,:))); y];
[residual, g1] = substitution.dynamic(y, x', M_.params, oo_.steady_state, 1);
example = load('example.mat');
end;
if max(abs(example.residual-residual))>1e-8
error('Residuals do not match!')
end
if max(max(abs(example.g1-g1)))>1e-8
error('Jacobian matrices do not match!')
end
delete('example.mat')