%MONTEVD Take ndraw realizations of shocks from RBC model
%        estimated by MLE with US data.  Use them to get 
%        ndraw realizations of productivity and hours.  
%        Apply SVAR filter to see the predicted decomposition
%        of variance.

%        Ellen McGrattan, 3-17-04

randn('seed',1004)
ndraw = 1000;
for I=1:ndraw;
  drawq;
  gr  = (1+gz).^[0:length(Yt)-1]';
  tem = [(exp(Yt(:,1)).*gr)./exp(Yt(:,3)),exp(Yt(:,3))];
  save fakedat.dat tem -ascii
  fake_gr_vd;
  Vy(I,1) = vyz/(vyz+vyd);
  Vh(I,1) = vhz/(vhz+vhd);
end;
svy  = sort(Vy);
svh  = sort(Vh);
mvy  = mean(Vy);
mvh  = mean(Vh);
lb   = round(.025*ndraw);
ub   = ndraw-round(.025*ndraw);

disp('Fraction of Variance of Output Due to Technology:')
disp(sprintf('   Mean           %7.3f ',mvy))
disp(sprintf('   2.5 pct band   %7.3f ',svy(lb)))
disp(sprintf('   97.5 pct band  %7.3f ',svy(ub)))
disp(' ')
disp('Fraction of Variance of Hours Due to Technology:')
disp(sprintf('   Mean           %7.3f ',mvh))
disp(sprintf('   2.5 pct band   %7.3f ',svh(lb)))
disp(sprintf('   97.5 pct band  %7.3f ',svh(ub)))

