%FIGURE1  This program generates Figure 1 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:
%     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
%     Hall's market to book correction for debt

load us/raw/atab6d.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;
load us/value/hall/mktbook.dat
load us/taxrates/taud.dat


%
% Extract data:
%

Y0             = 1960;
Y1             = 2001;
i              = Y0-1951:Y1-1951;
t              = Y0:Y1;
atab6a         = qtr2ann(atab6d);
atab6a         = atab6a(i,2:37)'/1000;
ltab102a       = qtr2ann(ltab102d,1);
ltab102a       = ltab102a(i,2:46)'/1000;
ltab109a       = qtr2ann(ltab109d,1);
ltab109a       = ltab109a(i,2:40)'/1000;
ltab117a       = qtr2ann(ltab117d,1);
ltab117a       = ltab117a(i,2:22)'/1000;
ltab118a       = qtr2ann(ltab118d,1);
ltab118a       = ltab118a(i,2:17)'/1000;
ltab123a       = qtr2ann(ltab123d,1);
ltab123a       = ltab123a(i,2:14)'/1000;
ltab129a       = qtr2ann(ltab129d,1);
ltab129a       = ltab129a(i,2:24)'/1000;
ltab130a       = qtr2ann(ltab130d,1);
ltab130a       = ltab130a(i,2:25)'/1000;
ltab213a       = qtr2ann(ltab213d,1);
ltab213a       = ltab213a(i,2:21)'/1000;
ltab230a       = qtr2ann(ltab230d,1);
ltab230a       = ltab230a(i,2:41)'/1000;
ltab231a       = qtr2ann(ltab231d,1);
ltab231a       = ltab231a(i,2:24)'/1000;
ltab232a       = qtr2ann(ltab232d,1);
ltab232a       = ltab232a(i,2:45)'/1000;
ici            = mf_type(Y0-1949: Y1-1949,2:7);
mfdebt         = sumnan([.5*ici(:,2),ici(:,3:5)]')'./ici(:,6);
mktbook        = [mktbook(Y0-1951: Y1-1951-2,2);
                  mktbook(Y1-1951-2,2);
                  mktbook(Y1-1951-2,2)];
taud           = [taud(Y0-1959:Y1-1959-1,2);
                  taud(Y1-1959-1,2)]/100;

%
% Intermediate variables
%

gdp            = atab6a(1,:)';
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
wgt3           = 1;   %debt weight on unidentified miscellaeous liabilities
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,:)*wgt3;
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],:)*wgt3])';
misca          = sum([ltab230a([2,3,5,7],:)*wgt1a;
                     +ltab230a([37],:);
                     +ltab230a([35],:)*wgt2;
                     +ltab231a([15,23],:);
                     +ltab232a([21,27,42,43],:)*wgt3])'+ life_misca_adj';
netdebt        = (debtl+miscl-debta-misca)./gdp .*(1-taud).*mktbook;
equity         = ltab213a(20,:)'./gdp;

%
% Generate figure:
%

plot(t,equity+netdebt,t,equity)
title('US Corporate Value, 1960-2001')
axis([1960,2001,0,2])
legend('Total value','Equity value',0)
