%ACCOUNTS    Accounting used for Sweat Equity project
%
%

%
% Sample t0:t1
%

yr0          = 2004;
qr0          = 1;
yr1          = 2011;
qr1          = 3;
yr1          = 2004;
qr1          = 4;
t            = ptime(yr0+qr0/10,(yr1-yr0)*4+qr1-qr0+1,4);
lt           = length(t);

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

load BEA/NIPA/table1_1_5Q.dat
[n,m]        = size(table1_1_5Q);
yr           = table1_1_5Q(1,:);
qr           = table1_1_5Q(2,:);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
table1_1_5Q  = table1_1_5Q(3:n,i);

gdp          = table1_1_5Q(1,:)';
pce          = table1_1_5Q(2,:)';
pced         = table1_1_5Q(4,:)';
pcend        = table1_1_5Q(5,:)';
pces         = table1_1_5Q(6,:)';
gpdi         = table1_1_5Q(7,:)';
gpdif        = table1_1_5Q(8,:)';
gpdii        = table1_1_5Q(13,:)';
netxm        = table1_1_5Q(14,:)';
netx         = table1_1_5Q(15,:)';
netm         = table1_1_5Q(18,:)';
gov          = table1_1_5Q(21,:)';

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

load BEA/NIPA/table1_1_9Q.dat
[n,m]        = size(table1_1_9Q);
yr           = table1_1_9Q(1,:);
qr           = table1_1_9Q(2,:);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
table1_1_9Q  = table1_1_9Q(3:n,i);

dgdp0        = table1_1_9Q(1,:)';
dgdp         = dgdp0/mean(dgdp0(1:4));
rgdp         = gdp./dgdp0;

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

load BEA/NIPA/table1_10Q.dat
[n,m]        = size(table1_10Q);
yr           = table1_10Q(1,:);
qr           = table1_10Q(2,:);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
table1_10Q   = table1_10Q(3:n,i);

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

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

load BEA/NIPA/table1_12Q.dat
[n,m]        = size(table1_12Q);
yr           = table1_12Q(1,:);
qr           = table1_12Q(2,:);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
table1_12Q   = table1_12Q(3:n,i);

natprof      = table1_12Q(13,:)';

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

