Skip to content
Snippets Groups Projects
Commit a63bc5b7 authored by Marco Ratto's avatar Marco Ratto Committed by Stéphane Adjemian
Browse files

fixed bugs with dating of AOA decompositions

parent 3e589d24
No related branches found
No related tags found
No related merge requests found
...@@ -75,6 +75,15 @@ if vintage_ ...@@ -75,6 +75,15 @@ if vintage_
end end
initial_date = options_.initial_date; initial_date = options_.initial_date;
if isempty(initial_date)
if isempty(type)
% we assume annual model
initial_date = dates('1Y');
else
% we assume the sample starts in Q1
initial_date = dates('1Q1');
end
end
if isfield(options_.plot_shock_decomp,'q2a') % private trap for aoa calls if isfield(options_.plot_shock_decomp,'q2a') % private trap for aoa calls
q2a=options_.plot_shock_decomp.q2a; q2a=options_.plot_shock_decomp.q2a;
...@@ -103,7 +112,7 @@ switch realtime_ ...@@ -103,7 +112,7 @@ switch realtime_
case 2 % conditional case 2 % conditional
if vintage_ if vintage_
z = oo_.realtime_conditional_shock_decomposition.(['time_' int2str(vintage_)]); z = oo_.realtime_conditional_shock_decomposition.(['time_' int2str(vintage_)]);
initial_date = options_.initial_date+vintage_-1; initial_date = initial_date+vintage_-1;
fig_name1=[fig_name ' ' int2str(forecast_) '-step ahead conditional forecast (given ' char(initial_date) ')']; fig_name1=[fig_name ' ' int2str(forecast_) '-step ahead conditional forecast (given ' char(initial_date) ')'];
else else
z = oo_.conditional_shock_decomposition.pool; z = oo_.conditional_shock_decomposition.pool;
...@@ -113,7 +122,7 @@ switch realtime_ ...@@ -113,7 +122,7 @@ switch realtime_
case 3 % forecast case 3 % forecast
if vintage_ if vintage_
z = oo_.realtime_forecast_shock_decomposition.(['time_' int2str(vintage_)]); z = oo_.realtime_forecast_shock_decomposition.(['time_' int2str(vintage_)]);
initial_date = options_.initial_date+vintage_-1; initial_date = initial_date+vintage_-1;
fig_name1=[fig_name ' ' int2str(forecast_) '-step ahead forecast (given ' char(initial_date) ')']; fig_name1=[fig_name ' ' int2str(forecast_) '-step ahead forecast (given ' char(initial_date) ')'];
else else
z = oo_.realtime_forecast_shock_decomposition.pool; z = oo_.realtime_forecast_shock_decomposition.pool;
...@@ -124,22 +133,13 @@ end ...@@ -124,22 +133,13 @@ end
steady_state = oo_.steady_state; steady_state = oo_.steady_state;
if isequal(type,'aoa') && isstruct(q2a) && realtime_ if isequal(type,'aoa') && isstruct(q2a) && realtime_
if isempty(initial_date) % take all dates where realtime is saved
t0=1; qqq=initial_date+options_.shock_decomp.save_realtime(:)-1;
initial_date = dates('1Y'); % take the first Q4 of saved realtime
else t0=min(options_.shock_decomp.save_realtime(qqq.time(:,2)==4));
initial_date0 = dates([int2str(initial_date.time(1)) 'Y']); if isempty(t0)
if initial_date.time(2)==1 error('the realtime decompositions are not stored in Q4! Please check your dates and settings.')
t0=1;
initial_date1=initial_date0;
else
t0=(4-initial_date.time(2)+2);
initial_date1=initial_date0+1;
end end
end
t0=min(options_.plot_shock_decomp.save_realtime);
ini1 = initial_date+t0-1;
t0=t0+(4-ini1.time(2));
if ~isfield(q2a,'var_type') % private trap for aoa calls if ~isfield(q2a,'var_type') % private trap for aoa calls
q2a.var_type=1; q2a.var_type=1;
end end
...@@ -232,7 +232,7 @@ switch type ...@@ -232,7 +232,7 @@ switch type
case 'yoy' case 'yoy'
z=z(:,:,1:end-3)+z(:,:,2:end-2)+z(:,:,3:end-1)+z(:,:,4:end); z=z(:,:,1:end-3)+z(:,:,2:end-2)+z(:,:,3:end-1)+z(:,:,4:end);
if ~isempty(initial_date), if ~isempty(initial_date)
initial_date = initial_date+3; initial_date = initial_date+3;
else else
initial_date = dates('1Q4'); initial_date = dates('1Q4');
...@@ -242,18 +242,24 @@ switch type ...@@ -242,18 +242,24 @@ switch type
case 'aoa' case 'aoa'
if isempty(initial_date) if isempty(initial_date)
t0=4; t0=1; % we assume the sample starts Q1 of 1st year
initial_date = dates('1Y'); initial_date = dates('1Y');
else else
initial_date0 = dates([int2str(initial_date.time(1)) 'Y']); initial_date0 = dates([int2str(initial_date.time(1)) 'Y']);
if initial_date.time(2)==1 if initial_date.time(2)==1 % the first year is full
t0=1; t0=1;
initial_date1=initial_date0; initial_date1=initial_date0;
else else
t0=(4-initial_date.time(2)+2); t0=(4-initial_date.time(2)+2); % 1st period of the 1st full year in sample
initial_date1=initial_date0+1; initial_date1=initial_date0+1;
end end
end end
if realtime_ == 0
t0=t0+4-1; % we start in Q4 of the first full year
end
if isempty(options_.plot_shock_decomp.plot_init_date) && realtime_ == 0
options_.plot_shock_decomp.plot_init_date=initial_date+t0;
end
if isstruct(q2a) if isstruct(q2a)
if realtime_ == 0 if realtime_ == 0
if ~isfield(q2a,'var_type') % private trap for aoa calls if ~isfield(q2a,'var_type') % private trap for aoa calls
...@@ -295,6 +301,7 @@ switch type ...@@ -295,6 +301,7 @@ switch type
initial_date = initial_date0; initial_date = initial_date0;
end end
else else
% this is for quarterly-annualized variables already defined in model, so we can just take Q4
t0=4-initial_date.time(2)+1; t0=4-initial_date.time(2)+1;
initial_date = initial_date0; initial_date = initial_date0;
z=z(:,:,t0:4:end); z=z(:,:,t0:4:end);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment