%FIGURES   Displays figures for McGrattan and Schmitz, ``Explaining
%          Cross-Country Income Differences,'' Handbook of Macroeconomics. 
%

%          Ellen McGrattan, 6-12-98


fig = input('Which figures would you like displayed?  ');


% FIGURE 1.

  if any(fig==1);
    load mad94.dat
    t   = mad94(1,:);
    y   = mad94([2:15,17:23,25:30,32:40,42:48],:);
    i   = find(~isnan(y(:,1)));
    semilogy(t,y(i,:),'o')
    title('Fig. 1. GDP Per Capita, 1820-1989')
    xlabel('Year'), ylabel('GDP Per Capita')
    pause(2)

% FIGURE 1, insert.

    load rgdpch.dat
    y   = rgdpch(:,40);
    i   = find(~isnan(y));
    n   = length(i);
    ry  = y(i)/gmean(y(i));
    hist0(ry)
    title('1989 Relative GDP Per Capita (World Average = 1)')
    ylabel('% of countries')
    pause(2)
  end;


% FIGURE 2.

  if any(fig==2);
    load rgdpw.dat
    load ckm_index.dat
    i   = ckm_index;
    n   = length(i);
    y   = rgdpw(i,11:36);
    ry  = y(:,1)/gmean(y(:,1));
    g   = ((y(:,26)./y(:,1)).^(1/25)-1)*100;
    plot(log(ry),g,'o')
    title('Fig. 2. Growth versus Initial GDP Per Worker, 1960-1985');
    xlabel('Relative GDP Per Worker in 1960')
    ylabel('Growth Rate of GDP Per Worker, 1960-85')
    pause(2)
  end;


% FIGURE 3

  if any(fig==3);
    load rgdpw.dat
    load ckm_index.dat
    i   = ckm_index;
    y   = rgdpw(i,11:36);
    g1  = ( (y(:,13)./y(:,1)) .^(1/12)-1)*100;
    g2  = ( (y(:,26)./y(:,13)).^(1/13)-1)*100;
    plot(g1,g2,'o')
    title('Fig. 3. Persistence of Growth Rates, 1960-1985');
    xlabel('Growth Rates of GDP Per Worker, 1961-72')
    ylabel('Growth Rates of GDP Per Worker, 1973-85')
    pause(2)
  end


% FIGURE 4

  if any(fig==4);
    load mad91.dat
    load rgdpch.dat
    t   = mad91(1:120,1);
    GDP = [mad91(1:120,2:9),mad91(121:240,2:9)];
    POP = [mad91(241:360,2:9),mad91(361:480,2:9)];
    gm  = maxnan(1/10*(log(GDP(11:10:120,:))-log(GDP(1:10:110,:)))' - ...
                 1/10*(log(POP(11:10:120,:))-log(POP(1:10:110,:)))' ) *100;
    T   = t(11:10:120);
    gs  = maxnan(1/10*(log(rgdpch(:,11:10:41))-log(rgdpch(:,1:10:31)))) * 100;
    labels = ['USA        '
              'CANADA     '
              'CANADA     '
              'CANADA     '
              'JAPAN      '
              'AUSTRIA    '
              'JAPAN      '
              'SWITZERLAND'
              'JAPAN      '
              'JAPAN      '
              'JORDAN     '
              'KOREA      '];
    plot(T(1:9),gm(1:9),1960:10:1990,gs)
    for i=1:9;
      text(T(i),gm(i),labels(i,:));
    end;
    text(1970,gs(2),labels(10,:))
    text(1980,gs(3),labels(11,:))
    text(1990,gs(4),labels(12,:))
    title('Fig. 4. Maximum GDP Per Capita Growth, 1870-1990')
    xlabel('Year'),ylabel('Maximum Growth Rate Over Decade (%, a.r.)')
    pause(2)
  end


% FIGURE 5

  if any(fig==5)
    load rgdpw.dat
    load rgdpch.dat
    load pop.dat
    load i.dat
    load ckm_index.dat
    j      = ckm_index;
    iky    = i(j,11:36)/100;
    gdp    = rgdpch(j,11:36).*pop(j,11:36);
    ik     = iky.*gdp;
    del    = 0.06;
    Del    = ones(125,1)*(1-del).^([24:-1:0]);
    ky     = sum( (Del.*ik(:,1:25))' )' ./ ( 1-(1-del)^25*gdp(:,1)./gdp(:,26) );    ky     = ky./gdp(:,26);
    y      = rgdpw(j,36);
    ry     = y/gmean(y);
    plot(log(ry),ky,'o')
    title('Fig. 5. Physical Capital-Output Ratio vs. Income, 1985')
    xlabel('Relative GDP Per Worker in 1985')
    ylabel('Physical Capital-Output Ratio, 1985')
    pause(2)
  end


% FIGURE 6
  
  if any(fig==6)
    load rgdpw.dat
    load ckm_index.dat
    load bl_index.dat
    load enrols.prn
    [nr,nc] = size(enrols);
    Enrols  = NaN*zeros(153,nc);
    Enrols(bl_index,:) = enrols;
    i       = ckm_index;
    s       = avgnan(Enrols(i,1:6)')';
    y       = rgdpw(i,36);
    ry      = y/gmean(y);
    plot(log(ry),s,'o')
    title('Fig. 6. Secondary Enrollment vs. Income, 1960-1985')
    xlabel('Relative GDP Per Worker in 1985')
    ylabel('Average Fraction Enrolled, 1960-85')
    pause(2)
  end


% FIGURE 7

  if any(fig==7)
    load rgdpw.dat
    load ckm_index.dat
    load bl_index.dat
    load enrolp.prn
    [nr,nc] = size(enrolp);
    Enrolp  = NaN*zeros(153,nc);
    Enrolp(bl_index,:) = enrolp;
    i       = ckm_index;
    p       = avgnan(Enrolp(i,1:6)')';
    y       = rgdpw(i,36);
    ry      = y/gmean(y);
    plot(log(ry),p,'o')
    title('Fig. 7. Primary Enrollment vs. Income, 1960-1985')
    xlabel('Relative GDP Per Worker in 1985')
    ylabel('Average Fraction Enrolled, 1960-85')
    pause(2)
  end


% FIGURE 8

  if any(fig==8)
    load rgdpw.dat
    load rgdpch.dat
    load pop.dat
    load i.dat
    load bl_index.dat
    load ckm_index.dat
    load enrols.prn
    load human.prn
    load ckm_pop.dat
    j      = ckm_index;
    iky    = i(j,11:36)/100;
    gdp    = rgdpch(j,11:36).*pop(j,11:36);
    ik     = iky.*gdp;
    del    = 0.06;
    Del    = ones(125,1)*(1-del).^([24:-1:0]);
    ky     = sum( (Del.*ik(:,1:25))' )' ./ ( 1-(1-del)^25*gdp(:,1)./gdp(:,26) );    ky     = ky./gdp(:,26);
    y      = rgdpw(j,36);
    ry     = y/gmean(y);
    [nr,nc] = size(enrols);
    Enrols  = NaN*zeros(153,nc);
    Enrols(bl_index,:) = enrols;
    s60    = Enrols(j,1);
    s65    = Enrols(j,2);
    s70    = Enrols(j,3);
    s75    = Enrols(j,4);
    s80    = Enrols(j,5);
    s85    = Enrols(j,6);
    pop_60 = ckm_pop(:,4:13);
    pop_65 = ckm_pop(:,16:25);
    pop_70 = ckm_pop(:,28:37);
    pop_75 = ckm_pop(:,40:49);
    pop_80 = ckm_pop(:,52:61);
    pop_85 = ckm_pop(:,64:73);
    aihy   = [s60 .* pop_60(:,1)./sum(pop_60')',  ...
              s65 .* pop_65(:,1)./sum(pop_65')',  ...
              s70 .* pop_70(:,1)./sum(pop_70')',  ...
              s75 .* pop_75(:,1)./sum(pop_75')',  ...
              s80 .* pop_80(:,1)./sum(pop_80')',  ...
              s85 .* pop_85(:,1)./sum(pop_85')'];
    aihy   = avgnan(aihy')';
    l      = rgdpch(j,11:36)./rgdpw(j,11:36) .*pop(j,11:36);
    lg     = ((l(:,26)./l(:,1)).^(1/25)-1)*100;
    delta  = 0.03;
    g      = 0.02;
    den    = (1+g)*(1+lg/100)-1+delta;
    hy_mrw = aihy./den;
    Human  = NaN*zeros(153,nc);
    Human(bl_index,:) = human;
    s      = Human(j,6);
    s(2)   = 3.099;            % Hall-Jones imputed values
    s(5)   = 3.790;
    s(6)   = 2.001;
    s(8)   = 3.329;
    s(10)  = 2.602;
    s(11)  = 3.024;
    s(13)  = 5.097;
    s(14)  = NaN;
    s(15)  = 2.255;
    s(18)  = 2.360;
    s(20)  = 2.928;
    s(24)  = 3.972;
    s(27)  = 2.518;
    s(29)  = 5.070;
    s(31)  = 3.414;
    s(33)  = 1.464;
    s(34)  = 3.913;
    s(37)  = 2.227;
    s(38)  = 2.288;
    s(60)  = 4.625;
    s(72)  = 2.103;
    s(76)  = 6.005;
    s(91)  = 4.808;
    s(100) = 7.880;
    s(109) = 8.596;
    s(114) = 5.618;
    s(120) = 7.349;
    gam1   = .095;
    gam2   = .0495;
    gam3   = -.0007;
    ex     = (exp(gam2*(27-s-6)+gam3*(27-s-6).^2).*pop_85(:,3)+ ...
              exp(gam2*(32-s-6)+gam3*(32-s-6).^2).*pop_85(:,4)+ ...
              exp(gam2*(37-s-6)+gam3*(37-s-6).^2).*pop_85(:,5)+ ...
              exp(gam2*(42-s-6)+gam3*(42-s-6).^2).*pop_85(:,6)+ ...
              exp(gam2*(47-s-6)+gam3*(47-s-6).^2).*pop_85(:,7)+ ...
              exp(gam2*(52-s-6)+gam3*(52-s-6).^2).*pop_85(:,8)+ ...
              exp(gam2*(57-s-6)+gam3*(57-s-6).^2).*pop_85(:,9)+ ...
              exp(gam2*(62-s-6)+gam3*(62-s-6).^2).*pop_85(:,10))./ ...
              sum(pop_85(:,3:10)')';
    s_kr   = exp(gam1*s).*ex;
    alpk   = 0.30;
    alph   = 0.28;
    a_kr   = rgdpw(j,36)./(ky.^(alpk/(1-alpk)).*s_kr);
    hy_kr  = a_kr.*(s_kr).^((1-alpk)/alph) ./ rgdpw(j,36);
    hy_kr  = real(hy_kr);
    plot(log(ry),hy_mrw/hy_mrw(62),'o',log(ry),hy_kr/hy_kr(62),'+')
    title('Fig. 8. Human Capital-Output Ratio vs. Income, 1985')
    xlabel('Relative GDP Per Worker in 1985')
    ylabel('Human Capital-Output Ratio, 1985 (U.S. = 1)')
    pause(2)
  end

% FIGURE 9

  if any(fig==9)
    load rgdpch.dat
    load gvxdxe.prn
    load ckm_index.dat
    load bl_index.dat
    i           = ckm_index;
    y           = rgdpch(i,36);
    ry          = y/gmean(y);
    [nr,nc]     = size(gvxdxe);
    Gvxdxe      = NaN*zeros(153,nc);
    Gvxdxe(bl_index,:) = gvxdxe;
    gvxdxe65_84 = avgnan(Gvxdxe(i,18:21)')';
    plot(log(ry),gvxdxe65_84,'o')
    c = cornan([log(ry),gvxdxe65_84]);
    title('Fig. 9. Government Share vs. Income, 1965-1985')
    xlabel('Relative GDP Per Capita in 1985')
    ylabel('Average Government Share of GDP, 1965-84')
    pause(2)
  end


% FIGURE 10

  if any(fig==10)
    load rgdpch.dat
    load bmp.prn
    load ckm_index.dat
    load bl_index.dat
    i           = ckm_index;
    y           = rgdpch(i,36);
    ry          = y/gmean(y);
    [nr,nc]     = size(bmp);
    Bmp         = NaN*zeros(153,nc);
    Bmp(bl_index,:) = bmp;
    bmpl65_84   = avgnan(Bmp(i,8:11)')';
    plot(log(ry),bmpl65_84,'o')
    c = cornan([log(ry),bmpl65_84]);
    title('Fig. 10. Black Market Premium vs. Income, 1965-85')
    xlabel('Relative GDP Per Capita in 1985')
    ylabel('Log(1+Black Market Premium), 1965-84')
    pause(2)
  end


% FIGURE 11

  if any(fig==11)
    load rgdpch.dat
    load pinstab.prn
    load ckm_index.dat
    load bl_index.dat
    i       = ckm_index;
    y       = rgdpch(i,36);
    ry      = y/gmean(y);
    [nr,nc] = size(pinstab);
    Pinstab = NaN*zeros(153,nc);
    Pinstab(bl_index,:) = pinstab;
    prightsb= avgnan(Pinstab(i,8:10)')';
    plot(log(ry),prightsb,'o')
    c = cornan([log(ry),prightsb]);
    title('Fig. 11. Political Rights vs. Income, 1972-1985')
    xlabel('Relative GDP Per Capita in 1985')
    ylabel('Index of Political Rights, 1972-84 (1=most freedom)')
    pause(2)
  end


% FIGURE 12

  if any(fig==12)
    load rgdpch.dat
    load bmp.prn
    load ckm_index.dat
    load bl_index.dat
    i         = ckm_index;
    y         = rgdpch(i,36);
    ry        = y/gmean(y);
    [nr,nc]   = size(bmp);
    Bmp       = NaN*zeros(153,nc);
    Bmp(bl_index,:) = bmp;
    lly65_84  = avgnan(Bmp(i,20:23)')';
    plot(log(ry),lly65_84,'o')
    c = cornan([log(ry),lly65_84]);
    title('Fig. 12. Financial Development vs. Income, 1965-85')
    xlabel('Relative GDP Per Capita in 1985')
    ylabel('Measure of Liquid Liabilities to GDP, 1965-84')
    pause(2)
  end

% FIGURE 13

  if any(fig==13)
    load rgdpw.dat
    load pi.dat
    load pc.dat
    load ckm_index.dat
    i    = ckm_index;
    y    = rgdpw(i,36);
    rp   = pi(i,36)./pc(i,36);
    ry   = y/gmean(y);
    plot(log(ry),log(rp),'o');
    title('Fig. 13. Relative Price of Investment vs. Income, 1985')
    xlabel('Relative GDP Per Worker in 1985')
    ylabel('Relative Price of Investment to Consumption, 1985')
    pause(2)
  end


% FIGURE 14

  if any(fig==14)
    load rgdpw.dat
    load ckm_index.dat
    load pubent.dat
    i     = ckm_index;
    j     = pubent(:,1);
    yr1   = pubent(:,2)-1959;
    yr2   = pubent(:,3)-1959;
    pe    = pubent(:,4);
    ry    = rgdpw(i,11:36)./(ones(125,1)*gmean(rgdpw(i,11:36)));
    y     = zeros(length(j),1);
    for k=1:length(j);
      l    = find(j(k) == i);
      y(k) = mean(ry(l,yr1(k):yr2(k))');
    end;
    y     = y(:);
    plot(log(y),pe,'o')
    title('Fig. 14. Public Enterprise Share vs. Income, Various Years')
    xlabel('Relative GDP Per Worker in 1985')
    ylabel('Public Enterprise Share of Manufacturing (%, Various Years)')
    pause(2)
  end


% FIGURE 15

  if any(fig==15)
    load rgdpw.dat
    load bmp.prn
    load ckm_index.dat
    load bl_index.dat
    i       = ckm_index;
    y       = rgdpw(i,31);
    ry      = y/gmean(y);
    [nr,nc] = size(bmp);
    Bmp     = NaN*zeros(153,nc);
    Bmp(bl_index,:) = bmp;
    owti    = Bmp(i,13);
    plot(log(ry),owti,'o')
    title('Fig. 15. Tariff Rates vs. Income, 1980')
    xlabel('Relative GDP Per Worker in 1980')
    ylabel('Tariff Rate in 1980')
    pause(2)
  end


% FIGURE 16

  if any(fig==16)
    load rgdpw.dat
    load funddet.dat
    load ckm_index.dat
    i       = ckm_index;
    y       = rgdpw(i,36);
    ry      = y/gmean(y);
    YrsOpen = funddet(i,12);
    plot(log(ry),YrsOpen,'o')
    title('Fig. 16. Fraction of Years Open vs. Income, 1950-94')
    xlabel('Relative GDP Per Worker in 1985')
    ylabel('Fraction of Years Open, 1950-94')
    pause(2)
  end

