Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • HHI index (or any concentration / inequality index) from a tab command

    Hi, I'm trying to calculate HHI indexes starting from a tab command.
    Manually, I just grab the percentages and put them in the new variable; but I wonder if there is a way to automate the process. In my data I have to do this 40 times (I have 2 sectors and 20 regions)!

    Code:
    sysuse auto
    tab foreign
    gen hhi=70.27^2 + 29.73^2
    sum hhi

  • #2
    Search the forum for mentions of HHI or of commands to calculate it such as entropyetc from SSC.


    Code:
    . sysuse auto, clear 
    
    . entropyetc foreign, gen(4=HHI)
    
    . l HHI in 1
    
         +----------+
         |      HHI |
         |----------|
      1. | .5821767 |
         +----------+
    
    . tab foreign
    
     Car origin |      Freq.     Percent        Cum.
    ------------+-----------------------------------
       Domestic |         52       70.27       70.27
        Foreign |         22       29.73      100.00
    ------------+-----------------------------------
          Total |         74      100.00
    
    . di 70.27^2 + 29.73^2
    5821.7458
    In your case, you presumably want to use the by() option. Multiplication by 10000 is something that you would have to do yourself.

    Comment

    Working...
    X