Fix extended_path with bytecode
By the way, document and enforce the fact that stochastic extended_path (i.e. order > 0) is not compatible with either bytecode or block. Closes: #1742time-shift
parent
43311a230f
commit
71e3e0d49e
|
@ -4240,7 +4240,9 @@ which is described below.
|
|||
the endogenous variables are generated by assuming that the
|
||||
agents believe that there will no more shocks after period
|
||||
:math:`t+S`. This is an experimental feature and can be quite
|
||||
slow. Default: ``0``.
|
||||
slow. A non-zero value is not compatible with either the
|
||||
``bytecode`` or the ``block`` option of the ``model`` block.
|
||||
Default: ``0``.
|
||||
|
||||
.. option:: hybrid
|
||||
|
||||
|
|
|
@ -40,46 +40,39 @@ if debug
|
|||
save ep_test_1.mat endo_simul exo_simul
|
||||
end
|
||||
|
||||
if bytecode_flag && ~ep.stochastic.order
|
||||
try
|
||||
tmp = bytecode('dynamic', endo_simul, exo_simul, M.params, endo_simul, periods);
|
||||
flag = false;
|
||||
catch ME
|
||||
disp(ME.message);
|
||||
flag = true;
|
||||
end
|
||||
else
|
||||
flag = true;
|
||||
if bytecode_flag && order > 0
|
||||
error('Option order > 0 of extended_path command is not compatible with bytecode option.')
|
||||
end
|
||||
if options.block && order > 0
|
||||
error('Option order > 0 of extended_path command is not compatible with block option.')
|
||||
end
|
||||
|
||||
if flag
|
||||
if order == 0
|
||||
options.periods = periods;
|
||||
options.block = pfm.block;
|
||||
oo.endo_simul = endo_simul;
|
||||
oo.exo_simul = exo_simul;
|
||||
oo.steady_state = steady_state;
|
||||
options.bytecode = bytecode_flag;
|
||||
options.lmmcp = olmmcp;
|
||||
options.solve_algo = solve_algo;
|
||||
options.stack_solve_algo = stack_solve_algo;
|
||||
tmp = perfect_foresight_solver_core(M, options, oo);
|
||||
if ~tmp.deterministic_simulation.status
|
||||
info_convergence = false;
|
||||
else
|
||||
info_convergence = true;
|
||||
end
|
||||
if order == 0
|
||||
options.periods = periods;
|
||||
options.block = pfm.block;
|
||||
oo.endo_simul = endo_simul;
|
||||
oo.exo_simul = exo_simul;
|
||||
oo.steady_state = steady_state;
|
||||
options.bytecode = bytecode_flag;
|
||||
options.lmmcp = olmmcp;
|
||||
options.solve_algo = solve_algo;
|
||||
options.stack_solve_algo = stack_solve_algo;
|
||||
tmp = perfect_foresight_solver_core(M, options, oo);
|
||||
if ~tmp.deterministic_simulation.status
|
||||
info_convergence = false;
|
||||
else
|
||||
switch(algo)
|
||||
case 0
|
||||
[flag, tmp.endo_simul] = ...
|
||||
solve_stochastic_perfect_foresight_model(endo_simul, exo_simul, pfm, ep.stochastic.quadrature.nodes, ep.stochastic.order);
|
||||
case 1
|
||||
[flag, tmp.endo_simul] = ...
|
||||
solve_stochastic_perfect_foresight_model_1(endo_simul, exo_simul, options, pfm, ep.stochastic.order);
|
||||
end
|
||||
info_convergence = ~flag;
|
||||
info_convergence = true;
|
||||
end
|
||||
else
|
||||
switch(algo)
|
||||
case 0
|
||||
[flag, tmp.endo_simul] = ...
|
||||
solve_stochastic_perfect_foresight_model(endo_simul, exo_simul, pfm, ep.stochastic.quadrature.nodes, ep.stochastic.order);
|
||||
case 1
|
||||
[flag, tmp.endo_simul] = ...
|
||||
solve_stochastic_perfect_foresight_model_1(endo_simul, exo_simul, options, pfm, ep.stochastic.order);
|
||||
end
|
||||
info_convergence = ~flag;
|
||||
end
|
||||
|
||||
if ~info_convergence && ~options.no_homotopy
|
||||
|
|
|
@ -289,6 +289,7 @@ MODFILES = \
|
|||
ep/rbcii.mod \
|
||||
ep/linearmodel0.mod \
|
||||
ep/linearmodel1.mod \
|
||||
ep/rbc_bytecode.mod \
|
||||
stochastic_simulations/example1_noprint.mod \
|
||||
stochastic-backward-models/solow_cd.mod \
|
||||
stochastic-backward-models/solow_ces.mod \
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
// Test extended_path + bytecode (regression check for #1742)
|
||||
|
||||
var Capital, Output, Labour, Consumption, Efficiency, efficiency, ExpectedTerm;
|
||||
|
||||
varexo EfficiencyInnovation;
|
||||
|
||||
parameters beta, theta, tau, alpha, psi, delta, rho, effstar, sigma;
|
||||
|
||||
/*
|
||||
** Calibration
|
||||
*/
|
||||
|
||||
|
||||
beta = 0.990;
|
||||
theta = 0.357;
|
||||
tau = 30.000;
|
||||
alpha = 0.450;
|
||||
psi = -5.000;
|
||||
delta = 0.020;
|
||||
rho = 0.950;
|
||||
effstar = 1.000;
|
||||
sigma = 0.010;
|
||||
|
||||
model(bytecode);
|
||||
|
||||
// Eq. n°1:
|
||||
efficiency = rho*efficiency(-1) + sigma*EfficiencyInnovation;
|
||||
|
||||
// Eq. n°2:
|
||||
Efficiency = effstar*exp(efficiency-.5*sigma*sigma/(1-rho*rho));
|
||||
|
||||
// Eq. n°3:
|
||||
Output = Efficiency*(alpha*(Capital(-1)^psi)+(1-alpha)*(Labour^psi))^(1/psi);
|
||||
|
||||
// Eq. n°4:
|
||||
Consumption + Capital - Output - (1-delta)*Capital(-1);
|
||||
|
||||
// Eq. n°5:
|
||||
((1-theta)/theta)*(Consumption/(1-Labour)) - (1-alpha)*(Output/Labour)^(1-psi);
|
||||
|
||||
// Eq. n°6:
|
||||
(((Consumption^theta)*((1-Labour)^(1-theta)))^(1-tau))/Consumption - ExpectedTerm(1);
|
||||
|
||||
// Eq. n°7:
|
||||
ExpectedTerm = beta*((((Consumption^theta)*((1-Labour)^(1-theta)))^(1-tau))/Consumption)*(alpha*((Output/Capital(-1))^(1-psi))+1-delta);
|
||||
|
||||
end;
|
||||
|
||||
steady_state_model;
|
||||
efficiency = 0;
|
||||
Efficiency = effstar;
|
||||
// Compute steady state ratios.
|
||||
Output_per_unit_of_Capital=((1/beta-1+delta)/alpha)^(1/(1-psi));
|
||||
Consumption_per_unit_of_Capital=Output_per_unit_of_Capital-delta;
|
||||
Labour_per_unit_of_Capital=(((Output_per_unit_of_Capital/Efficiency)^psi-alpha)/(1-alpha))^(1/psi);
|
||||
Output_per_unit_of_Labour=Output_per_unit_of_Capital/Labour_per_unit_of_Capital;
|
||||
Consumption_per_unit_of_Labour=Consumption_per_unit_of_Capital/Labour_per_unit_of_Capital;
|
||||
|
||||
// Compute steady state share of capital.
|
||||
ShareOfCapital=alpha/(alpha+(1-alpha)*Labour_per_unit_of_Capital^psi);
|
||||
|
||||
/// Compute steady state of the endogenous variables.
|
||||
Labour=1/(1+Consumption_per_unit_of_Labour/((1-alpha)*theta/(1-theta)*Output_per_unit_of_Labour^(1-psi)));
|
||||
Consumption = Consumption_per_unit_of_Labour*Labour;
|
||||
Capital = Labour/Labour_per_unit_of_Capital;
|
||||
Output = Output_per_unit_of_Capital*Capital;
|
||||
ExpectedTerm = beta*((((Consumption^theta)*((1-Labour)^(1-theta)))^(1-tau))/Consumption)*(alpha*((Output/Capital)^(1-psi))+1-delta);
|
||||
end;
|
||||
|
||||
|
||||
shocks;
|
||||
var EfficiencyInnovation = 1;
|
||||
end;
|
||||
|
||||
steady(nocheck);
|
||||
|
||||
extended_path(periods=10, order=0);
|
Loading…
Reference in New Issue