%ACTUAL    This file compares original data with Kalman smoothed
%          predictions (all shocks on) for Smets-Wouters (AER 2007).
%

%          Ellen McGrattan, 3-28-08


%
% Load dynare matrices dr_. oo_. from:
%
load usmodel_results.mat

%
% Load US data from (with original series in colums 1-12):
%
load ../sw_orig/usmodel_data.csv
d      = usmodel_data(73:232,1:12);
dlag   = usmodel_data(72:231,1:12);

ctrend = oo_.posterior_mode.parameters.ctrend;
cgamma = 1+ctrend/100 ;
Ysm    = [oo_.SmoothedVariables.c, ...
          oo_.SmoothedVariables.inve, ...
          oo_.SmoothedVariables.y, ...
          oo_.SmoothedVariables.labobs, ...
          oo_.SmoothedVariables.w, ...
          oo_.SmoothedVariables.pinfobs, ...
          oo_.SmoothedVariables.robs];
C      = d(:,4)./(d(:,3).*d(:,10)); C=C./(C(1)*cgamma.^[0:159]');
I      = d(:,5)./(d(:,3).*d(:,10)); I=I./(I(1)*cgamma.^[0:159]');
Y      = d(:,2)./d(:,10);           Y=Y./(Y(1)*cgamma.^[0:159]');
W      = d(:,12)./d(:,3);           W=W./(W(1)*cgamma.^[0:159]');
H      = d(:,11).*d(:,7)./d(:,10)/100;
Pi     = (log(d(:,3))-log(dlag(:,3)))*100;
R      = d(:,8)/4;
lnC    = (log(C)-mean(log(C)))*100;
lnI    = (log(I)-mean(log(I)))*100;
lnY    = (log(Y)-mean(log(Y)))*100;
lnW    = (log(W)-mean(log(W)))*100;
lnH    = (log(H)-mean(log(H)))*100;
Yact   = [lnC,lnI,lnY,lnH,lnW,Pi-mean(Pi),R-mean(R)];

t      = ptime(1965.1,160,4);
vars   = ['Consumption   '
          'Investment    '
          'Output        '
          'Hours         '
          'Real Wage     '
          'Inflation     '
          'Fed Funds rate'];
for i=1:7;
  plot(t,[Ysm(:,i),Yact(:,i)])
  set(gca,'Fontsize',16)
  legend('KF Smoothed','Actual')
  title(vars(i,:))
  pause(3) 
end;

disp('NOTE: variables that grow are detrended and logged and')
disp('      actual variables are demeaned.')
