%ACCOUNTS    Accounting used for Sweat Equity project
%
%

%
% Sample t0:t1
%

t0           = 1990;
t1           = 2003;

%
% NIPA Table 1.1.5 Gross domestic product (Annual, Bil$)
%

load BEA/NIPA/table1_1_5A.dat
[n,m]        = size(table1_1_5A);
t            = table1_1_5A(1,:);
i            = find(t==t0):find(t==t1);
table1_1_5A  = table1_1_5A(2:n,i);

gdp          = table1_1_5A(1,:)';
pce          = table1_1_5A(2,:)';
pced         = table1_1_5A(3,:)';
pcend        = table1_1_5A(4,:)';
pces         = table1_1_5A(5,:)';
gpdi         = table1_1_5A(6,:)';
gpdif        = table1_1_5A(7,:)';
gpdii        = table1_1_5A(12,:)';
netxm        = table1_1_5A(13,:)';
netx         = table1_1_5A(14,:)';
netm         = table1_1_5A(17,:)';
gov          = table1_1_5A(20,:)';

%
% NIPA Table 1.1.9 Implicit price deflators (2000=100)
%

load BEA/NIPA/table1_1_9A.dat
[n,m]        = size(table1_1_9A);
t            = table1_1_9A(1,:);
i            = find(t==t0):find(t==t1);
table1_1_9A  = table1_1_9A(2:n,i);

dgdp0        = table1_1_9A(1,:)';
dgdp         = dgdp0/dgdp0(1);


%
% NIPA Table 1.10 Gross domestic income (Annual, Bil$)
%

load BEA/NIPA/table1_10A.dat
[n,m]        = size(table1_10A);
t            = table1_10A(1,:);
i            = find(t==t0):find(t==t1);
table1_10A   = table1_10A(2:n,i);

gdi          = table1_10A(1,:)';
comp         = table1_10A(2,:)';
ibt          = table1_10A(9,:)'-table1_10A(10,:)'+table1_10A(14,:)';
nint         = table1_10A(13,:)';
pinc         = table1_10A(15,:)';
rent         = table1_10A(16,:)';
prof         = table1_10A(17,:)';
gprof        = table1_10A(22,:)';
dep          = table1_10A(23,:)';
desc         = table1_10A(26,:)';

%
% NIPA Table 1.12  National income by type of income (Anuual, Bil$)
%

load BEA/NIPA/table1_12A.dat
[n,m]        = size(table1_12A);
t            = table1_12A(1,:);
i            = find(t==t0):find(t==t1);
table1_12A   = table1_12A(2:n,i);

natprof      = table1_12A(13,:)';

%
% NIPA Table 1.13  National income by sector (Anuual, Bil$)
%

load BEA/NIPA/table1_13A.dat
[n,m]        = size(table1_13A);
t            = table1_13A(1,:);
i            = find(t==t0):find(t==t1);
table1_13A   = table1_13A(2:n,i);

dbus         = table1_13A(2,:)';
dcbus        = table1_13A(3,:)';
dcbuscomp    = table1_13A(4,:)';
dcbusprof    = table1_13A(7,:)';
dcbusnint    = table1_13A(8,:)';
dcbusibt     = table1_13A(9,:)';
dncbus       = table1_13A(10,:)';
dncbuscomp   = table1_13A(11,:)';
dncbuspinc   = table1_13A(14,:)';
dncbusrent   = table1_13A(15,:)';
dncbusnint   = table1_13A(16,:)';
dncbusibt    = table1_13A(17,:)';
dncbusgprof  = table1_13A(18,:)';
dppbus       = table1_13A(19,:)';
dppbuscomp   = table1_13A(20,:)';
dppbuspinc   = table1_13A(23,:)';
dppbusfpinc  = table1_13A(24,:)';
dppbusnfpinc = table1_13A(25,:)';
dppbusnint   = table1_13A(26,:)';
dppbusibt    = table1_13A(27,:)';
dopbus       = table1_13A(28,:)';
dopbuscomp   = table1_13A(29,:)';
dopbuspinc   = table1_13A(32,:)';
dopbusrent   = table1_13A(33,:)';
dopbusnint   = table1_13A(34,:)';
dopbusibt    = table1_13A(35,:)';
dgebus       = table1_13A(36,:)';
dgebuscomp   = table1_13A(37,:)';
dgebusgprof  = table1_13A(40,:)';
dhh          = table1_13A(42,:)';
dhhcomp      = table1_13A(43,:)';
dhhrent      = table1_13A(46,:)';
dhhnint      = table1_13A(47,:)';
dhhibt       = table1_13A(48,:)';
dnp          = table1_13A(49,:)';
dnpcomp      = table1_13A(50,:)';
dnprent      = table1_13A(53,:)';
dnpnint      = table1_13A(54,:)';
dnpibt       = table1_13A(55,:)';
dgg          = table1_13A(56,:)';
dggcomp      = table1_13A(57,:)';
row          = table1_13A(60,:)';
rowcomp      = table1_13A(61,:)';
rowprof      = table1_13A(62,:)';
rownint      = table1_13A(63,:)';

ssectcomp    = dcbuscomp+dppbuscomp+dopbuscomp;
ssectprof    = dcbusprof;
ssectrent    = dopbusrent;
ssectpinc    = dppbuspinc;
ssectnint    = dcbusnint+dppbusnint+dopbusnint;
ssectibt     = dcbusibt+dppbusibt+dopbusibt;
ssecti       = ssectcomp+ssectprof+ssectrent+ssectpinc+ssectnint+ssectibt;

