%MAKETABS    makes tables shown in main text and appendices.
%
%            Ellen McGrattan, 9-22-13

%
% Fill in GDP and net worth of households from the baseline
%

GDP0     = .701;
L0       = .277;
NWhh0    = 5.549*.701;

%
% Fill in utility from the economy with new demographics and continuing policy
%
U0       = -46.774;


%
% Table 5. Balanced Growth Aggregate Statistics
%
  
printtex = 0;
for i=1:5;

  if i==1;
    !rm -f bg.dat
    !cp ../baseline/baseline.dat bg.dat
  elseif i==2;
    !rm -f bg.dat
    !cp ../continue/continue.dat bg.dat
  elseif i==3;
    !rm -f bg.dat
    !cp ../nomedss/nomedss.dat bg.dat
  elseif i==4;
    !rm -f bg.dat
    !cp ../nocaptax/nocaptax.dat bg.dat
  elseif i==5;
    !rm -f bg.dat
    !cp ../noimptra/noimptra.dat bg.dat
  end;
  plotbg
  Table5(:,i)  = [taupc,taud,taupu,taul,tauc,(Tran+Tranj)/GDP,Tranwrk/GDP, ...
                  Tranret/GDP,C/GDP,w*(L1+L2)/GDP,(KT1eoy+KT2eoy+KI1eoy+ ...
                  KI2eoy)/GDP,(KT1eoy+KT2eoy)/GDP,KT1eoy/GDP,KT2eoy/GDP, ...
                  (KI1eoy+KI2eoy)/GDP,(L1+L2)/L0,GDP/GDP0,NWhh/NWhh0, ...
                  (irate-1)*100,(exp((U-U0)/Disc)-1)*100];

end;

!rm -f maketabs.out
diary maketabs.out
disp('BALANCED GROWTH RESULTS')
clc
disp(' ')
disp(' ')
disp(' ')
disp('               Table 5. Balanced Growth Aggregate Statistics')
disp('=========================================================================')
disp('                           |    Future policies with new demographics    ')
disp('                           |---------------------------------------------')  
disp('                           |               Eliminate FICA Taxes and      ')
disp('                           |           ----------------------------------')
disp('              Current US   | Continue    Medicare   Plus cut   Plus cut  ')
disp('              Policy and   |  with US    & Social   Capital    Implicit  ')
disp('              Demographics |  Policy     Security   Taxes      Transfers ')
disp('              -------------|---------------------------------------------')  
disp('Policy Inputs: ')
disp('  Tax rates ')
disp(sprintf('    C-Profits   %8.3f%12.3f%11.3f%11.3f%11.3f ',Table5(1,:)))
disp(sprintf('    C-Dist      %8.3f%12.3f%11.3f%11.3f%11.3f ',Table5(2,:)))
disp(sprintf('    Other Dist  %8.3f%12.3f%11.3f%11.3f%11.3f ',Table5(3,:)))
disp(sprintf('    Labor       %8.3f%12.3f%11.3f%11.3f%11.3f ',Table5(4,:)))
disp(sprintf('    Consumption %8.3f%12.3f%11.3f%11.3f%11.3f ',Table5(5,:)))
disp(sprintf('  Transfers     %8.3f%12.3f%11.3f%11.3f%11.3f ',Table5(6,:)))
disp(sprintf('    To workers  %8.3f%12.3f%11.3f%11.3f%11.3f ',Table5(7,:)))
disp(sprintf('    To retirees %8.3f%12.3f%11.3f%11.3f%11.3f ',Table5(8,:)))
disp('Policy Inputs: ')
disp(sprintf('  Cons. share   %8.3f%12.3f%11.3f%11.3f%11.3f ',Table5(9,:)))
disp(sprintf('  Labor share   %8.3f%12.3f%11.3f%11.3f%11.3f ',Table5(10,:)))
disp(sprintf('  Capital/GNP   %8.2f%12.2f%11.2f%11.2f%11.2f ',Table5(11,:)))
disp(sprintf('    Tangible    %8.2f%12.2f%11.2f%11.2f%11.2f ',Table5(12,:)))
disp(sprintf('      Sched C   %8.2f%12.2f%11.2f%11.2f%11.2f ',Table5(13,:)))
disp(sprintf('      Other     %8.2f%12.2f%11.2f%11.2f%11.2f ',Table5(14,:)))
disp(sprintf('    Intangible  %8.2f%12.2f%11.2f%11.2f%11.2f ',Table5(15,:)))
disp(sprintf('  Labor input   %8.2f%12.2f%11.2f%11.2f%11.2f ',Table5(16,:)))
disp(sprintf('  GNP           %8.2f%12.2f%11.2f%11.2f%11.2f ',Table5(17,:)))
disp(sprintf('  Net worth     %8.2f%12.2f%11.2f%11.2f%11.2f ',Table5(18,:)))
disp(sprintf('  Interest rate %8.2f%12.2f%11.2f%11.2f%11.2f ',Table5(19,:)))
disp(sprintf('  Welfare gain  %8.2f%12.2f%11.2f%11.2f%11.2f ',Table5(20,:)))
disp('=========================================================================')
disp(' ')
disp(' ')
Table7(1,:) = Table5(20,[1,3:5]);

if printtex==1;
  for i=1:10;
    disp(sprintf('&& %8.3f&& %8.3f&& %8.3f&& %8.3f&& %8.3f&\\cr',Table5(i,:)))
  end;
  for i=11:20;
    disp(sprintf('&& %8.2f&& %8.2f&& %8.2f&& %8.2f&& %8.2f&\\cr',Table(i,:)))
  end;
end;

diary 

 

isens = input('Print results of sensitivity analysis (1=yes,0=no) ');
if isens==1;
  ifull  = input('Print full details of alternatives? (1=yes,0=no) ' );
  label5 = [' Table 5a. Balanced Growth Statistics--No annuity markets           ';
            ' Table 5b. Balanced Growth Statistics--Age-dependent productivities ';
            ' Table 5c. Balanced Growth Statistics--12 percent profits tax rate  ';
            ' Table 5d. Balanced Growth Statistics--4 percent profits tax rate   ';
            ' Table 5e. Balanced Growth Statistics--Lower labor elasticity       ';
            ' Table 5f. Balanced Growth Statistics--One sector, one capital      '];
  %
  % Table 5a. Balanced Growth Statistics--No annuity markets
  %
  GDP0     = .701;
  NWhh0    = 5.549*.701;
  U0       = -53.249;
  for i=1:5;
    if i==1;
      !rm -f bg.dat
      !cp ../baseline/sensitivity/noannuities.dat bg.dat
    elseif i==2;
      !rm -f bg.dat
      !cp ../continue/sensitivity/noannuities.dat bg.dat
    elseif i==3;
      !rm -f bg.dat
      !cp ../nomedss/sensitivity/noannuities.dat bg.dat
    elseif i==4;
      !rm -f bg.dat
      !cp ../nocaptax/sensitivity/noannuities.dat bg.dat
    elseif i==5;
      !rm -f bg.dat
      !cp ../noimptra/sensitivity/noannuities.dat bg.dat
    end;
    plotbg
    Table5a(:,i) = [taupc,taud,taupu,taul,tauc,(Tran+Tranj)/GDP,Tranwrk/GDP, ...
                    Tranret/GDP,C/GDP,w*(L1+L2)/GDP,(KT1eoy+KT2eoy+KI1eoy+ ...
                    KI2eoy)/GDP,(KT1eoy+KT2eoy)/GDP,KT1eoy/GDP,KT2eoy/GDP, ...
                    (KI1eoy+KI2eoy)/GDP,(L1+L2)/L0,GDP/GDP0,NWhh/NWhh0, ...
                    (irate-1)*100,(exp((U-U0)/Disc)-1)*100];
  end;
  Table7(2,:) = Table5a(20,[1,3:5]);

  %
  % Table 5b. Balanced Growth Statistics--Age-dependent productivities
  %
  GDP0     = .701;
  NWhh0    = 5.557*.701;
  U0       = -51.285;
  for i=1:5;
    if i==1;
      !rm -f bg.dat
      !cp ../baseline/sensitivity/varyeps.dat bg.dat
    elseif i==2;
      !rm -f bg.dat
      !cp ../continue/sensitivity/varyeps.dat bg.dat
    elseif i==3;
      !rm -f bg.dat
      !cp ../nomedss/sensitivity/varyeps.dat bg.dat
    elseif i==4;
      !rm -f bg.dat
      !cp ../nocaptax/sensitivity/varyeps.dat bg.dat
    elseif i==5;
      !rm -f bg.dat
      !cp ../noimptra/sensitivity/varyeps.dat bg.dat
    end;
    plotbg
    Table5b(:,i) = [taupc,taud,taupu,taul,tauc,(Tran+Tranj)/GDP,Tranwrk/GDP, ...
                    Tranret/GDP,C/GDP,w*(L1+L2)/GDP,(KT1eoy+KT2eoy+KI1eoy+ ...
                    KI2eoy)/GDP,(KT1eoy+KT2eoy)/GDP,KT1eoy/GDP,KT2eoy/GDP, ...
                    (KI1eoy+KI2eoy)/GDP,(L1+L2)/L0,GDP/GDP0,NWhh/NWhh0, ...
                    (irate-1)*100,(exp((U-U0)/Disc)-1)*100];
  end;
  Table7(3,:) = Table5b(20,[1,3:5]);

  %
  % Table 5c. Balanced Growth Statistics--12 percent profits tax rate
  %
  GDP0     = .701;
  NWhh0    = 5.549*.701;
  U0       = -46.774;

  Table5c(:,1:3) = Table5(:,1:3);
  for i=4:5;
    if i==4;
      !rm -f bg.dat
      !cp ../nocaptax/sensitivity/taup12.dat bg.dat
    elseif i==5;
      !rm -f bg.dat
      !cp ../noimptra/sensitivity/taup12.dat bg.dat
    end;
    plotbg
    Table5c(:,i) = [taupc,taud,taupu,taul,tauc,(Tran+Tranj)/GDP,Tranwrk/GDP, ...
                    Tranret/GDP,C/GDP,w*(L1+L2)/GDP,(KT1eoy+KT2eoy+KI1eoy+ ...
                    KI2eoy)/GDP,(KT1eoy+KT2eoy)/GDP,KT1eoy/GDP,KT2eoy/GDP, ...
                    (KI1eoy+KI2eoy)/GDP,(L1+L2)/L0,GDP/GDP0,NWhh/NWhh0, ...
                    (irate-1)*100,(exp((U-U0)/Disc)-1)*100];
  end;
  Table7(4,:) = Table5c(20,[1,3:5]);

  %
  % Table 5d. Balanced Growth Statistics--4 percent profits tax rate
  %
  GDP0     = .701;
  NWhh0    = 5.549*.701;
  U0       = -46.774;
  Table5d(:,1:3) = Table5(:,1:3);
  for i=4:5;
    if i==4;
      !rm -f bg.dat
      !cp ../nocaptax/sensitivity/taup04.dat bg.dat
    elseif i==5;
      !rm -f bg.dat
      !cp ../noimptra/sensitivity/taup04.dat bg.dat
    end;
    plotbg
    Table5d(:,i) = [taupc,taud,taupu,taul,tauc,(Tran+Tranj)/GDP,Tranwrk/GDP, ...
                    Tranret/GDP,C/GDP,w*(L1+L2)/GDP,(KT1eoy+KT2eoy+KI1eoy+ ...
                    KI2eoy)/GDP,(KT1eoy+KT2eoy)/GDP,KT1eoy/GDP,KT2eoy/GDP, ...
                    (KI1eoy+KI2eoy)/GDP,(L1+L2)/L0,GDP/GDP0,NWhh/NWhh0, ...
                    (irate-1)*100,(exp((U-U0)/Disc)-1)*100];
  end;
  Table7(5,:) = Table5d(20,[1,3:5]);

  %
  % Table 5e. Balanced Growth Statistics--Lower labor elasticity
  %
  GDP0     = .700;
  NWhh0    = 5.567*.700;
  U0       = -46.158;
  for i=1:5;
    if i==1;
      !rm -f bg.dat
      !cp ../baseline/sensitivity/elasticity.dat bg.dat
    elseif i==2;
      !rm -f bg.dat
      !cp ../continue/sensitivity/elasticity.dat bg.dat
    elseif i==3;
      !rm -f bg.dat
      !cp ../nomedss/sensitivity/elasticity.dat bg.dat
    elseif i==4;
      !rm -f bg.dat
      !cp ../nocaptax/sensitivity/elasticity.dat bg.dat
    elseif i==5;
      !rm -f bg.dat
      !cp ../noimptra/sensitivity/elasticity.dat bg.dat
    end;
    plotbg_e
    Table5e(:,i) = [taupc,taud,taupu,taul,tauc,(Tran+Tranj)/GDP,Tranwrk/GDP, ...
                    Tranret/GDP,C/GDP,w*(L1+L2)/GDP,(KT1eoy+KT2eoy+KI1eoy+ ...
                    KI2eoy)/GDP,(KT1eoy+KT2eoy)/GDP,KT1eoy/GDP,KT2eoy/GDP, ...
                    (KI1eoy+KI2eoy)/GDP,(L1+L2)/L0,GDP/GDP0,NWhh/NWhh0, ...
                    (irate-1)*100,(exp((U-U0)/Disc)-1)*100];
  end;
  Table7(6,:) = Table5e(20,[1,3:5]);

  %
  % Table 5f. Balanced Growth Statistics--One sector, one capital model
  %
  GDP0     = 1.296;
  NWhh0    = 3.549*1.296;
  U0       = -26.825;
  for i=1:5;
    if i==1;
      !rm -f bg.dat
      !cp ../baseline/sensitivity/onesector.dat bg.dat
    elseif i==2;
      !rm -f bg.dat
      !cp ../continue/sensitivity/onesector.dat bg.dat
    elseif i==3;
      !rm -f bg.dat
      !cp ../nomedss/sensitivity/onesector.dat bg.dat
    elseif i==4;
      !rm -f bg.dat
      !cp ../nocaptax/sensitivity/onesector.dat bg.dat
    elseif i==5;
      !rm -f bg.dat
      !cp ../noimptra/sensitivity/onesector.dat bg.dat
    end;
    plotbg
    Table5f(:,i) = [taupc,taud,taupu,taul,tauc,(Tran+Tranj)/GDP,Tranwrk/GDP, ...
                    Tranret/GDP,C/GDP,w*(L1+L2)/GDP,(KT1eoy+KT2eoy+KI1eoy+ ...
                    KI2eoy)/GDP,(KT1eoy+KT2eoy)/GDP,KT1eoy/GDP,KT2eoy/GDP, ...
                    (KI1eoy+KI2eoy)/GDP,(L1+L2)/L0,GDP/GDP0,NWhh/NWhh0, ...
                    (irate-1)*100,(exp((U-U0)/Disc)-1)*100];
  end;
  Table7(7,:) = Table5f(20,[1,3:5]);

  diary maketabs.out

  disp('SENSITIVITY ANALYSIS')
  disp(' ')
  disp(' ')
  disp('    Table 7. Welfare Gains Relative to Economy with New Demographics     ')
  disp('                         and Continued US Policy                         ')
  disp('=========================================================================')
  disp('                                    |      Eliminate FICA Taxes and      ')
  disp('                                    |  ----------------------------------')
  disp('                       Current US   |    Medicare   Plus cut   Plus cut  ')
  disp('                       Policy and   |    & Social   Capital    Implicit  ')
  disp('                       Demographics |    Security   Taxes      Transfers ')
  disp('                       -------------|------------------------------------')  
  disp(sprintf('Benchmark             %8.1f      | %9.1f%11.1f%11.1f ',Table7(1,:)))
  disp(sprintf('No annuities          %8.1f      | %9.1f%11.1f%11.1f ',Table7(2,:)))
  disp(sprintf('Age-dependent prod.   %8.1f      | %9.1f%11.1f%11.1f ',Table7(3,:)))
  disp(sprintf('12%% profits tax       %8.1f      | %9.1f%11.1f%11.1f ',Table7(4,:)))
  disp(sprintf('4%% profits tax        %8.1f      | %9.1f%11.1f%11.1f ',Table7(5,:)))
  disp(sprintf('Lower elasticity      %8.1f      | %9.1f%11.1f%11.1f ',Table7(6,:)))
  disp(sprintf('One-sector model      %8.1f      | %9.1f%11.1f%11.1f ',Table7(7,:)))
  disp('=========================================================================')
  disp(' ')
  disp(' ')


  if ifull==1;
    clc
    for j=1:6;

      if j==1; Table = Table5a; end;
      if j==2; Table = Table5b; end;
      if j==3; Table = Table5c; end;
      if j==4; Table = Table5d; end;
      if j==5; Table = Table5e; end;
      if j==6; Table = Table5f; end;
      disp(label5(j,:))
      disp('=========================================================================')
      disp('                           |    Future policies with new demographics    ')
      disp('                           |---------------------------------------------')  
      disp('                           |               Eliminate FICA Taxes and      ')
      disp('                           |           ----------------------------------')
      disp('              Current US   | Continue    Medicare   Plus cut   Plus cut  ')
      disp('              Policy and   |  with US    & Social   Capital    Implicit  ')
      disp('              Demographics |  Policy     Security   Taxes      Transfers ')
      disp('              -------------|---------------------------------------------')  
      disp('Policy Inputs: ')
      disp('    Tax rates ')
      disp(sprintf('    C-Profits   %8.3f%12.3f%11.3f%11.3f%11.3f ',Table(1,:)))
      disp(sprintf('    C-Dist      %8.3f%12.3f%11.3f%11.3f%11.3f ',Table(2,:)))
      disp(sprintf('    Other Dist  %8.3f%12.3f%11.3f%11.3f%11.3f ',Table(3,:)))
      disp(sprintf('    Labor       %8.3f%12.3f%11.3f%11.3f%11.3f ',Table(4,:)))
      disp(sprintf('    Consumption %8.3f%12.3f%11.3f%11.3f%11.3f ',Table(5,:)))
      disp(sprintf('  Transfers     %8.3f%12.3f%11.3f%11.3f%11.3f ',Table(6,:)))
      disp(sprintf('    To workers  %8.3f%12.3f%11.3f%11.3f%11.3f ',Table(7,:)))
      disp(sprintf('    To retirees %8.3f%12.3f%11.3f%11.3f%11.3f ',Table(8,:)))
      disp('Policy Inputs: ')
      disp(sprintf('  Cons. share   %8.3f%12.3f%11.3f%11.3f%11.3f ',Table(9,:)))
      disp(sprintf('  Labor share   %8.3f%12.3f%11.3f%11.3f%11.3f ',Table(10,:)))
      disp(sprintf('  Capital/GNP   %8.2f%12.2f%11.2f%11.2f%11.2f ',Table(11,:)))
      disp(sprintf('    Tangible    %8.2f%12.2f%11.2f%11.2f%11.2f ',Table(12,:)))
      disp(sprintf('      Sched C   %8.2f%12.2f%11.2f%11.2f%11.2f ',Table(13,:)))
      disp(sprintf('      Other     %8.2f%12.2f%11.2f%11.2f%11.2f ',Table(14,:)))
      disp(sprintf('    Intangible  %8.2f%12.2f%11.2f%11.2f%11.2f ',Table(15,:)))
      disp(sprintf('  Labor input   %8.2f%12.2f%11.2f%11.2f%11.2f ',Table(16,:)))
      disp(sprintf('  GNP           %8.2f%12.2f%11.2f%11.2f%11.2f ',Table(17,:)))
      disp(sprintf('  Net worth     %8.2f%12.2f%11.2f%11.2f%11.2f ',Table(18,:)))
      disp(sprintf('  Interest rate %8.2f%12.2f%11.2f%11.2f%11.2f ',Table(19,:)))
      disp(sprintf('  Welfare gain  %8.2f%12.2f%11.2f%11.2f%11.2f ',Table(20,:)))
      disp('=========================================================================')
      disp(' ')
      disp(' ')
     
      if printtex==1;
        for i=1:10;
          disp(sprintf('&& %8.3f&& %8.3f&& %8.3f&& %8.3f&& %8.3f&\\cr',Table(i,:)))
        end;
        for i=11:20;
          disp(sprintf('&& %8.2f&& %8.2f&& %8.2f&& %8.2f&& %8.2f&\\cr',Table(i,:)))
        end;
      end;

    end;
  end;
  diary


end;
