Skip to content
Snippets Groups Projects
Verified Commit f408be57 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Perfect foresight with expectation errors: handle dates in the “learnt_in” keyword

parent 545968e3
Branches
No related tags found
No related merge requests found
...@@ -78,10 +78,13 @@ else ...@@ -78,10 +78,13 @@ else
allperiods = [allperiods, {M_.det_shocks.periods}]; allperiods = [allperiods, {M_.det_shocks.periods}];
end end
if ~isempty(M_.learnt_shocks) if ~isempty(M_.learnt_shocks)
allperiods = [allperiods, {M_.learnt_shocks.periods}]; allperiods = [allperiods, {M_.learnt_shocks.periods, M_.learnt_shocks.learnt_in }];
end
if ~isempty(M_.learnt_endval)
allperiods = [allperiods, {M_.learnt_endval.learnt_in }];
end end
if any(cellfun(@(x) isa(x, 'dates'), allperiods)) && isempty(first_simulation_period) if any(cellfun(@(x) isa(x, 'dates'), allperiods)) && isempty(first_simulation_period)
error('perfect_foresight_with_expectations_error_setup: at least one periods statement is specified using a date but neither first_simulation_period nor last_simulation_period option was passed') error('perfect_foresight_with_expectations_error_setup: at least one periods statement or learnt_in option is specified using a date but neither first_simulation_period nor last_simulation_period option was passed')
end end
%% Initialize information set at period 1 using “bare” shocks and endval blocks (or initval if there is no endval) %% Initialize information set at period 1 using “bare” shocks and endval blocks (or initval if there is no endval)
...@@ -111,11 +114,17 @@ else ...@@ -111,11 +114,17 @@ else
end end
%% Construct information sets for subsequent informational periods %% Construct information sets for subsequent informational periods
for p = 2:periods % Since the learnt_in=… option with a dates object is never translated to a
% “bare” shocks or endval block by the preprocessor (contrary to
% learnt_in=1), the loop starts with p=1 to also handle dates objects
% in learnt_in option corresponding to the first period.
for p = 1:periods
if p > 1
oo_.pfwee.terminal_info(:, p) = oo_.pfwee.terminal_info(:, p-1); oo_.pfwee.terminal_info(:, p) = oo_.pfwee.terminal_info(:, p-1);
oo_.pfwee.shocks_info(:, :, p) = oo_.pfwee.shocks_info(:, :, p-1); oo_.pfwee.shocks_info(:, :, p) = oo_.pfwee.shocks_info(:, :, p-1);
end
if ~isempty(M_.learnt_endval) if ~isempty(M_.learnt_endval)
idx = find([M_.learnt_endval.learnt_in] == p); idx = find(cellfun(@(x) (isa(x, 'numeric') && x == p) || (isa(x, 'dates') && x - first_simulation_period + 1 == p), {M_.learnt_endval.learnt_in}));
for i = 1:length(idx) for i = 1:length(idx)
j = idx(i); j = idx(i);
exo_id = M_.learnt_endval(j).exo_id; exo_id = M_.learnt_endval(j).exo_id;
...@@ -133,7 +142,7 @@ else ...@@ -133,7 +142,7 @@ else
end end
end end
if ~isempty(M_.learnt_shocks) if ~isempty(M_.learnt_shocks)
idx = find([M_.learnt_shocks.learnt_in] == p); idx = find(cellfun(@(x) (isa(x, 'numeric') && x == p) || (isa(x, 'dates') && x - first_simulation_period + 1 == p), {M_.learnt_shocks.learnt_in}));
for i = 1:length(idx) for i = 1:length(idx)
j = idx(i); j = idx(i);
exo_id = M_.learnt_shocks(j).exo_id; exo_id = M_.learnt_shocks(j).exo_id;
......
Subproject commit 8e3cdd94643b32e885a19ae4c79441ed952a5e2f Subproject commit a88ac75488d86a51f8febbead4692769722881c1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment