%TABLE3   This program generates Table 3 in 
%
%           Taxes, Regulations, and the Value of US and UK Corporations,
%           by Ellen McGrattan and Ed Prescott
%

%         Ellen McGrattan 8-28-03


%
% Data to load:
%     NIPA Table 1.9,   annually  1929-2002
%     NIPA Table 1.16,  annually  1929-2002
%     NIPA Table 5.12A, quarterly 1946:1-1997:4
%     NIPA Table 5.12B, quarterly 1996:4-2003:2
%     NIPA Table 6.16B, annually  1948-1987
%     NIPA Table 6.16C, annually  1987-2002
%     NIPA Table 8.25,  annually  1929-2001
%     FAS  Table 1.1,   annually  1925-2001
%     FAS  Table 4.1,   annually  1925-2001
%     FAS  Table 5.1,   annually  1925-2001
%     SOI  Table 2,     annually  1942-1999 (extrapolated in 2000-2001)
%     FOF  Table F.6,   quarterly 1952:1-2003:1
%     FOF  Table L.102, quarterly 1952:1-2003:1
%     FOF  Table L.109, quarterly 1952:1-2003:1
%     FOF  Table L.117, quarterly 1952:1-2003:1
%     FOF  Table L.118, quarterly 1952:1-2003:1
%     FOF  Table L.123, quarterly 1952:1-2003:1
%     FOF  Table L.129, quarterly 1952:1-2003:1
%     FOF  Table L.130, quarterly 1952:1-2003:1
%     FOF  Table L.213, quarterly 1952:1-2003:1
%     FOF  Table L.230, quarterly 1952:1-2003:1
%     FOF  Table L.231, quarterly 1952:1-2003:1
%     FOF  Table L.232, quarterly 1952:1-2003:1
%     ICI  Mutual Fund Assets, annually 1960-2002
%     Tax rates on dividends, annually 1960-2000

load us/raw/nipa109a.dat; 
load us/raw/nipa116a.dat; 
load us/raw/nipa512Aq.dat;
load us/raw/nipa512Bq.dat;
load us/raw/nipa616Ba.dat;
load us/raw/nipa616Ca.dat;
load us/raw/nipa825a.dat;
load us/raw/fas401a.dat;
load us/raw/fas501a.dat;
load us/raw/atab6d.dat;
load us/raw/land_soi.dat;
load us/taxrates/taud.dat;
load us/raw/ltab102d.dat;
load us/raw/ltab109d.dat;
load us/raw/ltab117d.dat;
load us/raw/ltab118d.dat;
load us/raw/ltab123d.dat;
load us/raw/ltab129d.dat;
load us/raw/ltab130d.dat;
load us/raw/ltab213d.dat;
load us/raw/ltab230d.dat;
load us/raw/ltab231d.dat;
load us/raw/ltab232d.dat;
load us/raw/mf_type.dat;

%
% Years to load: Y0 through Y1
%

Y0  = 1960;
Y1  = 2001;


%
% Extract data:
%

