| 1 |
@#define NumberOfCountries = 2 |
| 2 |
|
| 3 |
var log_kappa; |
| 4 |
@#for Country in 1:NumberOfCountries |
| 5 |
var mu@{Country}, logit_l@{Country}, k@{Country}, a@{Country}; |
| 6 |
@#endfor |
| 7 |
|
| 8 |
parameters alpha beta varrho delta theta rhoA sigmaA; |
| 9 |
|
| 10 |
alpha = 0.3; |
| 11 |
beta = 0.99; |
| 12 |
varrho = 1.5; |
| 13 |
delta = 0.025; |
| 14 |
theta = 0.9; |
| 15 |
rhoA = 0.95; |
| 16 |
sigmaA = 0.05; |
| 17 |
|
| 18 |
@#for Country in 1:NumberOfCountries |
| 19 |
varexo epsilonA@{Country}; |
| 20 |
@#endfor |
| 21 |
|
| 22 |
model; |
| 23 |
|
| 24 |
#kappa = exp( log_kappa ); |
| 25 |
#LEAD_kappa = exp( log_kappa(+1) ); |
| 26 |
|
| 27 |
#min_A = theta ^ ( 1/alpha ); |
| 28 |
#mean_a = log( 1 - min_A ); |
| 29 |
|
| 30 |
@#for Country in 1:NumberOfCountries |
| 31 |
|
| 32 |
#K@{Country} = exp( k@{Country} ); |
| 33 |
#LAG_K@{Country} = exp( k@{Country}(-1) ); |
| 34 |
#LEAD_A@{Country} = min_A + exp( a@{Country}(+1) ); |
| 35 |
#A@{Country} = min_A + exp( a@{Country} ); |
| 36 |
#LAG_A@{Country} = min_A + exp( a@{Country}(-1) ); |
| 37 |
#L@{Country} = 1 / ( 1 + exp( -logit_l@{Country} ) ); |
| 38 |
#LEAD_L@{Country} = 1 / ( 1 + exp( -logit_l@{Country}(+1) ) ); |
| 39 |
|
| 40 |
#C@{Country} = kappa ^ ( -1/varrho ) - theta / ( 1-alpha ) * ( A@{Country}*(1-L@{Country}) ) ^ ( 1-alpha ); |
| 41 |
#LEAD_phi@{Country} = ( 1 - theta * ( LEAD_A@{Country}*(1-LEAD_L@{Country}) ) ^ ( -alpha ) ) * LEAD_kappa; |
| 42 |
#I@{Country} = K@{Country} - ( 1-delta ) * LAG_K@{Country}; |
| 43 |
|
| 44 |
@#endfor |
| 45 |
|
| 46 |
@#for Country in 1:NumberOfCountries |
| 47 |
|
| 48 |
( a@{Country} - mean_a ) = rhoA * ( a@{Country}(-1) - mean_a ) - sigmaA * epsilonA@{Country}; |
| 49 |
L@{Country} = min( LAG_K@{Country} / A@{Country}, 1 - theta ^ ( 1/alpha ) / A@{Country} ); |
| 50 |
kappa - mu@{Country} = beta * ( ( 1-delta ) * ( LEAD_kappa - mu@{Country}(+1) ) + LEAD_phi@{Country} ); |
| 51 |
kappa = max( beta * ( ( 1-delta ) * ( LEAD_kappa - mu@{Country}(+1) ) + LEAD_phi@{Country} ), ( theta / ( 1-alpha ) * ( A@{Country}*(1-L@{Country}) ) ^ ( 1-alpha ) |
| 52 |
@#for OtherCountry in 1:NumberOfCountries |
| 53 |
+ A@{OtherCountry} * L@{OtherCountry} |
| 54 |
@#if OtherCountry != Country |
| 55 |
- C@{OtherCountry} - I@{OtherCountry} |
| 56 |
@#endif |
| 57 |
@#endfor |
| 58 |
) ^ ( -varrho ) ); |
| 59 |
|
| 60 |
@#endfor |
| 61 |
|
| 62 |
0 = 0 |
| 63 |
@#for OtherCountry in 1:NumberOfCountries |
| 64 |
+ A@{OtherCountry} * L@{OtherCountry} |
| 65 |
- C@{OtherCountry} - I@{OtherCountry} |
| 66 |
@#endfor |
| 67 |
; |
| 68 |
|
| 69 |
end; |
| 70 |
|
| 71 |
steady_state_model; |
| 72 |
|
| 73 |
a = log( 1 - theta ^ ( 1/alpha ) ); |
| 74 |
mu = 0; |
| 75 |
L = 1 - ( 1/theta * ( 2 - 1/beta - delta ) ) ^ ( -1/alpha ); |
| 76 |
K = L; |
| 77 |
I = delta * K; |
| 78 |
C = ( 1 - delta ) * L; |
| 79 |
|
| 80 |
kappa_ = ( C + theta / ( 1-alpha ) * ( 1-L ) ^ ( 1-alpha ) ) ^ ( -varrho ); |
| 81 |
|
| 82 |
log_kappa = log( kappa_ ); |
| 83 |
|
| 84 |
@#for Country in 1:NumberOfCountries |
| 85 |
|
| 86 |
mu@{Country} = mu; |
| 87 |
logit_l@{Country} = log( L / ( 1 - L ) ); |
| 88 |
k@{Country} = log( K ); |
| 89 |
a@{Country} = a; |
| 90 |
|
| 91 |
@#endfor |
| 92 |
|
| 93 |
end; |
| 94 |
|
| 95 |
steady; |
| 96 |
check; |
| 97 |
|
| 98 |
shocks; |
| 99 |
|
| 100 |
var epsilonA1; periods 1; values 2; |
| 101 |
@#for Country in 2:NumberOfCountries |
| 102 |
var epsilonA@{Country}; periods 1; values 0; |
| 103 |
@#endfor |
| 104 |
|
| 105 |
end; |
| 106 |
options_.debug=true; |
| 107 |
perfect_foresight_setup(periods=400); |
| 108 |
perfect_foresight_solver(robust_lin_solve); |
| 109 |
|
| 110 |
if ~oo_.deterministic_simulation.status |
| 111 |
error('Model did not solve') |
| 112 |
else |
| 113 |
% store results |
| 114 |
endo_simul=oo_.endo_simul; |
| 115 |
save endo_simul endo_simul |
| 116 |
end |
| 117 |
|
| 118 |
perfect_foresight_setup(periods=400); |
| 119 |
perfect_foresight_solver(robust_lin_solve,allow_nonfinite_values); |