osectcomp    = dhhcomp+dnpcomp+dgebuscomp+dggcomp;
osectrent    = dhhrent+dnprent;
osectprof    = dgebusgprof;
osectpinc    = 0*dhhcomp;
osectnint    = dhhnint+dnpnint;
osectibt     = dhhibt+dnpibt;
osecti       = osectcomp+osectprof+osectrent+osectpinc+osectnint+osectibt;

%
% NIPA Table 1.14  Gross VA of domestic corporate business (Annual, Bil$)
%

load BEA/NIPA/table1_14A.dat
[n,m]        = size(table1_14A);
t            = table1_14A(1,:);
i            = find(t==t0):find(t==t1);
table1_14A   = table1_14A(2:n,i);

cgdi         = table1_14A(1,:)';
cdep         = table1_14A(2,:)';
ccomp        = table1_14A(4,:)';
cibt         = table1_14A(7,:)'+table1_14A(10,:)';
cnint        = table1_14A(9,:)';
cprof        = table1_14A(11,:)';
ctax         = table1_14A(12,:)';
ndiv         = table1_14A(14,:)';
rete         = table1_14A(15,:)';
pbtd         = table1_14A(32,:)';
patd         = table1_14A(33,:)';
ccadj        = table1_14A(35,:)';  

%
% NIPA Table 2.5.5 Personal consumption expenditures by type (Annual, Bil$)
%

load BEA/NIPA/table2_5_5A.dat
[n,m]        = size(table2_5_5A);
t            = table2_5_5A(1,:);
i            = find(t==t0):find(t==t1);
table2_5_5A  = table2_5_5A(2:n,i);

pbexp        = table2_5_5A(64,:)';

%
% NIPA Table 3.1 Govt current receipts and expenditures (Annual, Bil$)
%

load BEA/NIPA/table3_1A.dat
[n,m]        = size(table3_1A);
t            = table3_1A(1,:);
i            = find(t==t0):find(t==t1);
t3_1A        = table3_1A(1,i)';
table3_1A    = table3_1A(2:n,i);

govc         = table3_1A(16,:)';
govi         = table3_1A(35,:)';
hhdt         = table3_1A(3,:)';
hhss         = table3_1A(7,:)';


%
% NIPA Table 3.2 Federal govt current receipts and expenditures (Annual, Bil$)
%

load BEA/NIPA/table3_2A.dat
[n,m]        = size(table3_2A);
t            = table3_2A(1,:);
i            = find(t==t0):find(t==t1);
table3_2A    = table3_2A(2:n,i);

fedres       = table3_2A(8,:)';

%
% NIPA Table 3.5 Taxes on production and imports (Annual, Bil$)
%

load BEA/NIPA/table3_5A.dat
[n,m]        = size(table3_5A);
t            = table3_5A(1,:);
i            = find(t==t0):find(t==t1);
table3_5A    = table3_5A(2:n,i);

ibtonly      = table3_5A(1,:)';
stax         = sum(table3_5A([3,11,14,28,29,30,31],:))';
ptax         = table3_5A(27,:)';

%
% NIPA Table 5.7.5A Private inventories and final sales (Quarterly, Bil$)
%

load BEA/NIPA/table5_7_5BQ.dat
load BEA/NIPA/table5_7_5AQ.dat
table5_7_5BQ = [table5_7_5BQ(1,:)+table5_7_5BQ(2,:)/10;
                table5_7_5BQ(3:4,:)];
table5_7_5AQ = [table5_7_5AQ(1,:)+table5_7_5AQ(2,:)/10;
                table5_7_5AQ(3:4,:)];
