Announcement

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

  • Herfindahl-Hirschman Index (HHI)

    Hi All,

    I am trying to calculate the HHI based on the number of vendors in a certain location by year. My data is arranged as below. Each row corresponds to the technology installed. The column “compcode” indicates the vendor installing the technology. The column “vdcname” indicates the location where the vendor installed the technology. “fiscal_year” is the year the technology was installed. The formula for the HHI = S12 + S22 + S32+ ……..+ Sn2, where Si = market share for a vendor. Therefore, Si relates to counting the distinct number of vendors and dividing it by the total count of vendors in that location for that particular year. Once we get that share of the market, then the rest is straightforward, which is squaring each Si and adding it up for the location for that year. The idea is if the HHI varies with the years and to get it as part of the data for each year.

    copy starting from the next line ------ ----------------
    Code:
    * Example generated by -dataex-. To install: ssc install    dataex
    clear
    input long vdcname float fiscal_year1 long compcode
    1388 2006 168
    1388 2013  96
    1388 2013  96
    1388 2013  96
    2538 2006 168
    2538 2007 168
    2538 2013  96
    2538 2013  96
    2538 2013  96
    2538 2013  96
    2607 2007 168
    2607 2007 168
    1746 2012  96
    1746 2012  96
    1746 2012  96
    1746 2013  96
    1746 2013  96
    1746 2013  96
    1746 2013  96
    end
    label values vdcname vdcname
    label def vdcname 1388 "Khewang", modify
    label def vdcname 1746 "Mehel", modify
    label def vdcname 2538 "Surumakhim", modify
    label def vdcname 2607 "Tel Lok", modify
    label values compcode compcode
    label def compcode 96 "MGC", modify
    label def compcode 168 "TPG", modify
    copy up to and including the previous line - ----------------
    Listed 19 out of 368945 observations

    I would be much thankful for any help.

    Samir

  • #2
    There are probably of the order of a hundred threads since 2014 on this measure, under this or any other name. (It goes back long before Herfindahl or Hirschman, but there you go.) Still, it might take a long search to find one that is precisely in this format.

    If I understand this correctly,this should help:

    Code:
    * Example generated by -dataex-. To install: ssc install    dataex
    clear
    input long vdcname float fiscal_year1 long compcode
    1388 2006 168
    1388 2013  96
    1388 2013  96
    1388 2013  96
    2538 2006 168
    2538 2007 168
    2538 2013  96
    2538 2013  96
    2538 2013  96
    2538 2013  96
    2607 2007 168
    2607 2007 168
    1746 2012  96
    1746 2012  96
    1746 2012  96
    1746 2013  96
    1746 2013  96
    1746 2013  96
    1746 2013  96
    end
    label values vdcname vdcname
    label def vdcname 1388 "Khewang", modify
    label def vdcname 1746 "Mehel", modify
    label def vdcname 2538 "Surumakhim", modify
    label def vdcname 2607 "Tel Lok", modify
    label values compcode compcode
    label def compcode 96 "MGC", modify
    label def compcode 168 "TPG", modify
    
    bysort fiscal_year1 vdcname compcode : gen numer = _N if _n == 1 
    by fiscal_year1 vdcname : gen denom = _N 
    by fiscal_year1 vdcname : egen HHI = total((numer/denom)^2) 
    format HHI %4.3f 
    tabdisp vdcname fiscal_year1, c(HHI)
    
    
    --------------------------------------
               |        fiscal_year1       
       vdcname |  2006   2007   2012   2013
    -----------+---------------------------
       Khewang | 1.000                1.000
         Mehel |               1.000  1.000
    Surumakhim | 1.000  1.000         1.000
       Tel Lok |        1.000              
    ---------------------------------------
    The example seems to boil down to monopolies in each combination, but I hope the principle is right It's very important to count each category just once.

    Comment


    • #3
      Thank you so much, Nick.

      Comment

      Working...
      X