Debian Codegraph @

tests/pac/trend-component-4/example1.mod

raw
1 // --+ options: json=compute, stochastic +--
2
3 var x1 x2 x1bar x2bar z ;
4
5 varexo ex1 ex2 ex1bar ex2bar ez ;
6
7 parameters a_x1_0 a_x1_0_ a_x1_1 a_x1_2 a_x1_x2_1 a_x1_x2_2
8 a_x2_0 a_x2_1 a_x2_2 a_x2_x1_1 a_x2_x1_2
9 e_c_m c_z_1 c_z_2 gamma beta ;
10
11 a_x1_0 = -.9;
12 a_x1_0_ = -.8;
13 a_x1_1 = .4;
14 a_x1_2 = .3;
15 a_x1_x2_1 = .1;
16 a_x1_x2_2 = .2;
17
18
19 a_x2_0 = -.9;
20 a_x2_1 = .2;
21 a_x2_2 = -.1;
22 a_x2_x1_1 = -.1;
23 a_x2_x1_2 = .2;
24
25 beta = .2;
26 e_c_m = .5;
27 c_z_1 = .2;
28 c_z_2 = -.1;
29
30 gamma = .9;
31
32 trend_component_model(model_name=toto, eqtags=['eq:x1', 'eq:x2', 'eq:x1bar', 'eq:x2bar'], targets=['eq:x1bar', 'eq:x2bar']);
33
34 pac_model(auxiliary_model_name=toto, discount=beta, model_name=pacman);
35
36 model;
37
38 [name='eq:x1']
39 diff(x1) = a_x1_0*(x1(-1)-x1bar(-1))+a_x1_0_*(x2(-1)-x2bar(-1)) + a_x1_1*diff(x1(-1)) + a_x1_2*diff(x1(-2)) + + a_x1_x2_1*diff(x2(-1)) + a_x1_x2_2*diff(x2(-2)) + ex1;
40
41 [name='eq:x2']
42 diff(x2) = a_x2_0*(x2(-1)-x2bar(-1)) + a_x2_1*diff(x1(-1)) + a_x2_2*diff(x1(-2)) + + a_x2_x1_1*diff(x2(-1)) + a_x2_x1_2*diff(x2(-2)) + ex2;
43
44 [name='eq:x1bar']
45 x1bar = x1bar(-1) + ex1bar;
46
47 [name='eq:x2bar']
48 x2bar = x2bar(-1) + ex2bar;
49
50 [name='eq:pac']
51 diff(z) = gamma*(e_c_m*(x1(-1)-z(-1)) + c_z_1*diff(z(-1)) + c_z_2*diff(z(-2)) + pac_expectation(pacman)) + (1-gamma)*ez;
52
53 end;
54
55 shocks;
56 var ex1 = 1.0;
57 var ex2 = 1.0;
58 var ex1bar = 1.0;
59 var ex2bar = 1.0;
60 var ez = 1.0;
61 end;
62
63 // Initialize the PAC model (build the Companion VAR representation for the auxiliary model).
64 pac.initialize('pacman');
65
66 // Update the parameters of the PAC expectation model (h0 and h1 vectors).
67 pac.update.expectation('pacman');
68
69 // Set initial conditions to zero. Please use more sensible values if any...
70 initialconditions = dseries(zeros(10, M_.endo_nbr+M_.exo_nbr), 2000Q1, vertcat(M_.endo_names,M_.exo_names));
71
72 // Simulate the model for 500 periods
73 TrueData = simul_backward_model(initialconditions, 5000);