i            = find(table5_7_5AQ(1,:)==table5_7_5BQ(1,1));
table5_7_5Q  = [table5_7_5AQ(1:3,1:i-1),table5_7_5BQ(1:3,:)];
table5_7_5A  = (qtr2ann(table5_7_5Q',1))';
[n,m]        = size(table5_7_5A);
t            = table5_7_5A(1,:);
i            = find(t==t0):find(t==t1);
table5_7_5A  = table5_7_5A(2:n,i);

kcinv        = table5_7_5A(1,:)'-.9*table5_7_5A(2,:)';
kncinv       = .9*table5_7_5A(2,:)';

%
% NIPA Table 7.5 Consumption of fixed capital by legal form (Annual, Bil$)
%

load BEA/NIPA/table7_5A.dat
[n,m]        = size(table7_5A);
t            = table7_5A(1,:);
i            = find(t==t0):find(t==t1);
table7_5A    = table7_5A(2:n,i);

dbusdep      = table7_5A(3,:)';
dcbusdep     = table7_5A(4,:)';
dncbusdep    = table7_5A(7,:)';
dppbusdep    = table7_5A(8,:)';
dopbusdep    = table7_5A(11,:)';
dgebusdep    = table7_5A(25,:)';
dhhdep       = table7_5A(19,:)';
dnpdep       = table7_5A(20,:)';
dggdep       = table7_5A(22,:)';

ssectdep     = dcbusdep+dppbusdep+dopbusdep;
ssect        = ssecti+ssectdep;
osectdep     = dhhdep+dnpdep+dgebusdep+dggdep;
osect        = osecti+osectdep;

%
% NIPA Table 7.19  Relation of corporate profits, etc. in NIPA and IRS
% (Source for 2002-2003 is IRS SOI Bulletin) 
%

load BEA/NIPA/table7_19A.dat
[n,m]        = size(table7_19A);
table7_19A   = [table7_19A,[2002:2004;NaN*ones(n-1,3)]];
t            = table7_19A(1,:);
i            = find(t==t0):find(t==t1);
table7_19A   = table7_19A(2:n,i);

gain         = table7_19A(12,:)';
j            = find([t0:t1]==2002);
gain(j)      = 268.202-29.834+7.292-9.678;
gain(j+1)    = 288.629-28.922+7.522-7.048;

%
% FA Table 1.1 Current-cost net stocks (Annual, Bil$, year-end) 
%

load BEA/FA/table1_1A.dat
[n,m]        = size(table1_1A);
t            = table1_1A(1,:);
i            = find(t==t0):find(t==t1);
table1_1A    = table1_1A(2:n,i);

kfix         = table1_1A(2,:)';
kgfix        = table1_1A(8,:)';
kcd          = table1_1A(13,:)';

%
% FA Table 1.5 Historical-cost investments (Annual, Bil$, year-end) 
%

load BEA/FA/table1_5A.dat
[n,m]        = size(table1_5A);
t            = table1_5A(1,:);
i            = find(t==t0):find(t==t1);
table1_5A    = table1_5A(2:n,i);

xfix         = table1_5A(2,:)';
xgfix        = table1_5A(8,:)';
xcd          = table1_5A(13,:)';

%
% FA Tables 6.1 Current-cost net stocks by owner (Annual, Bil$, year-end) 
%

load BEA/FA/table6_1A.dat
[n,m]        = size(table6_1A);
t            = table6_1A(1,:);
i            = find(t==t0):find(t==t1);
t6_1A        = table6_1A(1,i)';
table6_1A    = table6_1A(2:n,i);

kcfix        = table6_1A(2,:)';
kppfix       = table6_1A(6,:)'+table6_1A(7,:)';
khhfix       = table6_1A(9,:)';
knpfix       = table6_1A(8,:)';
ktefix       = table6_1A(10,:)';
kncfix       = kppfix+khhfix+knpfix+ktefix;

%
% FA Table 6.7 Historical-cost investments by owner (Annual, Bil$, year-end) 
%

load BEA/FA/table6_7A.dat
[n,m]        = size(table6_7A);
t            = table6_7A(1,:);
i            = find(t==t0):find(t==t1);
t6_7A        = table6_7A(1,i)';
table6_7A    = table6_7A(2:n,i);

xcfix        = table6_7A(2,:)';
xppfix       = table6_7A(6,:)'+table6_7A(7,:)';
xhhfix       = table6_7A(9,:)';
xnpfix       = table6_7A(8,:)';
xtefix       = table6_7A(10,:)';
xncfix       = xppfix+xhhfix+xnpfix+xtefix;

%
% FOF Table F6 Gross domestic product
%

load FOF/atabs/atab6d.dat
atab6dA      = (qtr2ann(atab6d))';
[n,m]        = size(atab6dA);
t            = atab6dA(1,:);
i            = find(t==t0):find(t==t1);
atab6dA      = atab6dA(2:n,i)/1000;

cgpdif       = sum(atab6dA([10,13,16,18],:))'+.1*atab6dA(12,:)';
npgpdif      = atab6dA(9,:)';
hhgpdif      = atab6dA(15,:)';
ncgpdif      = sum(atab6dA([11,17],:))'+.9*atab6dA(12,:)';

cgpdii       = atab6dA(20,:)'+.1*atab6dA(22,:)';
ncgpdii      = atab6dA(21,:)'+.9*atab6dA(22,:)';


%
% FOF Table F10 Measures of personal saving (Quarterly, Mil$)
%
load FOF/atabs/atab10d.dat
atab10dA     = (qtr2ann(atab10d))';
[n,m]        = size(atab10dA);
t            = atab10dA(1,:);
i            = find(t==t0):find(t==t1);
atab10dA     = atab10dA(2:n,i)/1000;

cddep        = atab10dA(27,:)';

%
% FOF Table B100 Balance sheet of households (Quarterly, Bil$)
%

load FOF/btabs/btab100d.dat
btab100dA    = (qtr2ann(btab100d,1))';
[n,m]        = size(btab100dA);
t            = btab100dA(1,:);
i            = find(t==t0):find(t==t1);
btab100dA    = btab100dA(2:n,i);

hhland       = btab100dA(3,:)'-btab100dA(43,:)'-btab100dA(47,:)';

%
% FOF Table B102 Balance sheet of nonfarm nonfin. corporate (Quarterly, Bil$)
%

load FOF/btabs/btab102d.dat
btab102dA    = (qtr2ann(btab102d,1))';
[n,m]        = size(btab102dA);
t            = btab102dA(1,:);
i            = find(t==t0):find(t==t1);
btab102dA    = btab102dA(2:n,i);

cland        = btab102dA(3,:)'-btab102dA(33,:)'-btab102dA(34,:)';

%
% FOF Table B103 Balance sheet of nonfarm noncorporate (Quarterly, Bil$)
%

load FOF/btabs/btab103d.dat
btab103dA    = (qtr2ann(btab103d,1))';
[n,m]        = size(btab103dA);
t            = btab103dA(1,:);
i            = find(t==t0):find(t==t1);
btab103dA    = btab103dA(2:n,i);

nfbland      = btab103dA(3,:)'-btab103dA(32,:)'-btab103dA(33,:)';

land         = hhland+cland+nfbland;
k            = kfix+kcinv+kncinv+kcd+land;

%
% FOF Table R100 Change in household net worth (Quarterly, Bil$)
%

load FOF/btabs/rtab100d.dat
rtab100dA    = (qtr2ann(rtab100d))';
[n,m]        = size(rtab100dA);
t            = rtab100dA(1,:);
i            = find(t==t0):find(t==t1);
rtab100dA    = rtab100dA(2:n,i)*4;
rtab100dQ    = rtab100d(:,2:n)';
nholdgain    = rtab100dA(9,:)'-rtab100dA(10,:)';

load BEA/NIPA/table1_1_9Q.dat
t            = table1_1_9Q(1,:);
tq           = table1_1_9Q(2,:);
i            = find(t==1952 & tq==1);
j            = find(t==2005 & tq==1);
dgdpq        = table1_1_9Q(3,i:j)';
gdpq         = atab6d(:,2);
nholdgainq   = rtab100dQ(9,:)'-rtab100dQ(10,:)';
sumholdgain  = cumsum(nholdgainq);
rholdgainq   = sumholdgain./dgdpq*100;
rholdgainq   = rholdgainq-[0;rholdgainq(1:length(rholdgainq)-1)];
tem          = (qtr2ann([rtab100d(:,1),rholdgainq]));
i            = find(tem(:,1)==t0):find(tem(:,1)==t1);
rholdgain    = tem(i,2);
rgdp         = gdp./dgdp0;

%
% CPS population and hours
%

load CPS/monthly/Hours.csv
hcps         = (qtr2ann(Hours(:,[1,9])))';
t            = hcps(1,:);
i            = find(t==t0):find(t==t1);
hcps         = hcps(2,i)'/52;

pcps         = (qtr2ann(Hours(:,[1,4])))';
t            = pcps(1,:);
i            = find(t==t0):find(t==t1);
pcps         = pcps(2,i)';
pcps         = pcps/pcps(1);

load CPS/march/cps.out
t            = cps(:,1);
i            = find(t==t0):find(t==t1);
cps          = cps(i,:);
h            = cps(:,2)-cps(:,3)-cps(:,9); 
hpp          = cps(:,4);
hscorp       = cps(:,5);
hhh          = cps(:,6);
hpws         = cps(:,7);
hgov         = cps(:,8);
hnp          = hgov.*dnpcomp./(dggcomp+dgebuscomp);
hnp          = h.*dnpcomp./comp;

hssect       = hcps.* (hpp+hscorp+hpws-hnp)./h;
hosect       = hcps.* (hhh+hgov+hnp)./h;

%
% Consumption taxes
%
i            = .041;
mu1          = (cibt+dppbusibt+dopbusibt)./ibt;
mu2          = 1-mu1;
tem          = stax./(pce+i*kcd+cddep);
tauc         = tem./(1-tem);
cdtax        = tauc.*pced./(1+tauc);
cntax        = stax-cdtax; 

%
% DETRENDED TIME SERIES: C+G,X(=Xb+Xo),Xo,H(=Hb+Hs+Ho),Ho,Tauc,Tauh
%

t            = [t0:t1]';
gdp0         = gdp(1);
gamma        = .02;
grate        = (1+gamma).^[0:t1-t0]';
Ct           = (pce-pced+i*kcd+cddep-pbexp-cntax+govc+i*kgfix)./ ...
               (dgdp.*grate.*pcps)/gdp0;
Xmt          = (pced+gpdi+govi+netxm-cdtax)./(dgdp.*grate.*pcps)/gdp0;
Xot          = (hhgpdif+npgpdif+pced-cdtax+govi+netxm)./ ...
               (dgdp.*grate.*pcps)/gdp0;
Xbt          = Xmt-Xot;
Ybt          = (ssect-mu1.*stax-pbexp)./(dgdp.*grate.*pcps)/gdp0;
Wbt          = (ssectcomp+.7*ssectpinc)./(dgdp.*grate.*pcps)/gdp0;
Rbt          = (ssectprof+.3*ssectpinc+ssectrent+ssectnint-pbexp)./ ...
               (dgdp.*grate.*pcps)/gdp0;
Depbt        = ssectdep./(dgdp.*grate.*pcps)/gdp0;
IBTbt        = (ssectibt-mu1.*stax)./(dgdp.*grate.*pcps)/gdp0;
Yot          = (osect+cddep-mu2.*stax+i*kgfix+i*kcd+desc)./ ...
               (dgdp.*grate.*pcps)/gdp0;
Ymt          = Ybt+Yot;
Hmt          = hcps/100;
Hot          = hosect/100;
Tauct        = tauc;
Tauht1       = 1.6*hhdt./(gdp-dep-ibtonly)+hhss./(comp+.7*pinc);
Tauht2       = 1.6*hhdt./(gain+gdp-dep-ibtonly)+hhss./(comp+.7*pinc);



fprintf('AVERAGES RELATIVE TO GDP, %g:%g\n',t0,t1)
disp('-----------------------------------')
disp(sprintf(' Gross Domestic Income    %5.3f',mean(gdi./gdp)))
disp(sprintf('   Capital consumption    %5.3f',mean(dep./gdp)))
disp(sprintf('   IBT+transfers-subs.    %5.3f',mean(ibt./gdp)))
disp(sprintf('   Compensation           %5.3f',mean(comp./gdp)))
disp(sprintf('   Corp. Profits (adj)    %5.3f',mean(prof./gdp)))
disp(sprintf('   Proprietors'' income    %5.3f',mean(pinc./gdp)))
disp(sprintf('   Rental income          %5.3f',mean(rent./gdp)))
disp(sprintf('   Govt. Enterprises      %5.3f',mean(gprof./gdp)))
disp(sprintf('   Net interest           %5.3f',mean(nint./gdp)))
disp(' ')
disp(' ')
disp(' BY SECTOR:')
disp(sprintf('   Domestic corporate     %5.3f',mean(cgdi./gdp)))
disp(sprintf('     Capital consumption  %5.3f',mean(cdep./gdp)))
disp(sprintf('     IBT+transfers-subs.  %5.3f',mean(cibt./gdp)))
disp(sprintf('     Compensation         %5.3f',mean(ccomp./gdp)))
disp(sprintf('     Profits (adj)        %5.3f',mean(prof./gdp)))
disp(sprintf('     Net interest         %5.3f',mean(cnint./gdp)))
disp(' ')
disp(sprintf('   Proprietors/Partners   %5.3f',mean((dppbus+dppbusdep)./gdp)))
disp(sprintf('     Capital consumption  %5.3f',mean(dppbusdep./gdp)))
disp(sprintf('     IBT+transfers-subs.  %5.3f',mean(dppbusibt./gdp)))
disp(sprintf('     Compensation         %5.3f',mean(dppbuscomp./gdp)))
disp(sprintf('     Proprietors'' income  %5.3f',mean(dppbuspinc./gdp)))
disp(sprintf('     Net interest         %5.3f',mean(dppbusnint./gdp)))
disp(' ')
disp(sprintf('   Other Private          %5.3f',mean((dopbus+dopbusdep)./gdp)))
disp(sprintf('     Capital consumption  %5.3f',mean(dopbusdep./gdp)))
disp(sprintf('     IBT+transfers-subs.  %5.3f',mean(dopbusibt./gdp)))
disp(sprintf('     Compensation         %5.3f',mean(dopbuscomp./gdp)))
disp(sprintf('     Proprietors'' income  %5.3f',mean(dopbuspinc./gdp)))
disp(sprintf('     Rental income        %5.3f',mean(dopbusrent./gdp)))
disp(sprintf('     Net interest         %5.3f',mean(dopbusnint./gdp)))
disp(' ')
disp(sprintf('   Govt. Enterprises      %5.3f',mean((dgebus+dgebusdep)./gdp)))
disp(sprintf('     Capital consumption  %5.3f',mean(dgebusdep./gdp)))
disp(sprintf('     Compensation         %5.3f',mean(dgebuscomp./gdp)))
disp(sprintf('     Profits              %5.3f',mean(dgebusgprof./gdp)))
disp(' ')
disp(sprintf('   Households             %5.3f',mean((dhh+dhhdep)./gdp)))
disp(sprintf('     Capital consumption  %5.3f',mean(dhhdep./gdp)))
disp(sprintf('     IBT+transfers-subs.  %5.3f',mean(dhhibt./gdp)))
disp(sprintf('     Compensation         %5.3f',mean(dhhcomp./gdp)))
disp(sprintf('     Rental income        %5.3f',mean(dhhrent./gdp)))
disp(sprintf('     Net interest         %5.3f',mean(dhhnint./gdp)))
disp(' ')
disp(sprintf('   Nonprofits             %5.3f',mean((dnp+dnpdep)./gdp)))
disp(sprintf('     Capital consumption  %5.3f',mean(dnpdep./gdp)))
disp(sprintf('     IBT+transfers-subs.  %5.3f',mean(dnpibt./gdp)))
disp(sprintf('     Compensation         %5.3f',mean(dnpcomp./gdp)))
disp(sprintf('     Rental income        %5.3f',mean(dnprent./gdp)))
disp(sprintf('     Net interest         %5.3f',mean(dnpnint./gdp)))
disp(' ')
disp(sprintf('   General Govt.          %5.3f',mean((dgg+dggdep)./gdp)))
disp(sprintf('     Capital consumption  %5.3f',mean(dggdep./gdp)))
disp(sprintf('     Compensation         %5.3f',mean(dggcomp./gdp)))
disp(' ')
disp(sprintf(' Statistical desc.        %5.3f',mean(desc./gdp)))
disp(' ')
disp(sprintf(' GDI                      %5.3f',mean(gdi./gdp)))
disp(' ')
disp(sprintf(' Income, Rest of World    %5.3f',mean(row./gdp)))
disp(sprintf('   Compensation          %6.3f',mean(rowcomp./gdp)))
disp(sprintf('   Profits                %5.3f',mean(rowprof./gdp)))
disp(sprintf('   Net interest          %6.3f',mean(rownint./gdp)))
disp(' ')
disp(' ')
disp(' ')
disp(' GDI, BY OUR CATEGORIZATION:')
disp(' ')
disp(sprintf('   Corp+Priv. NC Bus.     %5.3f',mean(ssect./gdp)))
disp(sprintf('     Capital consumption  %5.3f',mean(ssectdep./gdp)))
disp(sprintf('     IBT+transfers-subs.  %5.3f',mean(ssectibt./gdp)))
disp(sprintf('     Compensation         %5.3f',mean(ssectcomp./gdp)))
disp(sprintf('     Profits              %5.3f',mean(ssectprof./gdp)))
disp(sprintf('     Proprietors'' income  %5.3f',mean(ssectpinc./gdp)))
disp(sprintf('     Rental income        %5.3f',mean(ssectrent./gdp)))
disp(sprintf('     Net interest         %5.3f',mean(ssectnint./gdp)))
disp(' ')
disp(sprintf('   HH+NP+Govt.            %5.3f',mean(osect./gdp)))
disp(sprintf('     Capital consumption  %5.3f',mean(osectdep./gdp)))
disp(sprintf('     IBT+transfers-subs.  %5.3f',mean(osectibt./gdp)))
disp(sprintf('     Compensation         %5.3f',mean(osectcomp./gdp)))
disp(sprintf('     Profits              %5.3f',mean(osectprof./gdp)))
disp(sprintf('     Proprietors'' income  %5.3f',mean(osectpinc./gdp)))
disp(sprintf('     Rental income        %5.3f',mean(osectrent./gdp)))
disp(sprintf('     Net interest         %5.3f',mean(osectnint./gdp)))
disp(' ')
disp(' ')
disp(' DOMESTIC PRODUCT:')
disp(' ')
disp(sprintf('   Private consumption    %5.3f',mean(pce./gdp)))
disp(sprintf('     Nondurable+Service   %5.3f',mean((pce-pced)./gdp)))
disp(sprintf('     Durable              %5.3f',mean(pced./gdp)))
disp(sprintf('   Investment             %5.3f',mean(gpdi./gdp)))
disp(sprintf('     Corporate tangible   %5.3f',mean((cgpdif+cgpdii)./gdp)))
disp(sprintf('       Fixed              %5.3f',mean(cgpdif./gdp)))
disp(sprintf('       Inventory          %5.3f',mean(cgpdii./gdp)))
disp(sprintf('     Noncorporate bus     %5.3f',mean((ncgpdif+ncgpdii)./gdp)))
disp(sprintf('       Fixed              %5.3f',mean(ncgpdif./gdp)))
disp(sprintf('       Inventory          %5.3f',mean(ncgpdii./gdp)))
disp(sprintf('     Household            %5.3f',mean(hhgpdif./gdp)))
disp(sprintf('     Nonprofits           %5.3f',mean(npgpdif./gdp)))
disp(sprintf('   Govt. consumption      %5.3f',mean(govc./gdp)))
disp(sprintf('   Govt. investment       %5.3f',mean(govi./gdp)))
disp(sprintf('   Net Exports           %6.3f',mean(netxm./gdp)))
disp(' ')
disp(sprintf(' GDP                      %5.3f',mean(gdp./gdp)))
disp(' ')
disp(' ')
disp(' DOMESTIC PRODUCT, BY OUR CATEGORIZATION: ')
disp(' ')
disp(sprintf('   Private cons (nd+s)    %5.3f',mean((pce-pced)./gdp)))
disp(sprintf('   Govt. consumption      %5.3f',mean(govc./gdp)))
disp(sprintf('   Tangible investment    %5.3f',mean((pced+gpdi+govi+ ...
   netxm)./gdp)))
disp(sprintf('     Corporate            %5.3f',mean((cgpdif+cgpdii)./gdp)))
disp(sprintf('       Fixed              %5.3f',mean(cgpdif./gdp)))
disp(sprintf('       Inventory          %5.3f',mean(cgpdii./gdp)))
disp(sprintf('     Noncorporate bus     %5.3f',mean((ncgpdif+ncgpdii)./gdp)))
disp(sprintf('       Fixed              %5.3f',mean(ncgpdif./gdp)))
disp(sprintf('       Inventory          %5.3f',mean(ncgpdii./gdp)))
disp(sprintf('     Household            %5.3f',mean(hhgpdif./gdp)))
disp(sprintf('     Consumer durables    %5.3f',mean(pced./gdp)))
disp(sprintf('     Nonprofits           %5.3f',mean(npgpdif./gdp)))
disp(sprintf('     Govt. investment     %5.3f',mean(govi./gdp)))
disp(sprintf('     Net Exports         %6.3f',mean(netxm./gdp)))
disp(' ')
disp(sprintf(' GDP                      %5.3f',mean(gdp./gdp)))
disp(' ')
disp(' ')
disp(' DOMESTIC CAPITAL:')
disp(' ')
disp(sprintf('   Corporate              %5.3f',mean((kcfix+kcinv+cland)./gdp)))
disp(sprintf('     Fixed                %5.3f',mean(kcfix./gdp)))
disp(sprintf('     Inventory            %5.3f',mean(kcinv./gdp)))
disp(sprintf('     Nonfarm land         %5.3f',mean(cland./gdp)))
disp(sprintf('   Noncorporate           %5.3f',mean((kppfix+ktefix+kncinv+ ...
   nfbland)./gdp)))
disp(sprintf('     Fixed,Proprietors    %5.3f',mean(kppfix./gdp)))
disp(sprintf('     Fixed,Tax-exempt     %5.3f',mean(ktefix./gdp)))
disp(sprintf('     Inventory            %5.3f',mean(kncinv./gdp)))
disp(sprintf('     Nonfarm land         %5.3f',mean(nfbland./gdp)))
disp(sprintf('   Farm land (estimate)   %5.3f',.08))
disp(sprintf('   Household              %5.3f',mean((khhfix+hhland)./gdp)))
disp(sprintf('     Fixed                %5.3f',mean(khhfix./gdp)))
disp(sprintf('     Land                 %5.3f',mean(hhland./gdp)))
disp(sprintf('   Nonprofits             %5.3f',mean(knpfix./gdp)))
disp(sprintf('   Government             %5.3f',mean(kgfix./gdp)))
disp(sprintf('   Consumer durables      %5.3f',mean(kcd./gdp)))
disp(' ')
disp(sprintf(' Total                    %5.3f',mean(k./gdp)+.08))
disp(' ')
disp(' ')
disp(' CHECK: NIPA vs. FA Fixed Investment')
disp('   Total ')
disp(sprintf('     NIPA                 %5.3f',mean((gpdif+pced+govi)./gdp)))
disp(sprintf('     FA                   %5.3f',mean((xfix+xcd)./gdp)))
disp('   Corporate tangible     ')
disp(sprintf('     NIPA                 %5.3f',mean(cgpdif./gdp)))
disp(sprintf('     FA                   %5.3f',mean(xcfix./gdp)))
disp('   Noncorporate business ')
disp(sprintf('     NIPA                 %5.3f',mean(ncgpdif./gdp)))
disp(sprintf('     FA-Proprietors       %5.3f',mean(xppfix./gdp)))
disp(sprintf('     FA-Tax-exempt        %5.3f',mean(xtefix./gdp)))
disp('   Government ')
disp(sprintf('     NIPA                 %5.3f',mean(govi./gdp)))
disp(sprintf('     FA                   %5.3f',mean(xgfix./gdp)))
disp('   Consumer durables')
disp(sprintf('     NIPA                 %5.3f',mean(pced./gdp)))
disp(sprintf('     FA                   %5.3f',mean(xcd./gdp)))
disp('   Household ')
disp(sprintf('     NIPA                 %5.3f',mean(hhgpdif./gdp)))
disp(sprintf('     FA                   %5.3f',mean(xhhfix./gdp)))
disp('   Nonprofits')
disp(sprintf('     NIPA                 %5.3f',mean(npgpdif./gdp)))
disp(sprintf('     FA                   %5.3f',mean(xnpfix./gdp)))
disp(' ')
disp(' ')
disp(' ADDENDUM:')
disp(sprintf(' Foreign After-tax Prof.  %5.3f',mean((natprof-prof)./gdp)))
disp(sprintf(' Consumer durable dep.    %5.3f',mean(cddep./gdp)))
disp(sprintf(' IBT only                 %5.3f',mean(ibtonly./gdp)))
disp(sprintf('   Sales+other            %5.3f',mean(stax./gdp)))
disp(sprintf('   Property               %5.3f',mean(ptax./gdp)))
disp(sprintf(' Intermediate Fin. Ser.   %5.3f',mean(pbexp./gdp)))
disp(sprintf(' Net dividends            %5.3f',mean(ndiv./gdp)))
disp(sprintf(' Retained Earnings        %5.3f',mean(rete./gdp)))
disp(sprintf(' Dom. BT Profits (wo/adj) %5.3f',mean(pbtd./gdp)))
disp(sprintf(' Dom. AT Profits (wo/adj) %5.3f',mean(patd./gdp)))
disp(sprintf(' Federal Reserve Profits  %5.3f',mean(fedres./gdp)))
disp(sprintf(' Corporate tax liability  %5.3f',mean(ctax./gdp)))
disp(' ')
disp(' ')
disp('MAKE ADJUSTMENTS TO THE ACCOUNTS:')
disp(' ')

disp(' 1. Remove sales tax from consumption and IBT')
disp(' 2. Add private and public consumption services')
disp(' 3. Remove intermediate services')
disp(' ')
disp(' ')


fprintf('ADJUSTED AVERAGES, %g:%g\n',t0,t1)
disp('----------------------------')
disp(' ')
disp(sprintf(' Corp+Priv. NC Bus.       %5.3f',mean((ssect-mu1.*stax- ...
   pbexp)./gdp)))
disp(sprintf('   Capital consumption    %5.3f',mean(ssectdep./gdp)))
disp(sprintf('   Adjusted IBT           %5.3f',mean((ssectibt-mu1.*stax)./gdp)))
disp(sprintf('     IBT+transfers-subs.  %5.3f',mean(ssectibt./gdp)))
disp(sprintf('     Less: sales tax      %5.3f',mean(mu1.*stax./gdp)))
disp(sprintf('   Compensation           %5.3f',mean((ssectcomp+ ...
   .7*ssectpinc)./gdp)))
disp(sprintf('     Wage and salary      %5.3f',mean(ssectcomp./gdp)))
disp(sprintf('     70%% Prop. income     %5.3f',mean(.7*ssectpinc./gdp)))
disp(sprintf('   Profits                %5.3f',mean((ssectprof+ ...
   .3*ssectpinc+ssectrent+ssectnint-pbexp)./gdp)))
disp(sprintf('     Corp. Profits        %5.3f',mean(ssectprof./gdp)))
disp(sprintf('     30%% Prop. income     %5.3f',mean(.3*ssectpinc./gdp)))
disp(sprintf('     Rental income        %5.3f',mean(ssectrent./gdp)))
disp(sprintf('     Adjusted net int.    %5.3f',mean((ssectnint-pbexp)./gdp)))
disp(sprintf('       Net interest       %5.3f',mean(ssectnint./gdp)))
disp(sprintf('       Less: int.fin.ser. %5.3f',mean(pbexp./gdp)))
disp(' ')
disp(sprintf(' HH+NP+Govt.              %5.3f',mean((osect+cddep- ...
   mu2.*stax+i*kgfix+i*kcd+desc)./gdp)))
disp(sprintf('   Adjusted Capital cons. %5.3f',mean((osectdep+cddep)./gdp)))
disp(sprintf('     Capital consumption  %5.3f',mean(osectdep./gdp)))
disp(sprintf('     Plus: durable dep    %5.3f',mean(cddep./gdp)))
disp(sprintf('   Adjusted IBT           %5.3f',mean((osectibt-mu2.*stax)./gdp)))
disp(sprintf('     IBT+transfers-subs.  %5.3f',mean(osectibt./gdp)))
disp(sprintf('     Less: sales tax      %5.3f',mean(mu2.*stax./gdp)))
disp(sprintf('   Compensation           %5.3f',mean((osectcomp+ ...
   .7*osectpinc+desc)./gdp)))
disp(sprintf('     Wage and salary      %5.3f',mean(osectcomp./gdp)))
disp(sprintf('     70%% Prop. inc.       %5.3f',mean(.7*osectpinc./gdp)))
disp(sprintf('     Statistical desc.    %5.3f',mean(desc./gdp)))
disp(sprintf('   Profits                %5.3f',mean((osectprof+ ...
   .3*osectprof+osectrent+osectnint+i*kgfix+i*kcd)./gdp)))
disp(sprintf('     Govt. Enterprises    %5.3f',mean(osectprof./gdp)))
disp(sprintf('     30%% Prop. inc.       %5.3f',mean(.3*osectpinc./gdp)))
disp(sprintf('     Rental income        %5.3f',mean(osectrent./gdp)))
disp(sprintf('     Net interest         %5.3f',mean(osectnint./gdp)))
disp(sprintf('     Imputed services     %5.3f',i*mean((kgfix+kcd)./gdp)))
disp(' ')
disp(sprintf(' Total income             %5.3f',mean((gdp-stax-pbexp+cddep+ ...
   i*kcd+i*kgfix)./gdp)))
disp(' ')
disp(' ')
disp(sprintf(' Adjusted private cons    %5.3f',mean((pce-pced+i*kcd+ ...
   cddep-pbexp-cntax)./gdp)))
disp(sprintf('   Nondurable+services    %5.3f',mean((pce-pced)./gdp)))
disp(sprintf('   Plus: imputed service  %5.3f',mean(i*kcd./gdp)))
disp(sprintf('   Plus: durable dep      %5.3f',mean(cddep./gdp)))
disp(sprintf('   Less: int.fin.ser.     %5.3f',mean(pbexp./gdp)))
disp(sprintf('   Less: sales tax        %5.3f',mean(cntax./gdp)))
disp(sprintf(' Adjusted govt. cons      %5.3f',mean((govc+i*kgfix)./gdp)))
disp(sprintf('   Govt. consumption      %5.3f',mean(govc./gdp)))
disp(sprintf('   Plus: imputed service  %5.3f',mean(i*kgfix./gdp)))
disp(sprintf(' Tangible investment      %5.3f',mean((pced+gpdi+govi+ ...
   netxm-cdtax)./gdp)))
disp(sprintf('   Corporate tangible     %5.3f',mean((cgpdif+cgpdii)./gdp)))
disp(sprintf('     Fixed                %5.3f',mean(cgpdif./gdp)))
disp(sprintf('     Inventory            %5.3f',mean(cgpdii./gdp)))
disp(sprintf('   Noncorporate bus       %5.3f',mean((ncgpdif+ncgpdii)./gdp)))
disp(sprintf('     Fixed                %5.3f',mean(ncgpdif./gdp)))
disp(sprintf('     Inventory            %5.3f',mean(ncgpdii./gdp)))
disp(sprintf('   Household              %5.3f',mean(hhgpdif./gdp)))
disp(sprintf('   Nonprofits             %5.3f',mean(npgpdif./gdp)))
disp(sprintf('   Adjusted durable inv   %5.3f',mean((pced-cdtax)./gdp)))
disp(sprintf('     Consumer durables    %5.3f',mean(pced./gdp)))
disp(sprintf('     Less: sales tax      %5.3f',mean(cdtax./gdp)))
disp(sprintf('   Govt. investment       %5.3f',mean(govi./gdp)))
disp(sprintf('   Net Exports           %6.3f',mean(netxm./gdp)))
disp(' ')
disp(sprintf(' Total product            %5.3f',mean((gdp-stax-pbexp+cddep+ ...
   i*kcd+i*kgfix)./gdp)))
disp(' ')
disp(' ')
disp(' CONTRIBUTIONS TO AVERAGE WEEKLY HOURS ')
disp(sprintf('   Corp+Priv. NC Bus.    %6.3f',mean(hssect)))
disp(sprintf('   HH+NP+Govt.            %5.3f',mean(hosect)))
disp(' ')
disp(sprintf(' Avg, Non-inst pop       %6.3f',mean(hcps)))

disp(' ')
disp(' ')
disp(' TAX RATES ')
disp(sprintf('   Consumption            %5.3f',mean(Tauct)))
disp(sprintf('   Labor                  %5.3f',mean(Tauht1)))
disp(sprintf('   Labor -- excl. gains   %5.3f',mean(Tauht2)))


OBS          = [t,[Ymt,Yot,Ct,Xmt,Xot]/Ymt(1),Hmt,Hot,Tauct,Tauht1,Tauht2];

%
% Extrapolate back and forward
%
                                                                                
nt           = t1-t0+1;
OBS          = [t0-2,OBS(1,2:11);
                t0-1,OBS(1,2:11);
                OBS];
%tem          = [[t1:t1+4]',linspace(Ymt(nt)/Ymt(1),1,5)', ...
%                           linspace(Yot(nt)/Ymt(1),Yot(1)/Ymt(1),5)', ...
%                           linspace(Ct(nt)/Ymt(1),Ct(1)/Ymt(1),5)', ...
%                           linspace(Xmt(nt)/Ymt(1),Xmt(1)/Ymt(1),5)', ...
%                           linspace(Xot(nt)/Ymt(1),Xot(1)/Ymt(1),5)', ...
%                           linspace(Hmt(nt),Hmt(1),5)', ...
%                           linspace(Hot(nt),Hot(1),5)', ...
%                           linspace(Tauct(nt),Tauct(1),5)', ...
%                           linspace(Tauht1(nt),Tauht1(1),5)', ...
%                           linspace(Tauht2(nt),Tauht2(1),5)'];
%OBS          = [OBS;tem(2:5,:)];
%OBS          = [OBS;ones(33-length(OBS),1)*OBS(length(OBS),:)];
%OBS(:,1)     = linspace(OBS(1,1),OBS(1,1)+32,33)';

disp(' ')
disp(' ')
disp(' ')
disp('========================================================================')
disp(sprintf('  TIME SERIES for %g:%g (extrapolating other years) ',t0,t1))
disp('========================================================================')
disp(' ')
disp(' Year   Ym     Yo    C+G    Xm    Xo    Hm    Ho Cons-Tax   Labor Taxes ')
disp('                                                          w/gain wo/gain')
disp(' ')
fprintf('%5g%7.4f%7.4f%7.4f%7.4f%7.4f%7.4f%7.4f%7.4f%7.4f%7.4f\n',OBS')

                                                                                
