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: loops for regions


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: loops for regions
Date   Wed, 5 Sep 2012 23:35:02 +0100

Did you try

findit lilien

Someone may recognise this, but you give no reference or definition.

Nick

On Wed, Sep 5, 2012 at 9:52 PM, Chiara Mussida <[email protected]> wrote:
> tried to write my own file since the next step will be, as i hope, to
> compute a Lilien index for each region. I tried to search for a stata
> program but i did not succeed. Does anybody know whether it exists?
> Thanks
>
> On 05/09/2012, Nick Cox <[email protected]> wrote:
>> The first line confuses the -if- command and the -if- qualifier.
>>
>> I didn't look in detail at later code, as there should be no need to
>> write your own code, as many programs exist. -search inequality- for a
>> start. See also e.g. -ineq- (SSC), -hhi- (SSC).
>>
>> In fact, in many ways this is a calculator problem easily tackled with
>> Mata.
>>
>> . mata
>> : freq = (0, 0, 3, 9, 9)
>> : pr = freq :/ sum(freq)
>> : sum(pr:^2)
>>   .387755102
>>
>> In fact, zero frequencies map to zero squared proportions and can be
>> omitted.
>>
>> This index, although often attributed to Herfindahl by economists who
>> know only their only literature, was in essence invented decades
>> before by Gini. I don't have the reference in my head, but I think it
>> is in Bishop, Y., Fienberg, S.E. and Holland, P.W. 1975. Discrete
>> multivariate analysis. Cambridge, MA: MIT Press. Please trump me by
>> providing a yet earlier reference.
>>
>> Nick
>>
>> On Wed, Sep 5, 2012 at 5:15 PM, Chiara Mussida <[email protected]> wrote:
>>
>>> I want to generate a variable herf1 which takes the value of the below
>>> index for region 1, and thereafter repeat this loop for all the region
>>> in my dataset. The problem is that with the below command I get the
>>> herf1 index for region 1, which is identycal in value (I tried) to the
>>> herf2 for region2 whether I repeat this llop for region2, by starting
>>> with "if reg==2, and so forward for all the regions.
>>>
>>> if reg==1 {
>>> tab cat12_2, gen(categ)
>>> forvalues k = 1 2 to 12 {
>>> sum categ`k', meanonly
>>>         gen share`k'=r(mean) if reg==1 /*shares of each occ cat on the
>>> total
>>> occupation, time t*/
>>> }
>>> }
>>>
>>> gen herf1=(share1)^2 + (share2)^2 + (share3)^2 + (share4)^2 +
>>> (share5)^2 + (share6)^2 + (share7)^2 + (share8)^2 ///
>>> + (share9)^2 + (share10)^2 + (share11)^2 + (share12)^2  /*Herfindhal
>>> Index Region1*/
>>> the variable reg takes 1 for region1, 2 for region2...up to 20 for
>>> region20. In other words, Stata does not compute the specific index
>>> for each region, but the same index region by region.
>> *
>> *   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/
>>
>
>
> --
> Chiara Mussida
> PhD candidate
> Doctoral school of Economic Policy
> Catholic University, Piacenza (Italy)
> *
> *   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/


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