| 1 |
var Capital, Output, Labour, Consumption, Efficiency, efficiency, ExpectedTerm; |
| 2 |
|
| 3 |
varexo EfficiencyInnovation; |
| 4 |
|
| 5 |
parameters beta, theta, tau, alpha, psi, delta, rho, effstar, sigma2; |
| 6 |
|
| 7 |
beta = 0.9900; |
| 8 |
theta = 0.3570; |
| 9 |
tau = 2.0000; |
| 10 |
alpha = 0.4500; |
| 11 |
psi = -0.1000; |
| 12 |
delta = 0.0200; |
| 13 |
rho = 0.8000; |
| 14 |
effstar = 1.0000; |
| 15 |
sigma2 = 0; |
| 16 |
|
| 17 |
model; |
| 18 |
|
| 19 |
// Eq. n°1: |
| 20 |
efficiency = rho*efficiency(-1) + EfficiencyInnovation; |
| 21 |
|
| 22 |
// Eq. n°2: |
| 23 |
Efficiency = effstar*exp(efficiency); |
| 24 |
|
| 25 |
// Eq. n°3: |
| 26 |
Output = Efficiency*(alpha*(Capital(-1)^psi)+(1-alpha)*(Labour^psi))^(1/psi); |
| 27 |
|
| 28 |
// Eq. n°4: |
| 29 |
Capital = Output-Consumption + (1-delta)*Capital(-1); |
| 30 |
|
| 31 |
// Eq. n°5: |
| 32 |
((1-theta)/theta)*(Consumption/(1-Labour)) - (1-alpha)*(Output/Labour)^(1-psi); |
| 33 |
|
| 34 |
// Eq. n°6: |
| 35 |
(((Consumption^theta)*((1-Labour)^(1-theta)))^(1-tau))/Consumption = ExpectedTerm(1); |
| 36 |
|
| 37 |
// Eq. n°7: |
| 38 |
ExpectedTerm = beta*((((Consumption^theta)*((1-Labour)^(1-theta)))^(1-tau))/Consumption)*(alpha*((Output/Capital(-1))^(1-psi))+(1-delta)); |
| 39 |
|
| 40 |
end; |
| 41 |
|
| 42 |
steady_state_model; |
| 43 |
efficiency = EfficiencyInnovation/(1-rho); |
| 44 |
Efficiency = effstar*exp(efficiency); |
| 45 |
Output_per_unit_of_Capital=((1/beta-1+delta)/alpha)^(1/(1-psi)); |
| 46 |
Consumption_per_unit_of_Capital=Output_per_unit_of_Capital-delta; |
| 47 |
Labour_per_unit_of_Capital=(((Output_per_unit_of_Capital/Efficiency)^psi-alpha)/(1-alpha))^(1/psi); |
| 48 |
Output_per_unit_of_Labour=Output_per_unit_of_Capital/Labour_per_unit_of_Capital; |
| 49 |
Consumption_per_unit_of_Labour=Consumption_per_unit_of_Capital/Labour_per_unit_of_Capital; |
| 50 |
|
| 51 |
% Compute steady state share of capital. |
| 52 |
ShareOfCapital=alpha/(alpha+(1-alpha)*Labour_per_unit_of_Capital^psi); |
| 53 |
|
| 54 |
% Compute steady state of the endogenous variables. |
| 55 |
Labour=1/(1+Consumption_per_unit_of_Labour/((1-alpha)*theta/(1-theta)*Output_per_unit_of_Labour^(1-psi))); |
| 56 |
Consumption=Consumption_per_unit_of_Labour*Labour; |
| 57 |
Capital=Labour/Labour_per_unit_of_Capital; |
| 58 |
Output=Output_per_unit_of_Capital*Capital; |
| 59 |
ExpectedTerm=beta*((((Consumption^theta)*((1-Labour)^(1-theta)))^(1-tau))/Consumption) |
| 60 |
*(alpha*((Output/Capital)^(1-psi))+1-delta); |
| 61 |
end; |
| 62 |
|
| 63 |
steady; |
| 64 |
|
| 65 |
ik = varlist_indices('Capital',M_.endo_names); |
| 66 |
CapitalSS = oo_.steady_state(ik); |
| 67 |
|
| 68 |
histval; |
| 69 |
Capital(0) = CapitalSS/2; |
| 70 |
end; |
| 71 |
|
| 72 |
|
| 73 |
perfect_foresight_setup(periods=200); |
| 74 |
|
| 75 |
perfect_foresight_solver(stack_solve_algo=7,solve_algo=1); |
| 76 |
|
| 77 |
if ~oo_.deterministic_simulation.status |
| 78 |
error('Perfect foresight simulation failed') |
| 79 |
end |
| 80 |
|
| 81 |
rplot Consumption; |
| 82 |
rplot Capital; |
| 83 |
|
| 84 |
D = load(['rbc_det' filesep 'Output' filesep 'rbc_det_results']); |
| 85 |
|
| 86 |
if norm(D.oo_.endo_simul - oo_.endo_simul) > 1e-30; |
| 87 |
disp(norm(D.oo_.endo_simul - oo_.endo_simul)); |
| 88 |
error('rbc_det_stack_solve_algo_7 failed'); |
| 89 |
end; |
| 90 |
|
| 91 |
options_.dynatol.f=1e-10; |
| 92 |
@#define J = [0,1,2,3,4,9,10] |
| 93 |
@#for solve_algo_iter in J |
| 94 |
|
| 95 |
perfect_foresight_setup(periods=200); |
| 96 |
perfect_foresight_solver(stack_solve_algo=7,solve_algo=@{solve_algo_iter}); |
| 97 |
|
| 98 |
if ~oo_.deterministic_simulation.status |
| 99 |
error('Perfect foresight simulation failed') |
| 100 |
end |
| 101 |
|
| 102 |
rplot Consumption; |
| 103 |
rplot Capital; |
| 104 |
|
| 105 |
D = load(['rbc_det' filesep 'Output' filesep 'rbc_det_results']); |
| 106 |
if isoctave && options_.solve_algo==0 |
| 107 |
%%acount for somehow weaker convergence criterion in Octave's fsolve |
| 108 |
tol_crit=1e-4; |
| 109 |
else |
| 110 |
tol_crit=1e-8; |
| 111 |
end |
| 112 |
if norm(D.oo_.endo_simul - oo_.endo_simul) > tol_crit; |
| 113 |
disp(norm(D.oo_.endo_simul - oo_.endo_simul)); |
| 114 |
error(sprintf('rbc_det_stack_solve_algo_7 failed with solve_algo=%u',options_.solve_algo)); |
| 115 |
end; |
| 116 |
@#endfor |