| 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-2022 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; |
| 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)) + e; |
| 48 |
log(b) = tau*log(a(-1))+rho*log(b(-1)) + u; |
| 49 |
end; |
| 50 |
|
| 51 |
initval; |
| 52 |
y = 1.08068253095672; |
| 53 |
c = 0.80359242014163; |
| 54 |
h = 0.29175631001732; |
| 55 |
k = 11.08360443260358; |
| 56 |
a = 1; |
| 57 |
b = 1; |
| 58 |
end; |
| 59 |
|
| 60 |
resid; |
| 61 |
shocks; |
| 62 |
var e; stderr 0.009; |
| 63 |
var u; stderr 0.009; |
| 64 |
var e, u = phi*0.009*0.009; |
| 65 |
end; |
| 66 |
|
| 67 |
histval; |
| 68 |
k(0) = 11.08; |
| 69 |
a(0) = 1.2; |
| 70 |
b(0) = 1; |
| 71 |
end; |
| 72 |
|
| 73 |
stoch_simul(loglinear,order=1,periods=1000); |
| 74 |
forecast; |
| 75 |
|
| 76 |
load results_exp_histval; |
| 77 |
if max(max(abs(oo_.dr.ghx-oo_exp.dr.ghx)))>1e-10 |
| 78 |
error('Option loglinear wrong, ghx not equal') |
| 79 |
end |
| 80 |
if max(max(abs(oo_.dr.ghu-oo_exp.dr.ghu)))>1e-10 |
| 81 |
error('Option loglinear wrong, ghu not equal') |
| 82 |
end |
| 83 |
if max(max(abs(oo_.irfs.y_e-oo_exp.irfs.y_e)))>1e-10 |
| 84 |
error('Option loglinear wrong, IRFs not equal') |
| 85 |
end |
| 86 |
if max(max(abs(oo_.irfs.y_u-oo_exp.irfs.y_u)))>1e-10 |
| 87 |
error('Option loglinear wrong, ghu not equal') |
| 88 |
end |
| 89 |
if max(max(abs(oo_.mean-oo_exp.mean)))>1e-10 |
| 90 |
error('Option loglinear wrong, mean not equal') |
| 91 |
end |
| 92 |
if max(max(abs(oo_.dr.ys-oo_exp.dr.ys)))>1e-10 |
| 93 |
error('Option loglinear wrong, ys not equal') |
| 94 |
end |
| 95 |
if max(max(abs(oo_.steady_state-oo_exp.steady_state)))>1e-10 |
| 96 |
error('Option loglinear wrong, steady_state not equal') |
| 97 |
end |
| 98 |
|
| 99 |
if max(max(abs(struct2array(oo_.forecast.Mean)-struct2array(oo_exp.forecast.Mean))))>1e-10 || ... |
| 100 |
max(max(abs(struct2array(oo_.forecast.HPDinf)-struct2array(oo_exp.forecast.HPDinf))))>1e-10 || ... |
| 101 |
max(max(abs(struct2array(oo_.forecast.HPDsup)-struct2array(oo_exp.forecast.HPDsup))))>1e-10 |
| 102 |
error('Option loglinear wrong, forecast not equal') |
| 103 |
end |
| 104 |
|
| 105 |
conditional_forecast_paths; |
| 106 |
var a; |
| 107 |
periods 1 2 ; |
| 108 |
values 0.01 -0.02; |
| 109 |
var b; |
| 110 |
periods 1 2; |
| 111 |
values 0.05 0; |
| 112 |
end; |
| 113 |
|
| 114 |
conditional_forecast(parameter_set=calibration, controlled_varexo=(u,e)); |
| 115 |
|
| 116 |
|
| 117 |
forecasts=oo_.conditional_forecast; |
| 118 |
|
| 119 |
if max(max(abs(struct2array(forecasts.cond.Mean)-struct2array(conditional_forecasts_exp.cond.Mean))))>1e-10 || ... |
| 120 |
max(max(abs(struct2array(forecasts.cond.ci)-struct2array(conditional_forecasts_exp.cond.ci))))>1e-10 || ... |
| 121 |
max(max(abs(struct2array(forecasts.uncond.Mean)-struct2array(conditional_forecasts_exp.uncond.Mean))))>1e-10 || ... |
| 122 |
max(max(abs(struct2array(forecasts.uncond.ci)-struct2array(conditional_forecasts_exp.uncond.ci))))>1e-10 |
| 123 |
error('Option loglinear wrong, conditional forecast not equal') |
| 124 |
end |