Debian Codegraph @

tests/estimation/univariate/nls/dynamicmodel2.mod

raw
1 // --+ options: json=compute, stochastic +--
2
3 var y x z x1 z1 ;
4
5 varexo ey ex ez;
6
7 parameters alpha beta;
8
9 alpha = 1.0/3.0;
10 beta = 0.77;
11
12 model;
13
14 [name='eq4x1']
15 x1 = .5*x1(-1) + ex;
16
17 [name='eq4z1']
18 z1 = .8*z1(-1) + ez;
19
20 [name='eq4x']
21 x = x1^2/(1+x1^2);
22
23 [name='eq4z']
24 z = z1^2/(1+z1^2);
25
26 [name='eq4y']
27 y = alpha*x + (1-alpha)*z + beta*((1-alpha)*y(-1)+alpha*y(-2))+ey;
28
29 end;
30
31 /*
32 ** Artificial dataset
33 */
34
35 shocks;
36 var ex = .1;
37 var ez = .1;
38 var ey = .1;
39 end;
40
41 histval;
42 x1(0) = 0;
43 z1(0) = 0;
44 x(0) = 0;
45 z(0) = 0;
46 y(0) = 0;
47 y(-1) = 0;
48 end;
49
50 simulations = simul_backward_model([], 102);
51
52 /*
53 ** Estimation by NLS
54 */
55
56 eparams.alpha = .7;
57 eparams.beta = 1;
58
59 simulations.ey = dseries(NaN); // Reset residuals of the equation to NaN.
60
61 if ~isoctave
62 % Under Octave, estimate.nls (provided by matlab/+estimate/nls.m) is not
63 % accessible because there is a function which has the same name as the
64 % +estimate package, namely matlab/cli/estimate.m. This is a known Octave
65 % bug (https://savannah.gnu.org/bugs/?func=detailitem&item_id=46889).
66 estimate.nls('eq4y', eparams, simulations, dates('3Y'):simulations.dates(end));
67 end