load retstk.dat
load efundcost.dat
load yldstk.dat
load retmuni.dat
load retcorp.dat
load cpiinf.dat
load taud1040.dat
load slfactor.dat
load ntfactor.dat
load nipar.dat
macpi = wmavg(cpiinf(:,2),10,0,[ones(10,1);0.0001]);
taud  = taud1040(:,2).*slfactor(:,2).*ntfactor(:,2)/100;
N     = 15;

figure(1)
plot(1871:2002,mavg(retstk(:,2)-cpiinf(:,2)-taud.*yldstk(:,2)- ...
               efundcost(:,2)/100,N,N),'b', ...
               nipar(:,1),nipar(:,2),'g', ...
     1871:1934,retmuni(1:64,2),'r-+', ...
     1935:2002,retcorp(65:132,2)-macpi(65:132),'r-o', ...
     1871:2002,mean(nipar(:,2))*ones(132,1),'k')
title('Real After-tax and After-fee Asset Returns') 
legend('Large-company Stocks','NIPA Capital', ...
       'Long-term Municipal Bonds','Moody''s Aaa Corporate Bonds')
axis([1880,2002,-5,15])

figure(2)
plot(1871:2002,mavg(retstk(:,2)-cpiinf(:,2)-taud.*yldstk(:,2)- ...
               efundcost(:,2)/100,N,N),'b', ...
               nipar(:,1),nipar(:,2),'g', ...
     1871:1934,retmuni(1:64,2),'r-+', ...
     1960:2002,retcorp(90:132,2)-macpi(90:132),'r-o', ...
     1871:2002,mean(nipar(:,2))*ones(132,1),'k')
title('Real After-tax and After-fee Asset Returns') 
legend('Large-company Stocks','NIPA Capital', ...
       'Long-term Municipal Bonds','Moody''s Aaa Corporate Bonds')
axis([1880,2002,-5,15])

tem = [[1871:2002]',mavg(retstk(:,2)-cpiinf(:,2)-taud.*yldstk(:,2)- ...
                    efundcost(:,2)/100,N,N), ...
                    [NaN*ones(58,1);nipar(:,2);NaN;NaN], ...
                    [retmuni(1:64,2);retcorp(65:132,2)-macpi(65:132)], ...
                    mean(nipar(:,2))*ones(132,1)];
 
