Debian Codegraph @

tests/model-inversion/bk-diff-3/varmodel.mod

raw
1 // --+ options: stochastic +--
2
3 /* © 2022 Dynare Team
4 *
5 * This file is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * It is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with the file. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 @#define USE_HISTVAL = 0
20
21 var y ;
22
23 varexo e ;
24
25 parameters rho ;
26
27 rho = 1.0;
28
29 model(linear);
30 diff(y) = rho*diff(y(-1)) + e ;
31 end;
32
33 shocks;
34 var e = 1.0;
35 end;
36
37 steady;
38
39 check;
40
41 innovations = dseries(ones(200,1), 3Y, 'e');
42
43 @#if USE_HISTVAL
44 histval;
45 y(-1) = 0.0;
46 y(0) = 1.0;
47 end;
48 TrueData = simul_backward_model([], 200, innovations);
49 @#else
50 initdata = zeros(2, 2);
51 initdata(1,1) = 0.0;
52 initdata(2,1) = 1.0;
53 initialconditions = dseries(initdata, 1Y, vertcat(M_.endo_names(1:M_.orig_endo_nbr), M_.exo_names));
54 TrueData = simul_backward_model(initialconditions, 200, innovations);
55 @#endif
56
57 y0 = TrueData(2Y).y.data;
58 yts = TrueData(3Y:10Y).y.data;
59 yex = 1+cumsum(y0+cumsum(ones(8,1)));
60
61 assert(~any(yts-yex), 'Simulation is wrong!')
62
63 // Set the periods where some of the endogenous variables will be constrained.
64 subsample = 3Y:100Y;
65
66 // Load the generated data
67 SimulatedData = copy(TrueData);
68
69 // Set the constrained paths for the endogenous variables (Output and PhysicalCapitalStock).
70 constrainedpaths = SimulatedData{'y'}(subsample);
71
72 // Set the instruments (innovations used to control the paths for the endogenous variables).
73 exogenousvariables = dseries(NaN(98, 1), 3Y, M_.exo_names);
74
75 // Invert the model by calling the model_inversion routine.
76 [endogenousvariables, exogenousvariables] = model_inversion(constrainedpaths, exogenousvariables, SimulatedData, M_, options_, oo_);
77
78 assert(all(exogenousvariables.e.data==1), 'Inversion is wrong!');