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: data manipulation question


From   DC <[email protected]>
To   [email protected]
Subject   Re: st: data manipulation question
Date   Wed, 11 Aug 2010 11:01:36 -0400

Hi Scott,

Sorry if it is confusing.

move is binary for whether unit i (id) moved or not in that particular quarter.
Hence, for id=1, he doesn't move in quarter 2

What happens here is that id =1 does not move in quarter 2, so
therefore move = 0. However, in quarter 2
 the first nearest neighbor (id =2)  and second nearest neighbor
(id=3) moved and they were both of race 2. Hence,
I assigned the racial indicator for each nearest neighbor who moved to
move_nn1 and move_nn2.

In the next quarter, quarter 3, id =1 moved. In same quarter, nearest
neighbor 3 moved as well and he was also of race 2.
hence, I assigned 2 to move_nn3 to denote that nearest neighbor 3
moved and they were of race 2.

Perhaps,a better way to do it is to just assign a binary indicator for
whether nearest neighbor 1 and nearest neighbor 2
moved and put the race in a separate variable.

Thanks for any assistance.

Regards,
Marcus

On Wed, Aug 11, 2010 at 8:31 AM, Scott Merryman
<[email protected]> wrote:
> Perhaps you could explain in more detail how the move_nnj variables
> are generated in your example.
>
>  It is not clear why for id = 1, quarter = 2, move = 0 the move_nn1
> and move_nn2 = 2.  Then in quarter =3, move = 1 and now move_nn3 = 2?
>
> Scott
>
>
> On Tue, Aug 10, 2010 at 6:23 PM, DC <[email protected]> wrote:
>> Hi All,
>>
>> I have a question about the correct procedure to assign indicators of
>> events occurring to  nearest neighbors to individual identifiers .
>> Specifically, I have data that look something like this:
>>
>> id  race  quarter     move      nn1     nn2       nn3
>> 1      1          1          0          2          3         4
>> 1      1          2          0          2          3         4
>> 1      1          3          1          2          3         4
>> 2      0          1          0          1          4         3
>> 2      0          1          1          1          4         3
>> 3      0          1          0           5         1         4
>> 3      0          2          1           5         1         4
>> 4      0          1          0           3          2        5
>> 4      0          2          0           3          2        5
>> 4      0          3          1           3          2        5
>> 5      1          1          0            5        2         1
>> 5      1          2          1            5        2         1
>>
>> where id, race, quarter, and move are pretty straight forward. nn1,
>> nn2, nn3 denote a ranking of the 3  nearest neighbors to unit_ i.
>>
>> I would like to construct indicators first denoting whether unit_ i
>> saw a move in nn_ j in quarter_ t. Conditional on seeing a move  in
>> nn_ j
>> I would like to assign a racial indicator. In other words, something like this:
>>
>> id  race  quarter     move      nn1     nn2       nn3     move_nn1
>> move_nn2   move_nn3
>> 1      1          1          0          2          3         4
>>     0               0               0
>> 1      1          2          0          2          3         4
>>     2              2                0
>> 1      1          3          1          2          3         4
>>     0              0                2
>> 2      2          1          0          1          4         3
>>     0               0               0
>> 2      2          2          1          1          4         3
>>     0               0               2
>> 3      2          1          0           5         1         4
>>    0                0              0
>> 3      2          2          1           5         1         4
>>    1               0               0
>> 4      2          1          0           3          2        5
>>    0              0               0
>> 4      2          2          0           3          2        5
>>    2             2                1
>> 4      2          3          1           3          2        5
>>    0            0                0
>> 5      1          1          0            3        2         1
>>    0           0                 0
>> 5      1          2          1            3        2         1
>>     2            2                  0
>>
>>
>> It is a bit complicated. Any help would be greatly appreciated.
>>
>> Regards,
>> Marcus
>
> *
> *   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/
>



-- 
Marcus Casey, Ph.D.
Duke University

*
*   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