Commit cf5f556f authored by Marco Ratto's avatar Marco Ratto

Do not re-set auxiliary variables if they are already available in the input...

Do not re-set auxiliary variables if they are already available in the input info [i.e. smoothed variables].
This makes the function robust when one provides info using UpdatedVariables, instead, for faster realtime exercises.
parent e45acc11
......@@ -193,36 +193,38 @@ end
% Handle auxiliary variables for lags (both on endogenous and exogenous)
for i = 1:length(M_.aux_vars)
if M_.aux_vars(i).type ~= 1 && M_.aux_vars(i).type ~= 3
continue
end
if M_.aux_vars(i).type == 1
% Endogenous
orig_var = M_.endo_names{M_.aux_vars(i).orig_index};
else
% Exogenous
orig_var = M_.exo_names{M_.aux_vars(i).orig_index};
end
[m, k] = ismember(orig_var, outvars);
if m
if ~isempty(strmatch(invars{k}, M_.endo_names))
s = getfield(smoothedvars, invars{k});
else
s = getfield(smoothedshocks, invars{k});
end
l = M_.aux_vars(i).orig_lead_lag;
if period-M_.maximum_endo_lag+1+l < 1
error('The period that you indicated is too small to construct initial conditions')
if ~ ismember(M_.endo_names{M_.aux_vars(i).endo_index},invars)
if M_.aux_vars(i).type ~= 1 && M_.aux_vars(i).type ~= 3
continue
end
j = M_.aux_vars(i).endo_index;
v = s((period-M_.maximum_endo_lag+1+l):(period+l)); %+steady_state(j);
if ~isfield(opts, 'outfile')
M_.endo_histval(j, :) = v;
if M_.aux_vars(i).type == 1
% Endogenous
orig_var = M_.endo_names{M_.aux_vars(i).orig_index};
else
% When saving to a file, x(-2) is in the variable called "x_l2"
lead_lag = num2str(l);
lead_lag = regexprep(lead_lag, '-', 'l');
o = setfield(o, [ orig_var '_' lead_lag ], v);
% Exogenous
orig_var = M_.exo_names{M_.aux_vars(i).orig_index};
end
[m, k] = ismember(orig_var, outvars);
if m
if ~isempty(strmatch(invars{k}, M_.endo_names))
s = getfield(smoothedvars, invars{k});
else
s = getfield(smoothedshocks, invars{k});
end
l = M_.aux_vars(i).orig_lead_lag;
if period-M_.maximum_endo_lag+1+l < 1
error('The period that you indicated is too small to construct initial conditions')
end
j = M_.aux_vars(i).endo_index;
v = s((period-M_.maximum_endo_lag+1+l):(period+l)); %+steady_state(j);
if ~isfield(opts, 'outfile')
M_.endo_histval(j, :) = v;
else
% When saving to a file, x(-2) is in the variable called "x_l2"
lead_lag = num2str(l);
lead_lag = regexprep(lead_lag, '-', 'l');
o = setfield(o, [ orig_var '_' lead_lag ], v);
end
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment