%
% Construct transition matrix for LBD data
%

lfo    = xlsread('../RawData/DP/lfo_transition','pay weighted');

c2c    = lfo(1:6:192,3);
c2p    = lfo(1:6:192,5);
c2s    = lfo(1:6:192,6);
c2sc   = lfo(1:6:192,7);

sc2c   = lfo(5:6:192,3);
sc2p   = lfo(5:6:192,5);
sc2s   = lfo(5:6:192,6);
sc2sc  = lfo(5:6:192,7);

p2c    = lfo(3:6:192,3);
p2p    = lfo(3:6:192,5);
p2s    = lfo(3:6:192,6);
p2sc   = lfo(3:6:192,7);

s2c    = lfo(4:6:192,3);
s2p    = lfo(4:6:192,5);
s2s    = lfo(4:6:192,6);
s2sc   = lfo(4:6:192,7);

ctot   = c2c+c2sc+c2p+c2s;
sctot  = sc2c+sc2sc+sc2p+sc2s;
ptot   = p2c+p2sc+p2p+p2s;
stot   = s2c+s2sc+s2p+s2s;

tabs   = [s2s,s2p,s2sc,s2c]./(stot*ones(1,4))*100;
tabp   = [p2s,p2p,p2sc,p2c]./(ptot*ones(1,4))*100;
tabsc  = [sc2s,sc2p,sc2sc,sc2c]./(sctot*ones(1,4))*100;
tabc   = [c2s,c2p,c2sc,c2c]./(ctot*ones(1,4))*100;
tab    = [mean(tabs);mean(tabp);mean(tabsc);mean(tabc)];


disp('Payroll-weighted Transition Matrix (Continuing businesses)')
disp('==========================================================')
disp(' ') 
disp('                                    In t+1:')
disp('  In t:          Proprietor    Partner      S-Corp     C-Corp')
disp(sprintf(' Proprietor  %12.1f%12.1f%12.1f%12.1f',tab(1,:)))
disp(sprintf(' Partner     %12.1f%12.1f%12.1f%12.1f',tab(2,:)))
disp(sprintf(' S-Corp      %12.1f%12.1f%12.1f%12.1f',tab(3,:)))
disp(sprintf(' C-Corp      %12.1f%12.1f%12.1f%12.1f',tab(4,:)))
disp(' ')
disp(' ')
disp('Source:')
disp('  Dyrda and Pugsley (2019)')
disp('  Taxes, Private Equity, and Evolution of Income Inequality in the US')