nipa109a       = nipa109a(2:30,Y0-1928:Y1-1928)/1000;
nipa116a       = nipa116a(2:39,Y0-1928:Y1-1928)/1000;
nipa512q       = [nipa512Aq(1:3,:),nipa512Bq(1:3,6:22)];
nipa512a       = qtr2ann(nipa512q',1);
nipa512a       = nipa512a(Y0-1945:Y1-1945,2:3)'/1000;
nipa616a       = [nipa616Ba(:,1:39),nipa616Ca]/1000;
nipa616a       = nipa616a(2:35,Y0-1947:Y1-1947);
nipa825a       = nipa825a(2:38,Y0-1928:Y1-1928);
fas401a        = fas401a(2:55,Y0-1924:Y1-1924)/1000;
fas501a        = fas501a(2:20,Y0-1924:Y1-1924)/1000;
land_soi(21,2) = .5*land_soi(20,2)+.5*land_soi(22,2);
land_soi(59,2) = land_soi(58,2)^2/land_soi(57,2);
land_soi(60,2) = land_soi(59,2)^2/land_soi(58,2);
landsoi        = land_soi(Y0-1941:Y1-1941,2)/10^6;
atab6a         = qtr2ann(atab6d);
atab6a         = atab6a(Y0-1951:Y1-1951,2:37)'/1000;
ltab102a       = qtr2ann(ltab102d,1);
ltab102a       = ltab102a(Y0-1951:Y1-1951,2:46)'/1000;
ltab109a       = qtr2ann(ltab109d,1);
ltab109a       = ltab109a(Y0-1951:Y1-1951,2:40)'/1000;
ltab117a       = qtr2ann(ltab117d,1);
ltab117a       = ltab117a(Y0-1951:Y1-1951,2:22)'/1000;
ltab118a       = qtr2ann(ltab118d,1);
ltab118a       = ltab118a(Y0-1951:Y1-1951,2:17)'/1000;
ltab123a       = qtr2ann(ltab123d,1);
ltab123a       = ltab123a(Y0-1951:Y1-1951,2:14)'/1000;
ltab129a       = qtr2ann(ltab129d,1);
ltab129a       = ltab129a(Y0-1951:Y1-1951,2:24)'/1000;
ltab130a       = qtr2ann(ltab130d,1);
ltab130a       = ltab130a(Y0-1951:Y1-1951,2:25)'/1000;
ltab213a       = qtr2ann(ltab213d,1);
ltab213a       = ltab213a(Y0-1951:Y1-1951,2:21)'/1000;
ltab230a       = qtr2ann(ltab230d,1);
ltab230a       = ltab230a(Y0-1951:Y1-1951,2:41)'/1000;
ltab231a       = qtr2ann(ltab231d,1);
ltab231a       = ltab231a(Y0-1951:Y1-1951,2:24)'/1000;
ltab232a       = qtr2ann(ltab232d,1);
ltab232a       = ltab232a(Y0-1951:Y1-1951,2:45)'/1000;
ici            = mf_type(Y0-1949: Y1-1949,2:7);
taud           = taud(Y0-1959:Y1-1959,2)/100;

%
% Intermediate variables
%

gdp            = nipa109a(1,:)';
kc             = (fas401a(13,:)'+fas501a(3,:)')./gdp;
kinv           = (nipa512a(1,:)'-.9*nipa512a(2,:)')./gdp;
land           = landsoi./gdp;
k1m            = land+kc+kinv;
x1m            = (sum(atab6a([10,13,16,20],:))'+ ...
                  .1*sum(atab6a([12,22],:))')./gdp;
aprfc          = nipa116a(9,:)'./gdp;
ptxc           = nipa116a(11,:)'./gdp;
pbtc           = nipa116a(10,:)'./gdp;
aprfrowr       = nipa616a(6,:)'./gdp;
aprfrowp       = nipa616a(7,:)'./gdp;
aprffr         = nipa616a(11,:)'./gdp;
tau1           = (ptxc-aprffr)./(pbtc-aprffr);
itc            = nipa825a(25,:)'./gdp;
i              = find(isnan(itc));
if ~isempty(i);
  itc(i)       = zeros(length(i),1);
end;
taux           = itc./x1m;
forprfat       = aprfrowr-aprfrowp;
domprfat       = aprfc-ptxc;
fdrat          = forprfat./domprfat;
natprfat       = domprfat+forprfat;

wgt1l          = 1/4; %debt weight on foreign direct investments (liabilities)
wgt1a          = 1/10;%debt weight on foreign direct investments (assets)
wgt2           = 1/2; %debt weight on bank holding company investments
mfdebt         = sumnan([.5*ici(:,2),ici(:,3:5)]')'./ici(:,6);
life_reserves  = sum(ltab117a([18,19],:))+ltab231a(9,:)+ltab231a(18,:);
life_debta     = sum(ltab117a(2:4,:))+ltab117a(14,:).*mfdebt';
life_misca     = ltab230a(4,:)*wgt1a+ltab231a(8,:)+ltab232a(35,:);
life_finassets = ltab117a(1,:);
life_debta_adj = life_debta-(life_debta./life_finassets).*life_reserves;
life_misca_adj = life_misca-(life_misca./life_finassets).*life_reserves;
debtl          = sum([ltab102a([21,34,35],:);
                      ltab109a([22,26,30:33,37],:);
                      ltab117a([17,20],:);
                      ltab118a([15],:);
                      ltab129a([12,13],:);
                      ltab130a([14:17,20],:)])';
debta          = sum([ltab102a([2:12],:);
                      ltab102a([13],:).*mfdebt';
                      ltab109a([2:4,6,9,10,11,19],:);
                      ltab109a([18],:).*mfdebt';
                      ltab118a([2:4,12],:);
                      ltab123a([2,9],:);
                      ltab129a([2,3],:);
                      ltab130a([2,3,11],:)])' + life_debta_adj';
miscl          = sum([ltab230a([8,10:12,14],:)*wgt1l;
                      ltab230a([38:39],:);
                      ltab230a([30,34],:)*wgt2;
                      ltab231a([13,20],:);
                      ltab232a([2,7,14,17,18],:)])';
misca          = sum([ltab230a([2,3,5,7],:)*wgt1a;
                      ltab230a([37],:);
                      ltab230a([35],:)*wgt2;
                      ltab231a([15,23],:);
                      ltab232a([21,27,42,43],:)])'+ life_misca_adj';
netdebt        = (debtl+miscl-debta-misca)./gdp;
equity         = ltab213a(20,:)'./gdp;

%
% Averages for the periods reported
%

t              = Y0:Y1;
t69            = find(t==1969);
t00            = find(t==2000);
t01            = find(t==2001);
t60s           = find(t==1960):t69;
t90s           = find(t==1990):t01;
t90send        = find(t==1998):t01;
beta           = 0.98;
gam60s         = 0.03;
gam90s         = 0.02;
eta            = 0.01;
g60s           = gam60s+eta;
g90s           = gam90s+eta;
i60s           = (1+gam60s)/beta-1;
i90s           = (1+gam90s)/beta-1;
del60s         = mean(x1m(t60s))-g60s;
del90s         = mean(x1m(t90s))-g90s;
x1m60s         = mean(x1m(t60s));
x1m90s         = mean(x1m(t90s));
prf60s         = mean(aprfc(t60s));
prf90s         = mean(aprfc(t90s));
tprf60s        = i60s*x1m60s/((1-tau1(t69))*(g60s+del60s));
tprf90s        = i90s*x1m90s/((1-tau1(t01))*(g90s+del90s));
iprf60s        = prf60s-tprf60s;
iprf90s        = prf90s-tprf90s;
k1u60s         = iprf60s/(i60s-g60s);
k1u90s         = iprf90s/(i90s-g90s);
k1m60s         = mean(k1m(t60s));
k1m90s         = mean(k1m(t90s));
k1m90send      = mean(k1m(t90send));
forfac60s      = mean(fdrat(t60s));
forfac90s      = mean(fdrat(t90s));
forfac90send   = mean(fdrat(t90send));
v60s           = (1-taud(t69))*((1-taux(t69))*k1m60s+ ...
                                (1-tau1(t69))*k1u60s)*(1+forfac60s);
v90s           = (1-taud(t00))*((1-taux(t01))*k1m90s+ ...
                                (1-tau1(t01))*k1u90s)*(1+forfac90s);
v90send        = (1-taud(t00))*((1-taux(t01))*k1m90send+ ...
                                (1-tau1(t01))*k1u90s)*(1+forfac90send);
mktbkadj60s    = 0.656;  % Reference: Hall (2001)
mktbkadj90s    = 0.892;
mktbkadj90send = 0.789;
debt60s        = mean(netdebt(t60s))*mktbkadj60s *(1-taud(t69));
debt90s        = mean(netdebt(t90s))*mktbkadj90s *(1-taud(t00));
debt90send     = mean(netdebt(t90send))*mktbkadj90send *(1-taud(t00));
eqty60s        = mean(equity(t60s));
eqty90s        = mean(equity(t90s));
eqty90send     = mean(equity(t90send));
e60s           = mean(natprfat(t60s));
e90s           = mean(natprfat(t90s));
e90send        = mean(natprfat(t90send));

%
% Generate Table:
%

clc
disp('TABLE 3. U.S. Corporate Values and Price Earnings Ratios')
disp('======================================================================')
disp('                                           1960-1969        1998-2001 ')
disp('                                          ----------------------------')
disp(' Predicted Fundamental Values: ')
disp(' ')
disp('    Value-GDP Ratio, with contributions from ')
disp(sprintf( ...
     '       Domestic tangible capital             %5.3f            %5.3f', ...
             (1-taud(t69))*(1-taux(t69))*k1m60s, ...
             (1-taud(t00))*(1-taux(t01))*k1m90send))
disp(sprintf( ...
     '       Domestic intangible capital           %5.3f            %5.3f', ...
             (1-taud(t69))*(1-tau1(t69))*k1u60s, ...
             (1-taud(t00))*(1-tau1(t01))*k1u90s))
disp(sprintf( ...
     '       Foreign capital                       %5.3f            %5.3f', ...
            ((1-taud(t69))*(1-taux(t69))*k1m60s+ ...
             (1-taud(t69))*(1-tau1(t69))*k1u60s)*forfac60s, ...
            ((1-taud(t00))*(1-taux(t01))*k1m90send+ ...
             (1-taud(t00))*(1-tau1(t01))*k1u90s)*forfac90send))
disp('                                             -----            -----')
disp(sprintf( ...
     '       TOTAL                                 %5.3f            %5.3f', ...
             v60s,v90send))
disp(' ')
disp(sprintf( ...
     '    Price-Earnings Ratio                     %5.1f            %5.1f', ...
          v60s./e60s,v90send./e90send))
disp(' ')
disp(' ')
disp(' Actual Market Values: ')
disp(' ')
disp('    Value-GDP Ratio, with contributions from ')
disp(sprintf( ...
     '       Corporate equities                    %5.3f            %5.3f', ...
             eqty60s,eqty90send))
disp(sprintf( ...
     '       Net debt                              %5.3f            %5.3f', ...
             debt60s,debt90send))
disp('                                             -----            -----')
disp(sprintf( ...
     '       TOTAL                                 %5.3f            %5.3f', ...
             eqty60s+debt60s,eqty90send+debt90send))
disp(' ')
disp(sprintf( ...
     '    Price-Earnings Ratio                     %5.1f            %5.1f', ...
             (eqty60s+debt60s)./e60s,(eqty90send+debt90send)./e90send))
disp('======================================================================')
disp('NOTE:  Averages not displayed in Tables 1-2 but used in Tables 4-5:')
disp('                                                       ')
disp('       Period     Domestic tangible /GDP   Foreign/Domestic Profits')
disp('       ------------------------------------------------------------')
disp(sprintf( ...
     '       1960-1969           %5.2f                %5.2f', ...
             k1m60s,forfac60s))
disp(sprintf( ...
     '       1990-2001           %5.2f                %5.2f', ...
             k1m90s,forfac90s))
disp(sprintf( ...
     '       1998-2001           %5.2f                %5.2f', ...
             k1m90send,forfac90send))

