% compute CI for Pareto exponent using Ibragimov and Mueller 2010

level = 0.05 ;
tableUS = zeros(10,4) ;

if country == 1 % US
%%% post WWII
for i = 1:10
   if i==1||i==2
      id = (29+i:10:99+i) ; %%% post WWII
   else
      id = (29+i:10:89+i) ; %%% post WWII
   end
   T = length(id) ;
   
   a_hat = Alpha(id',1) ; % CMD using 1%share
   a_bar = mean(a_hat) ;
   sig = sqrt(sum((a_hat-a_bar).^2)/(T-1)) ;
   tableUS(i,1) = a_bar - sig/sqrt(T)*tinv(1-level/2,T-1) ;
   tableUS(i,2) = a_bar + sig/sqrt(T)*tinv(1-level/2,T-1) ;

   a_hat = AlphaSimple(id') ;
   a_bar = mean(a_hat) ;
   sig = sqrt(sum((a_hat-a_bar).^2)/(T-1)) ;
   tableUS(i,3) = a_bar - sig/sqrt(T)*tinv(1-level/2,T-1) ;
   tableUS(i,4) = a_bar + sig/sqrt(T)*tinv(1-level/2,T-1) ;
end

elseif country ==2 % France

tableFrance = zeros(10,4) ;
for i = 1:10
   if i<10
      id = (33+i:10:93+i) ; %%% post WWII
   else
      id = (33+i:10:83+i) ; %%% post WWII
   end
  
   T = length(id) ;
   
   a_hat = Alpha(id',1) ; % CMD using 1%share
   a_bar = mean(a_hat) ;
   sig = sqrt(sum((a_hat-a_bar).^2)/(T-1)) ;
   tableFrance(i,1) = a_bar - sig/sqrt(T)*tinv(1-level/2,T-1) ;
   tableFrance(i,2) = a_bar + sig/sqrt(T)*tinv(1-level/2,T-1) ;

   a_hat = AlphaSimple(id') ;
   a_bar = mean(a_hat) ;
   sig = sqrt(sum((a_hat-a_bar).^2)/(T-1)) ;
   tableFrance(i,3) = a_bar - sig/sqrt(T)*tinv(1-level/2,T-1) ;
   tableFrance(i,4) = a_bar + sig/sqrt(T)*tinv(1-level/2,T-1) ;
end

end