| 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 © 2001-2016 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 <https://www.gnu.org/licenses/>. |
| 23 |
*/ |
| 24 |
|
| 25 |
|
| 26 |
var y, c, k, a, h, b, e1, u1; |
| 27 |
varexo e, u; |
| 28 |
|
| 29 |
parameters beta, rho, alpha, delta, theta, psi, tau; |
| 30 |
|
| 31 |
alpha = 0.36; |
| 32 |
rho = 0.95; |
| 33 |
tau = 0.025; |
| 34 |
beta = 0.99; |
| 35 |
delta = 0.025; |
| 36 |
psi = 0; |
| 37 |
theta = 2.95; |
| 38 |
|
| 39 |
phi = 0.1; |
| 40 |
|
| 41 |
model; |
| 42 |
c*theta*h^(1+psi)=(1-alpha)*y; |
| 43 |
k = beta*(((b*c)/(b(+1)*c(+1))) |
| 44 |
*(b(+1)*alpha*y(+1)+(1-delta)*k)); |
| 45 |
y = a*(k(-1)^alpha)*(h^(1-alpha)); |
| 46 |
k = b*(y-c)+(1-delta)*k(-1); |
| 47 |
log(a) = rho*log(a(-1))+tau*log(b(-1)) + log(e1(-1)); |
| 48 |
log(b) = tau*log(a(-1))+rho*log(b(-1)) + log(u1(-1)); |
| 49 |
e1 = exp(e); |
| 50 |
u1 = exp(u); |
| 51 |
end; |
| 52 |
|
| 53 |
initval; |
| 54 |
y = 1.08068253095672; |
| 55 |
c = 0.80359242014163; |
| 56 |
h = 0.29175631001732; |
| 57 |
k = 11.08360443260358; |
| 58 |
a = 1; |
| 59 |
b = 1; |
| 60 |
e1 = 1; |
| 61 |
u1 = 1; |
| 62 |
end; |
| 63 |
|
| 64 |
shocks; |
| 65 |
var e; stderr 0.009; |
| 66 |
var u; stderr 0.009; |
| 67 |
var e, u = phi*0.009*0.009; |
| 68 |
end; |
| 69 |
|
| 70 |
stoch_simul(loglinear,order=1); |
| 71 |
|
| 72 |
D = load(['example4_loglinear_lagged_exogenous' filesep 'Output' filesep 'example4_loglinear_lagged_exogenous_results']); |
| 73 |
|
| 74 |
test1 = D.oo_.dr.ghx - oo_.dr.ghx; |
| 75 |
if norm(test1) > 1e-16; |
| 76 |
error('error in computing ghx'); |
| 77 |
end; |
| 78 |
test2 = D.oo_.dr.ghu - oo_.dr.ghu; |
| 79 |
if norm(test2) > 1e-16; |
| 80 |
error('error in computing ghu'); |
| 81 |
end; |
| 82 |
|
| 83 |
for i = fieldnames(D.oo_.irfs)'; |
| 84 |
test3 = D.oo_.irfs.(i{1}) - oo_.irfs.(i{1}); |
| 85 |
if norm(test2) > 1e-16; |
| 86 |
error(['error in computing irf ' i]); |
| 87 |
end; |
| 88 |
end; |
| 89 |
|