File: example_nls.mod

package info (click to toggle)
dynare 5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 77,852 kB
  • sloc: cpp: 94,481; ansic: 28,551; pascal: 14,532; sh: 5,453; objc: 4,671; yacc: 4,442; makefile: 2,923; lex: 1,612; python: 677; ruby: 469; lisp: 156; xml: 22
file content (67 lines) | stat: -rw-r--r-- 1,168 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// --+ options: json=compute, stochastic +--

var y x z x1 z1 ;

varexo ey ex ez;

parameters alpha beta;

alpha = 1.0/3.0;
beta = 0.77;

model;

  [name='eq4x1']
  x1 = .5*x1(-1) + ex;

  [name='eq4z1']
  z1 = .8*z1(-1) + ez;

  [name='eq4x']
  x = x1^2/(1+x1^2);

  [name='eq4z']
  z = z1^2/(1+z1^2);

  [name='eq4y']
  y = alpha*x + (1-alpha)*z + beta*((1-alpha)*y(-1)+alpha*y(-2))+ey;

end;

/*
** Artificial dataset
*/

shocks;
  var ex = .1;
  var ez = .1;
  var ey = .1;
end;

histval;
  x1(0) = 0;
  z1(0) = 0;
  x(0) = 0;
  z(0) = 0;
  y(0) = 0;
  y(-1) = 0;
end;

simulations = simul_backward_model([], 102);

/*
** Estimation by NLS
*/

eparams.alpha = .7;
eparams.beta = 1;

simulations.ey = dseries(NaN); // Reset residuals of the equation to NaN.

if ~isoctave
    % Under Octave, estimate.nls (provided by matlab/+estimate/nls.m) is not
    % accessible because there is a function which has the same name as the
    % +estimate package, namely matlab/cli/estimate.m. This is a known Octave
    % bug (https://savannah.gnu.org/bugs/?func=detailitem&item_id=46889).
    estimate.nls('eq4y', eparams, simulations, dates('3Y'):simulations.dates(end));
end