Streamlined extended path examples.
parent
099bdc5450
commit
62b0106dde
|
@ -15,7 +15,7 @@ sigma = 0.0001;
|
|||
|
||||
external_function(name=mean_preserving_spread,nargs=2);
|
||||
|
||||
model;
|
||||
model(use_dll);
|
||||
|
||||
// Eq. n°1:
|
||||
efficiency = rho*efficiency(-1) + sigma*EfficiencyInnovation;
|
||||
|
@ -31,21 +31,14 @@ end;
|
|||
|
||||
steady;
|
||||
|
||||
options_.ep.verbosity = 0;
|
||||
options_.ep.stochastic.order = 0;
|
||||
options_.ep.stochastic.nodes = 0;
|
||||
options_.console_mode = 0;
|
||||
ts = extended_path([], 100, [], options_, M_, oo_);
|
||||
|
||||
ts = extended_path([], 10, options_, M_, oo_);
|
||||
|
||||
options_.ep.verbosity = 0;
|
||||
options_.ep.stochastic.order = 1;
|
||||
options_.ep.IntegrationAlgorithm='Tensor-Gaussian-Quadrature';
|
||||
options_.ep.stochastic.nodes = 3;
|
||||
options_.console_mode = 0;
|
||||
sts = extended_path([], 100, [], options_, M_, oo_);
|
||||
|
||||
sts = extended_path([], 10, [], options_, M_, oo_);
|
||||
|
||||
if max(max(abs(ts-sts)))>pi*options_.dynatol.x
|
||||
// The model is backward, we do not care about future uncertainty, extended path and stochastic extended path
|
||||
// should return the same results.
|
||||
if max(max(abs(ts.data-sts.data)))>pi*options_.dynatol.x
|
||||
disp('Stochastic Extended Path:: Something is wrong here (potential bug in extended_path.m)!!!')
|
||||
end
|
||||
|
|
|
@ -32,34 +32,51 @@ if beta*exp(theta*xbar+.5*theta^2*M_.Sigma_e/(1-rho)^2)>1-eps
|
|||
end
|
||||
|
||||
set_dynare_seed('default');
|
||||
stoch_simul(order=1,irf=0,periods=5000);
|
||||
stoch_simul(order=1,irf=0,periods=201);
|
||||
y_perturbation_1 = oo_.endo_simul(1,:)';
|
||||
|
||||
set_dynare_seed('default');
|
||||
stoch_simul(order=2,irf=0,periods=5000);
|
||||
stoch_simul(order=2,irf=0,periods=201);
|
||||
y_perturbation_2 = oo_.endo_simul(1,:)';
|
||||
|
||||
set_dynare_seed('default');
|
||||
stoch_simul(order=2,pruning,irf=0,periods=5000);
|
||||
stoch_simul(order=2,pruning,irf=0,periods=201);
|
||||
y_perturbation_2_pruning = oo_.endo_simul(1,:)';
|
||||
|
||||
options_.simul.maxit = 100;
|
||||
options_.ep.verbosity = 0;
|
||||
options_.ep.stochastic.order = 0;
|
||||
options_.ep.stochastic.nodes = 2;
|
||||
options_.console_mode = 0;
|
||||
|
||||
set_dynare_seed('default');
|
||||
ts = extended_path([], 5000, [], options_, M_, oo_);
|
||||
|
||||
options_.ep.stochastic.order = 2;
|
||||
options_.ep.IntegrationAlgorithm='Tensor-Gaussian-Quadrature';
|
||||
set_dynare_seed('default');
|
||||
ts1_4 = extended_path([], 5000, [], options_, M_, oo_);
|
||||
|
||||
set_dynare_seed('default');
|
||||
ytrue=exact_solution(M_,oo_, 800);
|
||||
|
||||
|
||||
set_dynare_seed('default');
|
||||
options_.ep.stochastic.order = 0;
|
||||
ts = extended_path([], 200, [], options_, M_, oo_);
|
||||
|
||||
set_dynare_seed('default');
|
||||
options_.ep.stochastic.order = 2;
|
||||
options_.ep.IntegrationAlgorithm='Stroud-Cubature-3';//'Unscented'; //'Tensor-Gaussian-Quadrature';
|
||||
options_.ep.stochastic.quadrature.nodes = 3;
|
||||
ts1_4 = extended_path([], 200, [], options_, M_, oo_);
|
||||
|
||||
set_dynare_seed('default');
|
||||
options_.ep.stochastic.order = 4;
|
||||
options_.ep.IntegrationAlgorithm='Stroud-Cubature-3';//'Unscented'; //'Tensor-Gaussian-Quadrature';
|
||||
options_.ep.stochastic.quadrature.nodes = 3;
|
||||
ts1_8 = extended_path([], 200, [], options_, M_, oo_);
|
||||
|
||||
set_dynare_seed('default');
|
||||
options_.ep.stochastic.order = 6;
|
||||
options_.ep.IntegrationAlgorithm='Stroud-Cubature-3';//'Unscented'; //'Tensor-Gaussian-Quadrature';
|
||||
options_.ep.stochastic.quadrature.nodes = 3;
|
||||
ts1_12 = extended_path([], 200, [], options_, M_, oo_);
|
||||
|
||||
set_dynare_seed('default');
|
||||
options_.ep.stochastic.order = 8;
|
||||
options_.ep.IntegrationAlgorithm='Stroud-Cubature-3';//'Unscented'; //'Tensor-Gaussian-Quadrature';
|
||||
options_.ep.stochastic.quadrature.nodes = 3;
|
||||
ts1_16 = extended_path([], 200, [], options_, M_, oo_);
|
||||
|
||||
disp('True mean and standard deviation')
|
||||
disp(mean(ytrue(101:end)))
|
||||
disp(sqrt(var(ytrue(101:end))))
|
||||
|
@ -77,12 +94,12 @@ disp(mean(y_perturbation_2_pruning(101:end)))
|
|||
disp(sqrt(var(y_perturbation_2_pruning(101:end))))
|
||||
|
||||
disp('Extended path mean and standard deviation')
|
||||
disp(mean(ts(1,101:end)))
|
||||
disp(sqrt(var(ts(1,101:end))))
|
||||
disp(mean(ts.data(101:end,1)))
|
||||
disp(sqrt(var(ts.data(101:end,1))))
|
||||
|
||||
disp('Stochastic extended path mean and standard deviation')
|
||||
disp(mean(ts1_4(1,101:end)))
|
||||
disp(sqrt(var(ts1_4(1,101:end))))
|
||||
disp(mean(ts1_4.data(101:end,1)))
|
||||
disp(sqrt(var(ts1_4.data(101:end,1))))
|
||||
|
||||
disp('Accuracy error (order 1 perturbation)')
|
||||
disp(mean(100*abs(y_perturbation_1-ytrue')./ytrue'));
|
||||
|
@ -97,9 +114,21 @@ disp(100*mean(abs(y_perturbation_2_pruning-ytrue')./ytrue'));
|
|||
disp(100*max(abs(y_perturbation_2_pruning-ytrue')./ytrue'));
|
||||
|
||||
disp('Accuracy error (extended path)')
|
||||
disp(mean(100*abs(ts(1,:)'-ytrue')./ytrue'));
|
||||
disp(max(100*abs(ts(1,:)'-ytrue')./ytrue'));
|
||||
disp(mean(100*abs(ts.data(:,1)-ytrue')./ytrue'));
|
||||
disp(max(100*abs(ts.data(:,1)-ytrue')./ytrue'));
|
||||
|
||||
disp('Accuracy error (stochastic extended path)')
|
||||
disp(mean(100*abs(ts1_4(1,:)'-ytrue')./ytrue'));
|
||||
disp(max(100*abs(ts1_4(1,:)'-ytrue')./ytrue'));
|
||||
disp('Accuracy error (stochastic extended path (order=2))')
|
||||
disp(mean(100*abs(ts1_4.data(:,1)-ytrue')./ytrue'));
|
||||
disp(max(100*abs(ts1_4.data(:,1)-ytrue')./ytrue'));
|
||||
|
||||
disp('Accuracy error (stochastic extended path (order=4))')
|
||||
disp(mean(100*abs(ts1_8.data(:,1)-ytrue')./ytrue'));
|
||||
disp(max(100*abs(ts1_8.data(:,1)-ytrue')./ytrue'));
|
||||
|
||||
disp('Accuracy error (stochastic extended path (order=6))')
|
||||
disp(mean(100*abs(ts1_12.data(:,1)-ytrue')./ytrue'));
|
||||
disp(max(100*abs(ts1_12.data(:,1)-ytrue')./ytrue'));
|
||||
|
||||
disp('Accuracy error (stochastic extended path (order=8))')
|
||||
disp(mean(100*abs(ts1_16.data(:,1)-ytrue')./ytrue'));
|
||||
disp(max(100*abs(ts1_16.data(:,1)-ytrue')./ytrue'));
|
||||
|
|
|
@ -31,11 +31,7 @@ stoch_simul(order=1,periods=200, irf=0, nomoments);
|
|||
oo = oo_;
|
||||
|
||||
options_.simul.maxit = 100;
|
||||
options_.ep.verbosity = 0;
|
||||
options_.ep.stochastic.status = 0;
|
||||
options_.ep.order = 0;
|
||||
options_.ep.nnodes = 0;
|
||||
options_.console_mode = 0;
|
||||
|
||||
ts = extended_path([], 200, oo_.exo_simul, options_, M_, oo_);
|
||||
|
||||
|
|
|
@ -26,22 +26,14 @@ end;
|
|||
|
||||
steady;
|
||||
|
||||
options_.simul.maxit = 100;
|
||||
options_.ep.verbosity = 0;
|
||||
options_.ep.stochastic.status = 0;
|
||||
options_.ep.order = 0;
|
||||
options_.ep.nnodes = 0;
|
||||
options_.console_mode = 0;
|
||||
|
||||
// Extended path simulation
|
||||
ts = extended_path([], 10, [], options_, M_, oo_);
|
||||
options_.ep.order = 0;
|
||||
ts = extended_path([], 100, [], options_, M_, oo_);
|
||||
|
||||
// Stochastic extended path simulation
|
||||
options_.ep.stochastic.status = 1;
|
||||
options_.ep.IntegrationAlgorithm='Tensor-Gaussian-Quadrature';
|
||||
options_.ep.order = 1;
|
||||
options_.ep.nnodes = 3;
|
||||
sts = extended_path([], 10, [], options_, M_, oo_);
|
||||
sts = extended_path([], 100, [], options_, M_, oo_);
|
||||
|
||||
// The generated paths should be identical (because the model is linear)
|
||||
if max(max(abs(ts.data-sts.data))) > 1e-12
|
||||
|
|
|
@ -76,6 +76,5 @@ end;
|
|||
|
||||
steady;
|
||||
|
||||
options_.ep.IntegrationAlgorithm='Tensor-Gaussian-Quadrature';
|
||||
extended_path(periods=10);
|
||||
|
||||
|
|
|
@ -66,20 +66,13 @@ copyfile('rbcii_steady_state.m','+rbcii/steadystate.m');
|
|||
|
||||
steady(nocheck);
|
||||
|
||||
options_.simul.maxit = 100;
|
||||
options_.ep.verbosity = 0;
|
||||
options_.ep.stochastic.order = 0;
|
||||
options_.ep.stochastic.nodes = 2;
|
||||
options_.console_mode = 0;
|
||||
|
||||
ts = extended_path([], 20, [], options_, M_, oo_);
|
||||
|
||||
options_.ep.stochastic.order = 1;
|
||||
options_.ep.IntegrationAlgorithm='Tensor-Gaussian-Quadrature';
|
||||
// profile on
|
||||
ts1_4 = extended_path([], 20, [], options_, M_, oo_);
|
||||
// profile off
|
||||
// profile viewer
|
||||
|
||||
@#else
|
||||
|
||||
shocks;
|
||||
|
|
|
@ -50,7 +50,7 @@ parameters theta xi beta phi alpha eta KBar chi0 LMax chi IBar rhoinflavg taylrh
|
|||
VAIMSS = 1;
|
||||
consoldelta = 1;
|
||||
|
||||
model;//(use_dll);
|
||||
model(use_dll);
|
||||
// Value function and Euler equation
|
||||
V = exp(lC)^(1-phi) /(1-phi) + chi0 *(LMax-exp(lL))^(1-chi) /(1-chi) + beta *Vkp;
|
||||
Int1 = Int/10;
|
||||
|
@ -152,12 +152,5 @@ end;
|
|||
|
||||
//stoch_simul(order=3,periods=50000,pruning);
|
||||
|
||||
options_.ep.verbosity=0;
|
||||
options_.ep.stochastic.algo=1;
|
||||
options_.ep.solve_algo = 10;
|
||||
options_.ep.maxit = 100;
|
||||
options_.ep.IntegrationAlgorithm='UT_2p+1';
|
||||
options_.ep.ut.k = 1;
|
||||
options_.solve_tolf = 1e-12;
|
||||
|
||||
extended_path(order=1,periods=3);
|
||||
extended_path(order=0,periods=3);
|
Loading…
Reference in New Issue