Skip to content
Snippets Groups Projects
Commit 6d71870b authored by ferhat's avatar ferhat Committed by Sébastien Villemot
Browse files

Corrects a typo, checks that the number of dates and the number of values are...

Corrects a typo, checks that the number of dates and the number of values are equal, Warns instead of reporting an error if the basic_plan is applied on a shock that is used in a flip_plan (flip_plan has the higher priority)
(cherry picked from commit 4dc21b48)
parent d6bbebb0
No related branches found
No related tags found
No related merge requests found
...@@ -42,24 +42,28 @@ function plan = basic_plan(plan, exogenous, expectation_type, date, value) ...@@ -42,24 +42,28 @@ function plan = basic_plan(plan, exogenous, expectation_type, date, value)
sdate = length(date); sdate = length(date);
if sdate > 1 if sdate > 1
if date(1) < plan.date(1) || date(end) > plan.date(end) if date(1) < plan.date(1) || date(end) > plan.date(end)
error(['in basic_plan the forth argument (date=' date ') must lay inside the plan.date ' plan.date]); error(['in basic_plan the fourth argument (date=' date ') must lay inside the plan.date ' plan.date]);
end end
else else
if date < plan.date(1) || date > plan.date(end) if date < plan.date(1) || date > plan.date(end)
error(['in basic_plan the forth argument (date=' date ') must lay iside the plan.date ' plan.date]); error(['in basic_plan the fourth argument (date=' date ') must lay iside the plan.date ' plan.date]);
end end
end end
if length(date) ~= length(value)
error(['in basic_plan the number of dates (' int2str(length(date)) ') is not equal to the numbers of shock (' int2str(length(value)) ') for exogenous variable ' exogenous]);
end
if ~isempty(plan.options_cond_fcst_.controlled_varexo) if ~isempty(plan.options_cond_fcst_.controlled_varexo)
common_var = find(ix == plan.options_cond_fcst_.controlled_varexo); common_var = find(ix == plan.options_cond_fcst_.controlled_varexo);
if ~isempty(common_var) if ~isempty(common_var)
common_date = intersect(date, plan.constrained_date_{common_var}); common_date = intersect(date, plan.constrained_date_{common_var});
if ~isempty(common_date) if ~isempty(common_date)
date = setdiff(date, common_date);
if common_date.length > 1 if common_date.length > 1
the_dates = [cell2mat(strings(common_date(1))) ':' cell2mat(strings(common_date(end)))]; the_dates = [cell2mat(strings(common_date(1))) ':' cell2mat(strings(common_date(end)))];
else else
the_dates = cell2mat(strings(common_date)); the_dates = cell2mat(strings(common_date));
end end
error(['Impossible case: ' plan.exo_names{plan.options_cond_fcst_.controlled_varexo(common_var)} ' is used both as a shock and as an endogenous variable to control the path of ' plan.endo_names{plan.constrained_vars_(common_var)} ' at the dates ' the_dates]); warning(['Impossible case: ' plan.exo_names{plan.options_cond_fcst_.controlled_varexo(common_var)} ' is used both as a shock and as an endogenous variable to control the path of ' plan.endo_names{plan.constrained_vars_(common_var)} ' at the dates ' the_dates]);
end end
end end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment