%
%
%
%
%

figuresdir = '../20070126fomc' ;

HPloose = 5e5 ;
HPtight = 5e7 ;
HPlooselt = 3e7 ;
HPtightlt = 3e8 ;

ipind = 1 ;
ipdifind = 4 ;
caputind = 6 ;
nfpind = 8 ;
unempind = 16 ;
startsind = 44 ;
exhomeind = 47 ;
ismind = 60 ;
wilshind = 72 ;

cpiind = 1 ;
cpixind = 2 ;
pceind = 3 ;
pcexind = 4 ;
pcomind = 16 ;
poilind = 19 ;

ffrind = 1 ;
threemoind = 2 ;
tenyrind = 5 ;

dollarind = 10 ;
tradebalind = 1 ;


%
% Plot forecasts of EA Factors #1 and #2 and observable EA variables:
%

plot(date(1:T),eafactors(1:T,1),'LineWidth',1) ;
hold on ;
plot([1964 2011],zeros(2,1),':k') ;
shaderec(date(T)-.05/12, date(T)+.05/12, [.3,.3,.3]) ;
axis([1998,2009,-2,2]) ;
set(gca,'FontSize',12) ;
hold off ;
print('-dpng',strcat(figuresdir,'/figure4a.png')) ;

plot(date(1:T),eafactors(1:T,1),'LineWidth',1) ;
hold on ;
plot(date,eafactors(:,1),'--','LineWidth',1) ;
plot([1964 2011],zeros(2,1),':k') ;
shaderec(date(T)-.05/12, date(T)+.05/12, [.3,.3,.3]) ;
axis([1998,2009,-2,2]) ;
set(gca,'FontSize',12) ;
hold off ;
print('-dpng',strcat(figuresdir,'/figure4b.png')) ;

plot(date(1:T),eafactors(1:T,1),'LineWidth',1) ;
hold on ;
plot(date(1:T),-eafactors(1:T,2),'r','LineWidth',1) ;
plot([1964 2011],zeros(2,1),':k') ;
shaderec(date(T)-.05/12, date(T)+.05/12, [.3,.3,.3]) ;
axis([1998,2009,-2,2]) ;
set(gca,'FontSize',12) ;
hold off ;
print('-dpng',strcat(figuresdir,'/figure4c.png')) ;

plot(date(1:T),eafactors(1:T,1),'LineWidth',1) ;
hold on ;
plot(date,-eafactors(:,2),'r--','LineWidth',1) ;
plot(date(1:T),-eafactors(1:T,2),'r','LineWidth',1) ;
plot([1964 2011],zeros(2,1),':k') ;
axis([1998,2009,-2,2]) ;
shaderec(date(T)-.05/12, date(T)+.05/12, [.3,.3,.3]) ;
set(gca,'FontSize',12) ;
hold off ;
print('-dpng',strcat(figuresdir,'/figure4d.png')) ;

plot(date(1:T),eafactors(1:T,1),'LineWidth',1) ;
hold on ;
plot(date,eafactors(:,1),'--','LineWidth',1) ;
plot(date(1:T),-eafactors(1:T,2),'r','LineWidth',1) ;
plot(date,-eafactors(:,2),'r--','LineWidth',1) ;
plot([1964 2011],zeros(2,1),':k') ;
axis([1998,2009,-2,2]) ;
shaderec(date(T)-.05/12, date(T)+.05/12, [.3,.3,.3]) ;
set(gca,'FontSize',12) ;
hold off ;
print('-dpng',strcat(figuresdir,'/figure4e.png')) ;

plot(date(1:T),eafactors(1:T,1),'LineWidth',1) ;
hold on ;
plot(date,eafactors(:,1),'--','LineWidth',1) ;
plot([1964 2011],zeros(2,1),':k') ;
shaderec(date(T)-.01/12, date(T)+.01/12, [.3,.3,.3]) ;
plot(date(1:T),econactivity(1:T,ipind),'Color',[.1,.1,.1],'LineWidth',1) ;
plot(date,econactivity(:,ipind),'--','Color',[.1,.1,.1],'LineWidth',1) ;
axis([2006,2008,0,1]) ;
set(gca,'FontSize',12) ;
hold off ;
print('-dpng',strcat(figuresdir,'/figure4f.png')) ;



%
% Plot some counterfactuals for the current forecast, setting all factors to their
%  historical average and then setting each latent factor in turn equal to
%  its recent values:
%

n = size(vardata,2) ;

for i = 1:n ;
  vardata1 = repmat(mean(vardata(1:T-1,:)),varlags,1) ;
  vardata1(1:varlags,i) = vardata(T-varlags+1:T,i) ;
  cfactfcast(:,:,i) = [zeros(1,n); VARfcast(vardata1,varlags,fcasthorizon,B)] ;
end ;

plot(date,zeros(T+fcasthorizon,1),'k','LineWidth',1) ; % Baseline forecast
axis([2006,2009,-1,1]) ;
hold on ;
plot([1964 2011],zeros(2,1),':k') ;
shaderec(date(T)-.02/12, date(T)+.02/12, [.3,.3,.3]) ;
set(gca,'FontSize',12) ;
print('-dpng',strcat(figuresdir,'/figure9a.png')) ;

plot(date(T:T+fcasthorizon),squeeze(cfactfcast(:,1,1)),'--r','LineWidth',1.5) ; % better
print('-dpng',strcat(figuresdir,'/figure9b.png')) ;

plot(date(T:T+fcasthorizon),squeeze(cfactfcast(:,1,2)),'--','Color',[1 .5 0],'LineWidth',1) ;
print('-dpng',strcat(figuresdir,'/figure9c.png')) ;

plot(date(T:T+fcasthorizon),squeeze(cfactfcast(:,1,3)),'--y','LineWidth',1) ; % better
print('-dpng',strcat(figuresdir,'/figure9d.png')) ;

plot(date(T:T+fcasthorizon),squeeze(cfactfcast(:,1,4)),'--g','LineWidth',1) ; % better
print('-dpng',strcat(figuresdir,'/figure9e.png')) ;

plot(date(T:T+fcasthorizon),squeeze(cfactfcast(:,1,5)),'--','Color',[0,.6,0],'LineWidth',1) ; % better
print('-dpng',strcat(figuresdir,'/figure9f.png')) ;

plot(date(T:T+fcasthorizon),squeeze(cfactfcast(:,1,6)),'--b','LineWidth',1) ; % better
print('-dpng',strcat(figuresdir,'/figure9g.png')) ;

plot(date(T:T+fcasthorizon),squeeze(cfactfcast(:,1,7)),'--','Color',[.67,0,1],'LineWidth',1) ; % much worse
print('-dpng',strcat(figuresdir,'/figure9h.png')) ;

plot(date(T:T+fcasthorizon),squeeze(cfactfcast(:,1,8)),'--','Color',[.9,.4,.4],'LineWidth',1) ; % much worse
print('-dpng',strcat(figuresdir,'/figure9i.png')) ;

plot(date(T:T+fcasthorizon),squeeze(cfactfcast(:,1,9)),'--','Color',[.4,.4,.4],'LineWidth',1) ; % much worse
print('-dpng',strcat(figuresdir,'/figure9j.png')) ;

hold off ;

  