load BEA/NIPA/table1_13A.dat
[n,m]        = size(table1_13A);
table1_13A   = [table1_13A,table1_13A(:,m).^2./table1_13A(:,m-1)];
table1_13Q   = (ann2qtr(table1_13A',3,1))';
[n,m]        = size(table1_13Q);
yr           = floor(table1_13Q(1,:));
qr           = round((table1_13Q(1,:)-floor(table1_13Q(1,:)))*10);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
table1_13Q   = table1_13Q(2:n,i);

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

ssectcomp    = dcbuscomp+dppbuscomp+dopbuscomp;
ssectprof    = dcbusprof;
ssectrent    = dopbusrent;
ssectpinc    = dppbuspinc+dopbuspinc;
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 (Quarterly, Bil$)
%

load BEA/NIPA/table1_14Q.dat
[n,m]        = size(table1_14Q);
yr           = table1_14Q(1,:);
qr           = table1_14Q(2,:);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
table1_14Q   = table1_14Q(3:n,i);

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

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

load BEA/NIPA/table3_1Q.dat
[n,m]        = size(table3_1Q);
yr           = table3_1Q(1,:);
qr           = table3_1Q(2,:);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
table3_1Q    = table3_1Q(3:n,i);

govc         = table3_1Q(16,:)';
govi         = table3_1Q(35,:)';
ibtonly      = table3_1Q(4,:)';

%
% NIPA Table 3.2 Federal govt current receipts & expenditures (Quarterly, Bil$)
%

load BEA/NIPA/table3_2Q.dat
[n,m]        = size(table3_2Q);
yr           = table3_2Q(1,:);
qr           = table3_2Q(2,:);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
table3_2Q    = table3_2Q(3:n,i);

fedstax      = table3_2Q(4,:)';
fedres       = table3_2Q(8,:)';

%
% NIPA Table 3.2 State/Local current receipts & expenditures (Quarterly, Bil$)
%

load BEA/NIPA/table3_3Q.dat
[n,m]        = size(table3_3Q);
yr           = table3_3Q(1,:);
qr           = table3_3Q(2,:);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
table3_3Q    = table3_3Q(3:n,i);

stlstax      = table3_3Q(7,:)'+table3_3Q(9,:)';
ptax         = table3_3Q(8,:)';
stax         = fedstax+stlstax;

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

load BEA/NIPA/table5_7_5AQ.dat
load BEA/NIPA/table5_7_5BQ.dat
[n,m]        = size(table5_7_5BQ);
table5_7_5BQ = table5_7_5BQ(:,4:m);
i            = find((table5_7_5AQ(1,:)==table5_7_5BQ(1,1)) & ...
                    (table5_7_5AQ(2,:)==table5_7_5BQ(2,1)));
table5_7_5Q  = [table5_7_5AQ(1:4,1:i-1),table5_7_5BQ(1:4,:)];
[n,m]        = size(table5_7_5Q);
yr           = table5_7_5Q(1,:);
qr           = table5_7_5Q(2,:);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
table5_7_5Q  = table5_7_5Q(3:n,i);

kcinv        = table5_7_5Q(1,:)'-.9*table5_7_5Q(2,:)';
kncinv       = .9*table5_7_5Q(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);
table7_5A    = [table7_5A,table7_5A(:,m).^2./table7_5A(:,m-1)];
table7_5Q    = (ann2qtr(table7_5A',3,1))';
[n,m]        = size(table7_5Q);
yr           = floor(table7_5Q(1,:));
qr           = round((table7_5Q(1,:)-floor(table7_5Q(1,:)))*10);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
table7_5Q    = table7_5Q(2:n,i);

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

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

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

load BEA/FA/table1_1A.dat
[n,m]        = size(table1_1A);
table1_1A    = [table1_1A,table1_1A(:,m).^2./table1_1A(:,m-1)];
table1_1Q    = (ann2qtr(table1_1A',3,1))';
[n,m]        = size(table1_1Q);
yr           = floor(table1_1Q(1,:));
qr           = round((table1_1Q(1,:)-floor(table1_1Q(1,:)))*10);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
table1_1Q    = table1_1Q(2:n,i);

kfix         = table1_1Q(2,:)';
kpfixnrst    = table1_1Q(6,:)';
kpfixres     = table1_1Q(7,:)';
kgfix        = table1_1Q(8,:)';
kcd          = table1_1Q(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);
table6_1A    = [table6_1A,table6_1A(:,m).^2./table6_1A(:,m-1)];
table6_1Q    = (ann2qtr(table6_1A',3,1))';
[n,m]        = size(table6_1Q);
yr           = floor(table6_1Q(1,:));
qr           = round((table6_1Q(1,:)-floor(table6_1Q(1,:)))*10);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
table6_1Q    = table6_1Q(2:n,i);

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

%
% FOF Table F6 Gross domestic product
%

load FOF/atabs/atab6d.dat
[n,m]        = size(atab6d);
yr           = floor(atab6d(:,1));
qr           = round((atab6d(:,1)-floor(atab6d(:,1)))*10);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
atab6d       = atab6d(i,2:m)/1000;

cgpdif       = sum(atab6d(:,[10,13,16,18])')'+.1*atab6d(:,12);
npgpdif      = atab6d(:,9);
hhgpdif      = atab6d(:,15);
ncgpdif      = sum(atab6d(:,[11,17])')'+.9*atab6d(:,12);
cgpdii       = atab6d(:,20)+.1*atab6d(:,22);
ncgpdii      = atab6d(:,21)+.9*atab6d(:,22);


%
% FOF Table F10 Measures of personal saving (Quarterly, Mil$)
%
load FOF/atabs/atab10d.dat
[n,m]        = size(atab10d);
yr           = floor(atab10d(:,1));
qr           = round((atab10d(:,1)-floor(atab10d(:,1)))*10);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
atab10d      = atab10d(i,2:m)/1000;

cddep        = atab10d(:,27);

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

load FOF/btabs/btab100d.dat
[n,m]        = size(btab100d);
yr           = floor(btab100d(:,1));
qr           = round((btab100d(:,1)-floor(btab100d(:,1)))*10);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
btab100d     = btab100d(i,2:m)/1000;

hhland       = btab100d(:,3)-btab100d(:,43)-btab100d(:,46);

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

load FOF/btabs/btab102d.dat
[n,m]        = size(btab102d);
yr           = floor(btab102d(:,1));
qr           = round((btab102d(:,1)-floor(btab102d(:,1)))*10);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
btab102d     = btab102d(i,2:m)/1000;

cland        = btab102d(:,3)-btab102d(:,33)-btab102d(:,34);

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

load FOF/btabs/btab103d.dat
[n,m]        = size(btab103d);
yr           = floor(btab103d(:,1));
qr           = round((btab103d(:,1)-floor(btab103d(:,1)))*10);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
btab103d     = btab103d(i,2:m)/1000;

nfbland      = btab103d(:,3)-btab103d(:,32)-btab103d(:,33);
knfbinv      = btab103d(:,9);
land         = hhland+cland+nfbland;
k            = kfix+kcinv+kncinv+kcd+land;

%
% CPS population and hours
%

load CPS/avghrsq.dat
load CPS/busprdq.dat
[n,m]        = size(avghrsq);
yr           = avghrsq(:,1);
qr           = avghrsq(:,2);
t05          = find(yr==2005 & qr==4);
pcps05       = avghrsq(t05,5)/10^6;
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
hcps         = avghrsq(i,9);
pcps         = avghrsq(i,5)/10^6;

[n,m]        = size(busprdq);
yr           = busprdq(:,1);
qr           = busprdq(:,2);
hbus         = busprdq(:,3);
t05          = find(yr==2005 & qr==4);
hbus05       = busprdq(t05,3);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));
hbus         = hbus(i)./pcps *pcps05/hbus05;  % = 1 in 2005:4
hssect       = hbus * 188.846/228.971 *(1+2103/136218)* .28019;
                  % (private/total hrs)(1+ag/total at work) * per cap hrs
hosect       = hcps-hssect;

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

%
% Labor taxes
%

load TAX/barro.dat
yr           = barro(:,1);
tauhq        = ann2qtr(barro(:,1:2),3,1);
[n,m]        = size(tauhq);
yr           = floor(tauhq(:,1));
qr           = round((tauhq(:,1)-floor(tauhq(:,1)))*10);
i            = find((yr==yr0) & (qr==qr0)):find((yr==yr1) & (qr==qr1));

tauh         = tauhq(i,2);

%
% Capital taxes
%
tauk         = ptax./(kpfixres+kpfixnrst+land);
taukb        = (ibt-dhhibt-dnpibt-stax)./(kcfix+kppfix+kcinv+knfbinv+ ...
                cland+nfbland);
taup         = (ctax-fedres)./(pbtd-fedres);

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

gdp0         = mean(gdp(1:4));
gamma        = 1.019.^(1/4)-1;
grate        = (1+gamma).^[0:lt-1]';
grate        = grate/mean(grate(1:4));
Ct           = (pce-pced+irate*kcd+cddep-cntax+govc+irate*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;
Ymt          = (gdp+cddep+irate*kgfix+irate*kcd-stax)./ ...
               (dgdp.*grate.*pcps)/gdp0;
Wbt          = (ssectcomp+.7*ssectpinc)./(dgdp.*grate.*pcps)/gdp0;
Rbt          = (ssectprof+.3*ssectpinc+ssectrent+ssectnint)./ ...
               (dgdp.*grate.*pcps)/gdp0;
Depbt        = ssectdep./(dgdp.*grate.*pcps)/gdp0;
IBTbt        = (ssectibt-mu1.*stax)./(dgdp.*grate.*pcps)/gdp0;
Yot          = (osect+cddep-mu2.*stax+irate*kgfix+irate*kcd+desc)./ ...
               (dgdp.*grate.*pcps)/gdp0;
Ybt          = (ssect-mu1.*stax)./(dgdp.*grate.*pcps)/gdp0;
Ybt          = Ymt-Yot;
Hmt          = hcps;
Hot          = hosect;
Tauct        = tauc;
Tauht        = tauh;
Taukt        = tauk/4;
Taukbt       = taukb/4;
Taupt        = taup;

agdp         = gdp-stax+cddep+irate*kcd+irate*kgfix;

fprintf('AVERAGES RELATIVE ADJUSTED TO GDP, %g:%g-%g:%g\n',yr0,qr0,yr1,qr1)
disp('------------------------------------------------')
disp(sprintf(' Gross Domestic Income   %6.3f',mean(gdi./agdp)))
disp(sprintf('   Capital consumption   %6.3f',mean(dep./agdp)))
disp(sprintf('   IBT+transfers-subs.   %6.3f',mean(ibt./agdp)))
disp(sprintf('   Compensation          %6.3f',mean(comp./agdp)))
disp(sprintf('   Corp. Profits (adj)   %6.3f',mean(prof./agdp)))
disp(sprintf('   Proprietors'' income   %6.3f',mean(pinc./agdp)))
disp(sprintf('   Rental income         %6.3f',mean(rent./agdp)))
disp(sprintf('   Govt. Enterprises     %6.3f',mean(gprof./agdp)))
disp(sprintf('   Net interest          %6.3f',mean(nint./agdp)))
disp(' ')
disp(' ')
disp(' BY SECTOR:')
disp(sprintf('   Domestic corporate    %6.3f',mean(cgdi./agdp)))
disp(sprintf('     Capital consumption %6.3f',mean(cdep./agdp)))
disp(sprintf('     IBT+transfers-subs. %6.3f',mean(cibt./agdp)))
disp(sprintf('     Compensation        %6.3f',mean(ccomp./agdp)))
disp(sprintf('     Profits (adj)       %6.3f',mean(prof./agdp)))
disp(sprintf('     Net interest        %6.3f',mean(cnint./agdp)))
disp(' ')
disp(sprintf('   Proprietors/Partners  %6.3f',mean((dppbus+dppbusdep)./agdp)))
disp(sprintf('     Capital consumption %6.3f',mean(dppbusdep./agdp)))
disp(sprintf('     IBT+transfers-subs. %6.3f',mean(dppbusibt./agdp)))
disp(sprintf('     Compensation        %6.3f',mean(dppbuscomp./agdp)))
disp(sprintf('     Proprietors'' income %6.3f',mean(dppbuspinc./agdp)))
disp(sprintf('     Net interest        %6.3f',mean(dppbusnint./agdp)))
disp(' ')
disp(sprintf('   Other Private         %6.3f',mean((dopbus+dopbusdep)./agdp)))
disp(sprintf('     Capital consumption %6.3f',mean(dopbusdep./agdp)))
disp(sprintf('     IBT+transfers-subs. %6.3f',mean(dopbusibt./agdp)))
disp(sprintf('     Compensation        %6.3f',mean(dopbuscomp./agdp)))
disp(sprintf('     Proprietors'' income %6.3f',mean(dopbuspinc./agdp)))
disp(sprintf('     Rental income       %6.3f',mean(dopbusrent./agdp)))
disp(sprintf('     Net interest        %6.3f',mean(dopbusnint./agdp)))
disp(' ')
disp(sprintf('   Govt. Enterprises     %6.3f',mean((dgebus+dgebusdep)./agdp)))
disp(sprintf('     Capital consumption %6.3f',mean(dgebusdep./agdp)))
disp(sprintf('     Compensation        %6.3f',mean(dgebuscomp./agdp)))
disp(sprintf('     Profits             %6.3f',mean(dgebusgprof./agdp)))
disp(' ')
disp(sprintf('   Households            %6.3f',mean((dhh+dhhdep)./agdp)))
disp(sprintf('     Capital consumption %6.3f',mean(dhhdep./agdp)))
disp(sprintf('     IBT+transfers-subs. %6.3f',mean(dhhibt./agdp)))
disp(sprintf('     Compensation        %6.3f',mean(dhhcomp./agdp)))
disp(sprintf('     Rental income       %6.3f',mean(dhhrent./agdp)))
disp(sprintf('     Net interest        %6.3f',mean(dhhnint./agdp)))
disp(' ')
disp(sprintf('   Nonprofits            %6.3f',mean((dnp+dnpdep)./agdp)))
disp(sprintf('     Capital consumption %6.3f',mean(dnpdep./agdp)))
disp(sprintf('     IBT+transfers-subs. %6.3f',mean(dnpibt./agdp)))
disp(sprintf('     Compensation        %6.3f',mean(dnpcomp./agdp)))
disp(sprintf('     Rental income       %6.3f',mean(dnprent./agdp)))
disp(sprintf('     Net interest        %6.3f',mean(dnpnint./agdp)))
disp(' ')
disp(sprintf('   General Govt.         %6.3f',mean((dgg+dggdep)./agdp)))
disp(sprintf('     Capital consumption %6.3f',mean(dggdep./agdp)))
disp(sprintf('     Compensation        %6.3f',mean(dggcomp./agdp)))
disp(' ')
disp(sprintf(' GDI                     %6.3f',mean(gdi./agdp)))
disp(' ')
disp(sprintf(' Income, Rest of World   %6.3f',mean(row./agdp)))
disp(sprintf('   Compensation          %6.3f',mean(rowcomp./agdp)))
disp(sprintf('   Profits               %6.3f',mean(rowprof./agdp)))
disp(sprintf('   Net interest          %6.3f',mean(rownint./agdp)))
disp(' ')
disp(' ')
disp(' ')
disp(' GDI, BY OUR CATEGORIZATION:')
disp(' ')
disp(sprintf('   Corp+Priv. NC Bus.    %6.3f',mean(ssect./agdp)))
disp(sprintf('     Capital consumption %6.3f',mean(ssectdep./agdp)))
disp(sprintf('     IBT+transfers-subs. %6.3f',mean(ssectibt./agdp)))
disp(sprintf('     Compensation        %6.3f',mean(ssectcomp./agdp)))
disp(sprintf('     Profits             %6.3f',mean(ssectprof./agdp)))
disp(sprintf('     Proprietors'' income %6.3f',mean(ssectpinc./agdp)))
disp(sprintf('     Rental income       %6.3f',mean(ssectrent./agdp)))
disp(sprintf('     Net interest        %6.3f',mean(ssectnint./agdp)))
disp(' ')
disp(sprintf('   HH+NP+Govt.           %6.3f',mean(osect./agdp)))
disp(sprintf('     Capital consumption %6.3f',mean(osectdep./agdp)))
disp(sprintf('     IBT+transfers-subs. %6.3f',mean(osectibt./agdp)))
disp(sprintf('     Compensation        %6.3f',mean(osectcomp./agdp)))
disp(sprintf('     Profits             %6.3f',mean(osectprof./agdp)))
disp(sprintf('     Proprietors'' income %6.3f',mean(osectpinc./agdp)))
disp(sprintf('     Rental income       %6.3f',mean(osectrent./agdp)))
disp(sprintf('     Net interest        %6.3f',mean(osectnint./agdp)))
disp(' ')
disp(' ')
disp(' DOMESTIC PRODUCT:')
disp(' ')
disp(sprintf('   Private consumption   %6.3f',mean(pce./agdp)))
disp(sprintf('     Nondurable+Service  %6.3f',mean((pce-pced)./agdp)))
disp(sprintf('     Durable             %6.3f',mean(pced./agdp)))
disp(sprintf('   Investment            %6.3f',mean(gpdi./agdp)))
disp(sprintf('     Corporate tangible  %6.3f',mean((cgpdif+cgpdii)./agdp)))
disp(sprintf('       Fixed             %6.3f',mean(cgpdif./agdp)))
disp(sprintf('       Inventory         %6.3f',mean(cgpdii./agdp)))
disp(sprintf('     Noncorporate bus    %6.3f',mean((ncgpdif+ncgpdii)./agdp)))
disp(sprintf('       Fixed             %6.3f',mean(ncgpdif./agdp)))
disp(sprintf('       Inventory         %6.3f',mean(ncgpdii./agdp)))
disp(sprintf('     Household           %6.3f',mean(hhgpdif./agdp)))
disp(sprintf('     Nonprofits          %6.3f',mean(npgpdif./agdp)))
disp(sprintf('   Govt. consumption     %6.3f',mean(govc./agdp)))
disp(sprintf('   Govt. investment      %6.3f',mean(govi./agdp)))
disp(sprintf('   Net Exports           %6.3f',mean(netxm./agdp)))
disp(' ')
disp(sprintf(' GDP                     %6.3f',mean(gdp./agdp)))
disp(' ')
disp(' ')
disp(' DOMESTIC PRODUCT, BY OUR CATEGORIZATION: ')
disp(' ')
disp(sprintf('   Private cons (nd+s)   %6.3f',mean((pce-pced)./agdp)))
disp(sprintf('   Govt. consumption     %6.3f',mean(govc./agdp)))
disp(sprintf('   Tangible investment   %6.3f',mean((pced+gpdi+govi+ ...
   netxm)./agdp)))
disp(sprintf('     Corporate           %6.3f',mean((cgpdif+cgpdii)./agdp)))
disp(sprintf('       Fixed             %6.3f',mean(cgpdif./agdp)))
disp(sprintf('       Inventory         %6.3f',mean(cgpdii./agdp)))
disp(sprintf('     Noncorporate bus    %6.3f',mean((ncgpdif+ncgpdii)./agdp)))
disp(sprintf('       Fixed             %6.3f',mean(ncgpdif./agdp)))
disp(sprintf('       Inventory         %6.3f',mean(ncgpdii./agdp)))
disp(sprintf('     Household           %6.3f',mean(hhgpdif./agdp)))
disp(sprintf('     Consumer durables   %6.3f',mean(pced./agdp)))
disp(sprintf('     Nonprofits          %6.3f',mean(npgpdif./agdp)))
disp(sprintf('     Govt. investment    %6.3f',mean(govi./agdp)))
disp(sprintf('     Net Exports         %6.3f',mean(netxm./agdp)))
disp(' ')
disp(sprintf(' GDP                     %6.3f',mean(gdp./agdp)))
disp(' ')
disp(' ')
disp(' DOMESTIC CAPITAL:')
disp(' ')
disp(sprintf('   Corporate             %6.3f',mean((kcfix+kcinv+cland)./agdp)))
disp(sprintf('     Fixed               %6.3f',mean(kcfix./agdp)))
disp(sprintf('     Inventory           %6.3f',mean(kcinv./agdp)))
disp(sprintf('     Nonfarm land        %6.3f',mean(cland./agdp)))
disp(sprintf('   Noncorporate          %6.3f',mean((kppfix+ktefix+kncinv+ ...
   nfbland)./agdp)))
disp(sprintf('     Fixed,Proprietors   %6.3f',mean(kppfix./agdp)))
disp(sprintf('     Fixed,Tax-exempt    %6.3f',mean(ktefix./agdp)))
disp(sprintf('     Inventory           %6.3f',mean(kncinv./agdp)))
disp(sprintf('     Nonfarm land        %6.3f',mean(nfbland./agdp)))
disp(sprintf('   Farm land (estimate)  %6.3f',.08))
disp(sprintf('   Household             %6.3f',mean((khhfix+hhland)./agdp)))
disp(sprintf('     Fixed               %6.3f',mean(khhfix./agdp)))
disp(sprintf('     Land                %6.3f',mean(hhland./agdp)))
disp(sprintf('   Nonprofits            %6.3f',mean(knpfix./agdp)))
disp(sprintf('   Government            %6.3f',mean(kgfix./agdp)))
disp(sprintf('   Consumer durables     %6.3f',mean(kcd./agdp)))
disp(' ')
disp(sprintf(' Total                   %6.3f',mean(k./agdp)+.08))
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(' ')
disp(' ')


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

disp(' ')
disp(' ')
disp(' TAX RATES ')
disp(sprintf('   Consumption           %6.3f',mean(Tauct)))
disp(sprintf('   Labor                 %6.3f',mean(Tauht)))
disp(sprintf('   Profits               %6.3f',mean(Taupt)))
disp(sprintf('   Property              %6.3f',mean(Taukt)))
disp(sprintf('     Business            %6.3f',mean(Taukbt)))


OBS          = [t,[Ymt,Yot,Ct,Xmt,Xot]/Ymt(1),Hmt,Hot,Tauct,Tauht, ...
                Taupt,Taukt,Taukbt];

disp(' ')
disp('=============================================================================================')
disp(sprintf('  TIME SERIES for %g:%g-%g:%g ',yr0,qr0,yr1,qr1))
disp('=============================================================================================')
disp(' ')
disp('Year.Qtr   Ym     Yo     C+G    Xm     Xo     Hm     Ho     Tauc   Taul   Taup   Tauk  Taukb')
disp(' ')
fprintf('%7.3f%7.4f%7.4f%7.4f%7.4f%7.4f%7.4f%7.4f%7.4f%7.4f%7.4f%7.4f%7.4f\n',OBS')

                                                                                
