Merge remote-tracking branch 'local_master/master' into dr1break
commit
403ffdf8b1
|
@ -79,7 +79,7 @@ make_ex_;
|
||||||
make_y_;
|
make_y_;
|
||||||
|
|
||||||
% Initialize the output array.
|
% Initialize the output array.
|
||||||
time_series = NaN(M_.endo_nbr,sample_size+1);
|
time_series = zeros(M_.endo_nbr,sample_size);
|
||||||
|
|
||||||
% Set the covariance matrix of the structural innovations.
|
% Set the covariance matrix of the structural innovations.
|
||||||
variances = diag(M_.Sigma_e);
|
variances = diag(M_.Sigma_e);
|
||||||
|
@ -106,6 +106,7 @@ if options_.ep.stochastic
|
||||||
[r,w] = gauss_hermite_weights_and_nodes(options_.ep.number_of_nodes);
|
[r,w] = gauss_hermite_weights_and_nodes(options_.ep.number_of_nodes);
|
||||||
switch options_.ep.stochastic
|
switch options_.ep.stochastic
|
||||||
case 1
|
case 1
|
||||||
|
if M_.exo_nbr>1
|
||||||
rr = cell(1);
|
rr = cell(1);
|
||||||
ww = cell(1);
|
ww = cell(1);
|
||||||
for i=1:size(M_.Sigma_e,1)
|
for i=1:size(M_.Sigma_e,1)
|
||||||
|
@ -114,10 +115,19 @@ if options_.ep.stochastic
|
||||||
end
|
end
|
||||||
rrr = cartesian_product_of_sets(rr{:});
|
rrr = cartesian_product_of_sets(rr{:});
|
||||||
www = cartesian_product_of_sets(ww{:});
|
www = cartesian_product_of_sets(ww{:});
|
||||||
|
else
|
||||||
|
rrr = r;
|
||||||
|
www = w;
|
||||||
|
end
|
||||||
www = prod(www,2);
|
www = prod(www,2);
|
||||||
|
nnn = length(www);
|
||||||
otherwise
|
otherwise
|
||||||
error(['Order ' int2str(options_.ep.stochastic) ' Stochastic Extended Path method is not implemented!'])
|
error(['Order ' int2str(options_.ep.stochastic) ' Stochastic Extended Path method is not implemented!'])
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
rrr = zeros(1,number_of_structural_innovations);
|
||||||
|
www = 1;
|
||||||
|
nnn = 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
% Initializes some variables.
|
% Initializes some variables.
|
||||||
|
@ -158,7 +168,9 @@ while (t<sample_size)
|
||||||
shocks = oo_.ep.shocks(t,:);
|
shocks = oo_.ep.shocks(t,:);
|
||||||
% Put it in oo_.exo_simul (second line).
|
% Put it in oo_.exo_simul (second line).
|
||||||
oo_.exo_simul(2,positive_var_indx) = shocks;
|
oo_.exo_simul(2,positive_var_indx) = shocks;
|
||||||
if options_.ep.init && t==1% Compute first order solution.
|
for s = 1:nnn
|
||||||
|
oo_.exo_simul(3,positive_var_indx) = rrr(s,:)*covariance_matrix_upper_cholesky;
|
||||||
|
if options_.ep.init && s==1% Compute first order solution. t==1 &&
|
||||||
initial_path = simult_(initial_conditions,oo_.dr,oo_.exo_simul(2:end,:),1);
|
initial_path = simult_(initial_conditions,oo_.dr,oo_.exo_simul(2:end,:),1);
|
||||||
if options_.ep.init==1
|
if options_.ep.init==1
|
||||||
oo_.endo_simul(:,1:end-1) = initial_path(:,1:end-1);% Last column is the steady state.
|
oo_.endo_simul(:,1:end-1) = initial_path(:,1:end-1);% Last column is the steady state.
|
||||||
|
@ -278,20 +290,15 @@ while (t<sample_size)
|
||||||
else
|
else
|
||||||
oo_.endo_simul = tmp;
|
oo_.endo_simul = tmp;
|
||||||
end
|
end
|
||||||
if nargin==6
|
|
||||||
zlb_periods = find(oo_.endo_simul(zlb_idx,:)<=1+1e-12);
|
|
||||||
zlb_number_of_periods = length(zlb_periods);
|
|
||||||
if zlb_number_of_periods
|
|
||||||
count_zlb = [count_zlb ; [t, zlb_number_of_periods, zlb_periods(1) , zlb_periods(end)] ];
|
|
||||||
end
|
|
||||||
end
|
|
||||||
% Save results of the perfect foresight model solver.
|
% Save results of the perfect foresight model solver.
|
||||||
time_series(:,t) = oo_.endo_simul(:,2);
|
time_series(:,t) = time_series(:,t)+ www(s)*oo_.endo_simul(:,2);
|
||||||
save('simulated_paths.mat','time_series');
|
%save('simulated_paths.mat','time_series');
|
||||||
% Set initial condition for the nex round.
|
% Set initial condition for the nex round.
|
||||||
%initial_conditions = oo_.endo_simul(:,2);
|
%initial_conditions = oo_.endo_simul(:,2);
|
||||||
oo_.endo_simul = oo_.endo_simul(:,1:options_.periods+2);
|
end
|
||||||
|
%oo_.endo_simul = oo_.endo_simul(:,1:options_.periods+M_.maximum_endo_lag+M_.maximum_endo_lead);
|
||||||
oo_.endo_simul(:,1:end-1) = oo_.endo_simul(:,2:end);
|
oo_.endo_simul(:,1:end-1) = oo_.endo_simul(:,2:end);
|
||||||
|
oo_.endo_simul(:,1) = time_series(:,t);
|
||||||
oo_.endo_simul(:,end) = oo_.steady_state;
|
oo_.endo_simul(:,end) = oo_.steady_state;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -302,3 +309,5 @@ else
|
||||||
fprintf(back);
|
fprintf(back);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
oo_.endo_simul = oo_.steady_state;
|
|
@ -106,3 +106,18 @@ nodes = sqrt(2)*nodes;
|
||||||
%$ t(3) = dyn_assert(zeros(1,2),expectation,1e-12);
|
%$ t(3) = dyn_assert(zeros(1,2),expectation,1e-12);
|
||||||
%$ T = all(t);
|
%$ T = all(t);
|
||||||
%@eof:3
|
%@eof:3
|
||||||
|
|
||||||
|
%@test:4
|
||||||
|
%$ n = 9; sigma = .1;
|
||||||
|
%$ [nodes,weights] = gauss_hermite_weights_and_nodes(n);
|
||||||
|
%$
|
||||||
|
%$ sum_of_weights = sum(weights);
|
||||||
|
%$ expectation = sum(weights.*nodes*.1);
|
||||||
|
%$ variance = sum(weights.*((nodes*.1).^2));
|
||||||
|
%$
|
||||||
|
%$ % Check the results.
|
||||||
|
%$ t(1) = dyn_assert(1.0,sum_of_weights,1e-12);
|
||||||
|
%$ t(2) = dyn_assert(.01,variance,1e-12);
|
||||||
|
%$ t(3) = dyn_assert(0.0,expectation,1e-12);
|
||||||
|
%$ T = all(t);
|
||||||
|
%@eof:4
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
var Efficiency, efficiency;
|
||||||
|
|
||||||
|
varexo EfficiencyInnovation;
|
||||||
|
|
||||||
|
parameters rho, effstar, sigma2;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Calibration
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
rho = 0.950;
|
||||||
|
effstar = 1.000;
|
||||||
|
sigma2 = 0.0001;
|
||||||
|
|
||||||
|
external_function(name=mean_preserving_spread);
|
||||||
|
|
||||||
|
model(block,bytecode);
|
||||||
|
|
||||||
|
// Eq. n°1:
|
||||||
|
efficiency = rho*efficiency(-1) + EfficiencyInnovation;
|
||||||
|
|
||||||
|
// Eq. n°2:
|
||||||
|
Efficiency = effstar*exp(efficiency-mean_preserving_spread(rho));
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
shocks;
|
||||||
|
var EfficiencyInnovation = sigma2;
|
||||||
|
end;
|
||||||
|
|
||||||
|
steady;
|
||||||
|
|
||||||
|
options_.ep.verbosity = 0;
|
||||||
|
options_.ep.stochastic = 0;
|
||||||
|
options_.console_mode = 0;
|
||||||
|
|
||||||
|
|
||||||
|
ts = extended_path([],1000);
|
||||||
|
|
||||||
|
|
||||||
|
options_.ep.verbosity = 0;
|
||||||
|
options_.ep.stochastic = 1;
|
||||||
|
options_.console_mode = 0;
|
||||||
|
|
||||||
|
sts = extended_path([],1000);
|
||||||
|
|
||||||
|
|
||||||
|
if max(max(abs(ts-sts)))>1e-12
|
||||||
|
disp('Stochastic Extended Path:: Something is wrong here (potential bug in extended_path.m)!!!')
|
||||||
|
end
|
|
@ -0,0 +1,9 @@
|
||||||
|
function [ys, info] = ar_steadystate(ys, exogenous)
|
||||||
|
% Steady state routine for ar.mod (First order autoregressive process)
|
||||||
|
|
||||||
|
global M_
|
||||||
|
|
||||||
|
info = 0;
|
||||||
|
|
||||||
|
ys(1)=M_.params(2);
|
||||||
|
ys(2)=0;
|
Loading…
Reference in New Issue