| 1 |
/* |
| 2 |
* Test functionality of model_info on a more complex model with many leads and lags/states. |
| 3 |
* Prevents regression where loop over states did lead to index overflow of block indices. |
| 4 |
*/ |
| 5 |
|
| 6 |
/* |
| 7 |
* Copyright © 2010-2026 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 |
@#define countries = [ "H", "F" ] |
| 26 |
@#define J = 4 |
| 27 |
|
| 28 |
@#for co in countries |
| 29 |
var C_@{co} L_@{co} N_@{co} A_@{co} K_@{co} Z_@{co} X_@{co} LAMBDA_@{co} S_@{co} NX_@{co} Y_@{co}; |
| 30 |
|
| 31 |
varexo E_@{co}; |
| 32 |
|
| 33 |
parameters beta_@{co} alpha_@{co} eta_@{co} mu_@{co} gamma_@{co} theta_@{co} nu_@{co} sigma_@{co} delta_@{co} phi_@{co} psi_@{co} rho_@{co}_@{co}; |
| 34 |
@#endfor |
| 35 |
|
| 36 |
// Lagrange multiplier of aggregate constraint |
| 37 |
var LGM; |
| 38 |
|
| 39 |
parameters rho_@{countries[1]}_@{countries[2]} rho_@{countries[2]}_@{countries[1]}; |
| 40 |
|
| 41 |
model(block); |
| 42 |
@#for co in countries |
| 43 |
|
| 44 |
Y_@{co} = ((LAMBDA_@{co}*K_@{co}(-@{J})^theta_@{co}*N_@{co}^(1-theta_@{co}))^(-nu_@{co}) + sigma_@{co}*Z_@{co}(-1)^(-nu_@{co}))^(-1/nu_@{co}); |
| 45 |
K_@{co} = (1-delta_@{co})*K_@{co}(-1) + S_@{co}; |
| 46 |
X_@{co} = |
| 47 |
@# for lag in (-J+1):0 |
| 48 |
+ phi_@{co}*S_@{co}(@{lag}) |
| 49 |
@# endfor |
| 50 |
; |
| 51 |
|
| 52 |
A_@{co} = (1-eta_@{co})*A_@{co}(-1) + N_@{co}; |
| 53 |
L_@{co} = 1 - alpha_@{co}*N_@{co} - (1-alpha_@{co})*eta_@{co}*A_@{co}(-1); |
| 54 |
|
| 55 |
// Utility multiplied by gamma |
| 56 |
# U_@{co} = (C_@{co}^mu_@{co}*L_@{co}^(1-mu_@{co}))^gamma_@{co}; |
| 57 |
|
| 58 |
// FOC with respect to consumption |
| 59 |
psi_@{co}*mu_@{co}/C_@{co}*U_@{co} = LGM; |
| 60 |
|
| 61 |
// FOC with respect to labor |
| 62 |
// NOTE: this condition is only valid for alpha = 1 |
| 63 |
psi_@{co}*(1-mu_@{co})/L_@{co}*U_@{co}*(-alpha_@{co}) = - LGM * (1-theta_@{co})/N_@{co}*(LAMBDA_@{co}*K_@{co}(-@{J})^theta_@{co}*N_@{co}^(1-theta_@{co}))^(-nu_@{co})*Y_@{co}^(1+nu_@{co}); |
| 64 |
|
| 65 |
// FOC with respect to capital |
| 66 |
@# for lag in 0:(J-1) |
| 67 |
+beta_@{co}^@{lag}*LGM(+@{lag})*phi_@{co} |
| 68 |
@# endfor |
| 69 |
@# for lag in 1:J |
| 70 |
-beta_@{co}^@{lag}*LGM(+@{lag})*phi_@{co}*(1-delta_@{co}) |
| 71 |
@# endfor |
| 72 |
= beta_@{co}^@{J}*LGM(+@{J})*theta_@{co}/K_@{co}*(LAMBDA_@{co}(+@{J})*K_@{co}^theta_@{co}*N_@{co}(+@{J})^(1-theta_@{co}))^(-nu_@{co})*Y_@{co}(+@{J})^(1+nu_@{co}); |
| 73 |
|
| 74 |
// FOC with respect to stock of inventories |
| 75 |
LGM=beta_@{co}*LGM(+1)*(1+sigma_@{co}*Z_@{co}^(-nu_@{co}-1)*Y_@{co}(+1)^(1+nu_@{co})); |
| 76 |
|
| 77 |
// Shock process |
| 78 |
@# if co == countries[1] |
| 79 |
@# define alt_co = countries[2] |
| 80 |
@# else |
| 81 |
@# define alt_co = countries[1] |
| 82 |
@# endif |
| 83 |
(LAMBDA_@{co}-1) = rho_@{co}_@{co}*(LAMBDA_@{co}(-1)-1) + rho_@{co}_@{alt_co}*(LAMBDA_@{alt_co}(-1)-1) + E_@{co}; |
| 84 |
|
| 85 |
|
| 86 |
NX_@{co} = (Y_@{co} - (C_@{co} + X_@{co} + Z_@{co} - Z_@{co}(-1)))/Y_@{co}; |
| 87 |
|
| 88 |
@#endfor |
| 89 |
|
| 90 |
// World ressource constraint |
| 91 |
@#for co in countries |
| 92 |
+C_@{co} + X_@{co} + Z_@{co} - Z_@{co}(-1) |
| 93 |
@#endfor |
| 94 |
= |
| 95 |
@#for co in countries |
| 96 |
+Y_@{co} |
| 97 |
@#endfor |
| 98 |
; |
| 99 |
|
| 100 |
end; |
| 101 |
|
| 102 |
@#for co in countries |
| 103 |
beta_@{co} = 0.99; |
| 104 |
mu_@{co} = 0.34; |
| 105 |
gamma_@{co} = -1.0; |
| 106 |
alpha_@{co} = 1; |
| 107 |
eta_@{co} = 0.5; // Irrelevant when alpha=1 |
| 108 |
theta_@{co} = 0.36; |
| 109 |
nu_@{co} = 3; |
| 110 |
sigma_@{co} = 0.01; |
| 111 |
delta_@{co} = 0.025; |
| 112 |
phi_@{co} = 1/@{J}; |
| 113 |
psi_@{co} = 0.5; |
| 114 |
@#endfor |
| 115 |
|
| 116 |
rho_H_H = 0.906; |
| 117 |
rho_F_F = 0.906; |
| 118 |
rho_H_F = 0.088; |
| 119 |
rho_F_H = 0.088; |
| 120 |
|
| 121 |
initval; |
| 122 |
@#for co in countries |
| 123 |
LAMBDA_@{co} = 1; |
| 124 |
NX_@{co} = 0; |
| 125 |
Z_@{co} = 1; |
| 126 |
A_@{co} = 1; |
| 127 |
L_@{co} = 0.5; |
| 128 |
N_@{co} = 0.5; |
| 129 |
Y_@{co} = 1; |
| 130 |
K_@{co} = 1; |
| 131 |
C_@{co} = 1; |
| 132 |
S_@{co} = 1; |
| 133 |
X_@{co} = 1; |
| 134 |
|
| 135 |
E_@{co} = 0; |
| 136 |
@#endfor |
| 137 |
|
| 138 |
LGM = 1; |
| 139 |
end; |
| 140 |
|
| 141 |
shocks; |
| 142 |
var E_H; stderr 0.00852; |
| 143 |
var E_F; stderr 0.00852; |
| 144 |
corr E_H, E_F = 0.258; |
| 145 |
end; |
| 146 |
|
| 147 |
model_info; |
| 148 |
model_info(incidence,block_dynamic); |
| 149 |
model_info(incidence,block_static); |