Commit fc9197a9 authored by Johannes Pfeifer 's avatar Johannes Pfeifer

imcforecast.m: Make code robust to 1 period

When using 1 period, the second dimension was a singleton that was removed as well by squeeze, resulting in a column vector when a row vector/matrix was expected. Fixes https://forum.dynare.org/t/problem-with-the-conditional-forecast-in-dynare-4-5-7/14385/2
parent 6b9a86b0
......@@ -265,13 +265,21 @@ forecasts.instruments = options_cond_fcst.controlled_varexo;
for i = 1:EndoSize
forecasts.cond.Mean.(M_.endo_names{oo_.dr.order_var(i)}) = mFORCS1(i,:)';
tmp = sort(squeeze(FORCS1(i,:,:))');
if size(FORCS1,2)>1
tmp = sort(squeeze(FORCS1(i,:,:))');
else
tmp = sort(squeeze(FORCS1(i,:,:)));
end
forecasts.cond.ci.(M_.endo_names{oo_.dr.order_var(i)}) = [tmp(t1,:)' ,tmp(t2,:)' ]';
end
for i = 1:n1
forecasts.controlled_exo_variables.Mean.(options_cond_fcst.controlled_varexo{i}) = mFORCS1_shocks(i,:)';
tmp = sort(squeeze(FORCS1_shocks(i,:,:))');
if size(FORCS1_shocks,2)>1
tmp = sort(squeeze(FORCS1_shocks(i,:,:))');
else
tmp = sort(squeeze(FORCS1_shocks(i,:,:)));
end
forecasts.controlled_exo_variables.ci.(options_cond_fcst.controlled_varexo{i}) = [tmp(t1,:)' ,tmp(t2,:)' ]';
end
......@@ -290,7 +298,11 @@ mFORCS2 = mean(FORCS2,3);
for i = 1:EndoSize
forecasts.uncond.Mean.(M_.endo_names{oo_.dr.order_var(i)})= mFORCS2(i,:)';
tmp = sort(squeeze(FORCS2(i,:,:))');
if size(FORCS2,2)>1
tmp = sort(squeeze(FORCS2(i,:,:))');
else
tmp = sort(squeeze(FORCS2(i,:,:)));
end
forecasts.uncond.ci.(M_.endo_names{oo_.dr.order_var(i)}) = [tmp(t1,:)' ,tmp(t2,:)' ]';
end
forecasts.graph.title = graph_title;
......
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