Initialize empirical simulations with information provided in histval

Closes: #195, #157
time-shift
Sébastien Villemot 2011-12-21 18:37:45 +01:00
parent ea8162c11f
commit a2061b6f4e
4 changed files with 19 additions and 15 deletions

View File

@ -1,9 +1,9 @@
function y_=simult(ys, dr)
% function y_=simult(ys, dr)
function y_=simult(y0, dr)
% function y_=simult(y0, dr)
% Recursive Monte Carlo simulations
%
% 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
%
% OUTPUTS
@ -54,7 +54,7 @@ for i=1:replic
if ~isempty(M_.Sigma_e)
oo_.exo_simul(:,i_exo_var) = randn(options_.periods,nxs)*chol_S;
end
y_ = simult_(ys,dr,oo_.exo_simul,order);
y_ = simult_(y0,dr,oo_.exo_simul,order);
% elimninating initial value
y_ = y_(:,2:end);
if replic > 1

View File

@ -130,7 +130,15 @@ if options_.periods > 0 && ~PI_PCL_solver
options_ =options_old;
return
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;
end

View File

@ -82,7 +82,12 @@ elseif options_.periods ~= 0
options_ =options_old;
return
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;
if options_.nomoments == 0
disp_moments(oo_.endo_simul,var_list);

View File

@ -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;
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