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: Re: Creating a Peer-Variable excluding the focal entity


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Re: Creating a Peer-Variable excluding the focal entity
Date   Wed, 26 Mar 2014 16:03:55 +0000

Thanks; that helps greatly.

Also, I can see on checking that I misread your example, so sorry about that.

The code you want is

egen total = total(V), by(sector year)
egen count = count(V), by(sector year)
gen peer = (total - V)/(count - 1)

Note that this just the principle

mean of others = (sum of all - this value) / (count of all - 1)

spelled out at length in
http://www.stata.com/support/faqs/data-management/creating-variables-recording-properties/
which I referred you to earlier.

If there are any missing values on V, you need instead

gen peer = (total - cond(missing(V), 0, V)) / (count - cond(missing(V), 0, 1))

OR

gen peer = (total - V) / (count - 1)
replace peer = total/count if missing(V)




.
Nick
[email protected]


On 26 March 2014 14:18, Houdou Basse Mama <[email protected]> wrote:
> Many thanks Nick for your guidance.
>
> I would like to specify my question. Suppose, you have 7 firms belonging to two different sectors 1 and 2. Each firm-year observation is associated with a media visibility measure. What I want ot compute is the variable "Peer Visibility" as I did it for Firm 1 over the period 2009-2013. This latter variable is industry-year computed and varies over the 7 firms. I append an example below:
>
> firm    year    sector  Visibility      Peer Visibility
> 1       2009    1       4.2             4.7
> 1       2010    1       9.7             9.6
> 1       2011    1       5.2             4.2
> 1       2012    1       9.3             9.5
> 1       2013    1       6.1             5
> 2       2009    1       4.6
> 2       2010    1       9.4
> 2       2011    1       4.6
> 2       2012    1       9.3
> 2       2013    1       4.9
> 3       2009    1       4.8
> 3       2010    1       9.8
> 3       2011    1       3.8
> 3       2012    1       9.7
> 3       2013    1       5.1
> 4       2009    2       5.2
> 4       2010    2       9.3
> 4       2011    2       3.6
> 4       2012    2       9.2
> 4       2013    2       6.3
> 5       2009    2       7
> 5       2010    2       9.1
> 5       2011    2       3.5
> 5       2012    2       9.2
> 5       2013    2       7.3
> 6       2009    2       6.9
> 6       2010    2       9.5
> 6       2011    2       4.4
> 6       2012    2       9.1
> 6       2013    2       7
> 7       2009    2       6.9
> 7       2010    2       9.7
> 7       2011    2       4.6
> 7       2012    2       9
> 7       2013    2       6.8
>
> I hope I could specify the issue. Thanks in advance for your help
> Houdou
>
>
> ----- Ursprüngliche Mail -----
> Von: "Houdou Basse Mama" <[email protected]>
> An: [email protected]
> Gesendet: Dienstag, 25. März 2014 11:33:10
> Betreff: Creating a Peer-Variable excluding the focal entity
>
> Dear Statalist,
>
> Could you please provide assistance. I attempt (with no success) to create a peer group variable each period excluding a focal firm j. Suppose I want to regress a firm's outcome (y_jit) on a vector X that contains two variables. The outcome y_jit should be regressed on X_jit and X_-jit, where the former varibale denotes the a firm-specific determinant of Y_jit and a peer group counterpart, respectively. I need to construct the peer group variable (X_-jit) that excludes the firm itself.
>
> Assume a variable "visibility" that is firm-specific. I want to compute a peer-counterpart for this firm-specific variable using industry affiliation as peer group. Call this new variable "peer_visibility". The computed variable should be industry-year computed.
>
> I have read the points made in the thread in statalist since October through December 2013 but still cannot solve the problem. Many thanks in advance for your help.
>
> Best and many thanks for your time
>
> Houdou
> ESCP Europe Berlin Campus
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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