parent
ea8162c11f
commit
a2061b6f4e
|
@ -1,9 +1,9 @@
|
||||||
function y_=simult(ys, dr)
|
function y_=simult(y0, dr)
|
||||||
% function y_=simult(ys, dr)
|
% function y_=simult(y0, dr)
|
||||||
% Recursive Monte Carlo simulations
|
% Recursive Monte Carlo simulations
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
% ys: vector of variables in steady state
|
% y0: vector of variables in initial period of the simulation
|
||||||
% dr: structure of decisions rules for stochastic simulations
|
% dr: structure of decisions rules for stochastic simulations
|
||||||
%
|
%
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
|
@ -54,7 +54,7 @@ for i=1:replic
|
||||||
if ~isempty(M_.Sigma_e)
|
if ~isempty(M_.Sigma_e)
|
||||||
oo_.exo_simul(:,i_exo_var) = randn(options_.periods,nxs)*chol_S;
|
oo_.exo_simul(:,i_exo_var) = randn(options_.periods,nxs)*chol_S;
|
||||||
end
|
end
|
||||||
y_ = simult_(ys,dr,oo_.exo_simul,order);
|
y_ = simult_(y0,dr,oo_.exo_simul,order);
|
||||||
% elimninating initial value
|
% elimninating initial value
|
||||||
y_ = y_(:,2:end);
|
y_ = y_(:,2:end);
|
||||||
if replic > 1
|
if replic > 1
|
||||||
|
|
|
@ -130,7 +130,15 @@ if options_.periods > 0 && ~PI_PCL_solver
|
||||||
options_ =options_old;
|
options_ =options_old;
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
oo_.endo_simul = simult(oo_.dr.ys,oo_.dr);
|
% Note that the first column of oo_.endo_simul is preserved by the following
|
||||||
|
% call to simult; this is important because stoch_simul can be followed by
|
||||||
|
% forecast (see ticket #157)
|
||||||
|
if size(oo_.endo_simul,2) == 0
|
||||||
|
y0 = oo_.dr.ys;
|
||||||
|
else
|
||||||
|
y0 = oo_.endo_simul(:,1);
|
||||||
|
end
|
||||||
|
oo_.endo_simul = simult(y0,oo_.dr);
|
||||||
dyn2vec;
|
dyn2vec;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,12 @@ elseif options_.periods ~= 0
|
||||||
options_ =options_old;
|
options_ =options_old;
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
oo_.endo_simul = simult(repmat(oo_.dr.ys,1,M_.maximum_lag),oo_.dr);
|
if size(oo_.endo_simul,2) < maximum_lag
|
||||||
|
y0 = oo_.dr.ys;
|
||||||
|
else
|
||||||
|
y0 = oo_.endo_simul(:,1);
|
||||||
|
end
|
||||||
|
oo_.endo_simul = simult(y0,oo_.dr);
|
||||||
dyn2vec;
|
dyn2vec;
|
||||||
if options_.nomoments == 0
|
if options_.nomoments == 0
|
||||||
disp_moments(oo_.endo_simul,var_list);
|
disp_moments(oo_.endo_simul,var_list);
|
||||||
|
|
|
@ -135,15 +135,6 @@ StochSimulStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||||
cerr << "ERROR: in 'stoch_simul', you cannot use option 'pruning' with 'k_order_solver' option or with 3rd order approximation" << endl;
|
cerr << "ERROR: in 'stoch_simul', you cannot use option 'pruning' with 'k_order_solver' option or with 3rd order approximation" << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Workaround for ticket #157
|
|
||||||
it = options_list.num_options.find("periods");
|
|
||||||
if (it != options_list.num_options.end() && atoi(it->second.c_str()) > 0
|
|
||||||
&& mod_file_struct.histval_present)
|
|
||||||
{
|
|
||||||
cerr << "ERROR: the 'periods' option of 'stoch_simul' is not compatible with a 'histval' block" << endl;
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue