Changed the initialization of the persistent variables in perfect_foresight_simulation.

time-shift
Stéphane Adjemian (Charybdis) 2010-05-05 16:25:28 +02:00
parent 83521c384f
commit 913ef20078
2 changed files with 11 additions and 10 deletions

View File

@ -86,6 +86,8 @@ verbose = 0;
t = 0;
new_draw = 1;
perfect_foresight_simulation([],[],[]);
while (t<=sample_size)
t = t+1;
if new_draw

View File

@ -1,4 +1,4 @@
function info = perfect_foresight_simulation(compute_linear_solution,steady_state)
function info = perfect_foresight_simulation(compute_linear_solution,steady_state, init_flag)
% Performs deterministic simulations with lead or lag on one period
%
% INPUTS
@ -37,19 +37,15 @@ function info = perfect_foresight_simulation(compute_linear_solution,steady_stat
global M_ options_ it_ oo_
persistent flag_init
persistent lead_lag_incidence dynamic_model ny nyp nyf nrs nrc iyf iyp isp is isf isf1 iz icf
persistent ghx
persistent lead_lag_incidence dynamic_model ny nyp nyf nrs nrc iyf iyp isp is isf isf1 iz icf ghx
initial_endo_simul = oo_.endo_simul;
if isempty(flag_init)
if nargin==3% Initialization of the persistent variables.
lead_lag_incidence = M_.lead_lag_incidence;
dynamic_model = [M_.fname '_dynamic'];
ny = size(oo_.endo_simul,1);
nyp = nnz(lead_lag_incidence(1,:));% number of lagged variables.
nyf = nnz(lead_lag_incidence(3,:));% number of leaded variables.
nrs = ny+nyp+nyf+1;
nrs = ny+nyp+nyf+1;
nrc = nyf+1;
iyf = find(lead_lag_incidence(3,:)>0);% indices for leaded variables.
iyp = find(lead_lag_incidence(1,:)>0);% indices for lagged variables.
@ -58,10 +54,13 @@ if isempty(flag_init)
isf = iyf+nyp;
isf1 = (nyp+ny+1):(nyf+nyp+ny+1);
iz = 1:(ny+nyp+nyf);
icf = 1:size(iyf,2);
flag_init = 1;
icf = 1:size(iyf,2);
info = [];
return
end
initial_endo_simul = oo_.endo_simul;
warning off all
if nargin<1