Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Computing Herfindahl-Hirschman index


From   Antoine Terracol <[email protected]>
To   [email protected]
Subject   Re: st: Computing Herfindahl-Hirschman index
Date   Wed, 08 Dec 2010 13:28:23 +0100

if you just want the hhi variables, you could either

. drop item*

at the end of the code

or

. drop item
. reshape wide hhi , i(importer) j(id_item)

within the code (i.e drop item before reshaping back, and ommit the item variable from the -reshape- command)


Antoine


On 08/12/2010 13:19, Syed Basher wrote:
Dear Antoine,

The second option is better and worked.

. reshape wide item hhi , i(importer) j(id_item)

The above command reports "item" and the associated "hhi" for all items. Suppose I want only the hhi, deleting item from the above reshape command doesn't work.

Thank you very very much.

Syed

--- On Wed, 12/8/10, Antoine Terracol<[email protected]>  wrote:

From: Antoine Terracol<[email protected]>
Subject: Re: st: Computing Herfindahl-Hirschman index
To: [email protected]
Date: Wednesday, December 8, 2010, 2:35 PM
Syed,

try

egen sum_item1=total(item1)
gen hhi_item1=(100*item1/sum_item1)^2

and so on for each item

or, alternatively

reshape long item, i(importer) j(id_item)

bysort id_item : egen sum=total(item)
gen hhi=item/sum
drop sum

reshape wide item hhi , i(importer) j(id_item)

which should give you all the results at once (I've not
checked the code)

Antoine

On 08/12/2010 12:11, Syed Basher wrote:
Dear Statalist,

I have the following (hypothetical) trade dataset
which contains imported items by importer.

importer  | item1 item2..... item20
-----------------------------------
11        |  10
   20        80
12
|   5       7
        9
13        |
      1
14
|   2
        6
...       |
20
|   8       9

I would like to obtain the following table/data:

importer  | item1
item2   .... item20
-------------------------------------------
11        |  1600
    2921.84
    7091.41
12
|   400      357.92
        89.75
13        |
         7.30
14        |    64

    39.88
...       |
20        |  1024
     591.67


where, say, the value 1600 is obtained using the
formula (si*100)^2, where si is the share of importer11 in
item1 and is obtained using 10/25,   25 is
the sum of all entries in item1. This will allow me to get
the  Herfindahl-Hirschman index by importer for each
item.

I hope any one of you can help. Thank you so mcuh.

Regards,

Syed Basher
Qatar National Food Security Program




*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


--
Ce message a ete verifie par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ete trouve.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/





*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


--
Ce message a ete verifie par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ete trouve.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index