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]

st: RE: Creating Peer Scores


From   Lance Erickson <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: Creating Peer Scores
Date   Tue, 30 Jul 2013 15:24:57 +0000

If I understand what you're hoping to do, you need to use the -egen- command...

egen alldelinq = rowmean(FRID1, FRID2, FRID3...)

This will return the variable "alldelinq" that is the mean of all existing friends. I don't think I would use the sum in this case because respondents with few friends will tend to have lower scores than those with more friends. For example, a respondent with a single friend with delinquency of 10 would get the same score as another respondent with 10 friends each of which has a score of 1. But if that's what you want then you need to use -rowtotal- rather than -rowmean-.

Lance


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Bobby Jo Otto
Sent: Tuesday, July 30, 2013 8:51 AM
To: [email protected]
Subject: st: Creating Peer Scores

-----------------------------
Hello,

I have data in which a primary respondent (RESPID) has listed up to ten friends who have each been assigned their own individual ID scores (FRID1, FRID2, FRID3...). Like the primary respondent, the friends have all answered questions about their behavior and activities, and I created a score called DELINQ to measure these activities.  I would like to combine the scores for all of the friends (as many as ten) to develop a "peer" score for the primary respondent on the DELINQ variable, presumably by summing the DELINQ variable for all of the friends listed by the primary respondent.

I tried a loop code (see below), but since some of the primary respondents have not listed friends, the code didn't work (the error message was that the DELINQ variable wasn't found). Below I provide an example of what the data looks like and the code that I tried to use.

RESPID    FR1ID   FR2ID   FR3ID     DELINQ
1                    7       10         2              3
2                    5         .          .              1
3                     8       5          .              6
4                     .       .          10             0
5                     4       7          1            14
6                         .       .        5            8
7                     10      3          5            11
8                       .       .          8            13
9                       .       .          4             5
10                    9       .          7              2

As you can see, not everyone nominated a friend.  Does anyone know how I can create this peer score?  A second issue is that I need to weight the peer delinquency scores based on the number of friends included in the score?  How could the code be adjusted for this?  Any help would be much appreciated. I am using Stata version 11.2.

Previous Coding:

gen PEER_DELINQ = .
forvalues i=1/`=_N' {

        local f1 = FR1ID[`i']
        local f2 = FR2ID[`i']
        local f3 = FR3ID[`i']

        replace PEER_DELINQ = DELINQ[`f1'] + DELINQ[`f2'] + DELINQ[`f3'] in `i'

}



Thanks in advance.
------------------------------
*
*   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