1/*
2 * Example 1 from F. Collard (2001): "Stochastic simulations with DYNARE:
3 * A practical guide" (see "guide.pdf" in the documentation directory).
4 */
5
6/*
7 * Copyright (C) 2001-2010 Dynare Team
8 *
9 * This file is part of Dynare.
10 *
11 * Dynare is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * Dynare is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
23 */
24
25
26var y, c, k, a, h, b;
27varexo e, u;
28
29parameters beta, rho, alpha, delta, theta, psi, tau;
30
31alpha = 0.36;
32rho   = 0.95;
33tau   = 0.025;
34beta  = 0.99;
35delta = 0.025;
36psi   = 0;
37theta = 2.95;
38
39phi   = 0.1;
40
41model;
42c*theta*h^(1+psi)=(1-alpha)*y;
43k = beta*(((exp(b)*c)/(exp(b(+1))*c(+1)))
44    *(exp(b(+1))*alpha*y(+1)+(1-delta)*k));
45y = exp(a)*(k(-1)^alpha)*(h^(1-alpha));
46k = exp(b)*(y-c)+(1-delta)*k(-1);
47a = rho*a(-1)+tau*b(-1) + e;
48b = tau*a(-1)+rho*b(-1) + u;
49end;
50
51initval;
52y = 1.08068253095672;
53c = 0.80359242014163;
54h = 0.29175631001732;
55k = 11.08360443260358;
56a = 0;
57b = 0;
58e = 0;
59u = 0;
60end;
61
62shocks;
63var e; stderr 1;
64var u; stderr 1;
65end;
66
67stoch_simul(irf=20,order=1,nomoments,nofunctions);
68unit_irf=cell2mat(struct2cell(oo_.irfs));
69
70shocks;
71var e; stderr 0.005;
72var u; stderr 0.005;
73end;
74
75stoch_simul(irf=20,order=1,relative_irf);
76relative_irfs=cell2mat(struct2cell(oo_.irfs));
77if max(max(abs(100*unit_irf-relative_irfs)))>1e-8;
78     error('relative_irf-option at order=1 is broken')
79end
80
81
82//Check relative IRF option at order 2 by comparing it with unnormalized IRF of unit size
83shocks;
84var e; stderr 0.01;
85var u; stderr 0.01;
86end;
87set_dynare_seed('default');
88options_.relative_irf=0;
89stoch_simul(irf=20,order=2,nomoments,nofunctions);
90unit_irf_order_2=cell2mat(struct2cell(oo_.irfs));
91
92shocks;
93var e; stderr 0.0095;
94var u; stderr 0.0095;
95end;
96set_dynare_seed('default');
97stoch_simul(irf=20,order=2,relative_irf,nomoments,nofunctions);
98relative_irfs_order_2=cell2mat(struct2cell(oo_.irfs));
99if max(max(abs(unit_irf_order_2-relative_irfs_order_2)))>2e-4;
100     error('relative_irf-option at order=2 is broken')
101end
102
103