[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: RE: Creating a Non-Self Mean (Score) |

Date |
Sun, 13 Jul 2008 17:34:05 +0100 |

You refer to the count option. There is a -count- command and a -count()- function for -egen-. I guess you mean the -count- command. As you say, it is not suitable for this purpose. But the -count()- function for -egen- is. In your example, the variable name -SumOthers- might confuse. I'll rename it: Obs Strata Response MeanOthers 1 1 3 2 2 1 1 3 1 2 4 2 1 5 2 3 6 1 3 You want egen Sum = total(Response), by(Strata) replace Sum = Sum - Response egen Count = count(Response), by(Strata) gen MeanOthers = Sum / (Count - 1) Another way to do it, which is explained in the FAQ cited, is egen Count = total(Response < .), by(Strata) For future publications note the tricky singular and plural, from Latin: one stratum, two or more strata. Nick n.j.cox@durham.ac.uk Chao Yawo Thanks for the suggestions. I was able to create (Sum of Others - This Value), as suggested, hence I have the numerator for creating the Mean of Others. However, I am running into a bit of a problem creating the denominator. Here is what my data looks like at the moment: Obs Strata SumOthers MeanOthers 1 1 3 2 2 1 1 3 1 2 4 2 1 5 2 3 6 1 3 The Mean for observation 1 = ([3+1+2+3]-3 / 4 - 1) = 2. That is, to the get the mean of others, I have to divide the "Sum of Others - This Value" by a denominator that counts the "number of observations within each strata - 1". I looked at the Count option, however, I realized that it saves it output as a scalar, hence I am unable to get the denominator required. > > From: Nick Cox <n.j.cox@durham.ac.uk> > > This is a FAQ. See > > > > FAQ . . Creating variables recording prop. of the > other > > members of a > > group > > 4/05 How do I create variables summarizing > for > > each > > individual properties of the other > members > > of a > > group? > > > > http://www.stata.com/support/faqs/data/members.html > > > > The key principle for sums is elementary > > > > Sum of others = Sum of all - This value > > > > And for means correspondingly > > > > Mean of others = (Sum of all - This value) / (Number > in > > group - 1) > > > > Other summary measures are more challenging, but the > FAQ > > gives advice. > > > > The only obvious complication is that you want to sum > > across variables > > before you summarize across the other members of this > > group. That will > > often be easiest through -egen, rowtotal()-. Chao Yawo > > I am examining the effect of stigmatizing attitudes of > > specific health > > behaviors, using a demographic health survey (DHS). > DHS > > respondents were > > required to indicate (by a YES, NO, DONT KNOW) > whether: > > > > (1) whether they would buy a vegetable from a vendor > who > > has HIV, (2) > > whether they would keep their family member's HIV > > infection a secret > > (3) whether they would be willing to care for a > relative > > who is infected > > with HIV > > (4) wheether a female teacher infected with HIV should > be > > allowed to > > continue teaching in school > > > > I want to calculate a summary score that reflects > community > > attitude > > (the attitudes of all members of the community on > these > > variables --- > > that is the score must EXCLUDE those of the > respondent, and > > INCLUDE > > those of all others. In some literature, this is > referred > > to as > > non-self mean. > > > > Since in the DHS, clusters (V022) are the lowest level > from > > which a > > sample of households is drawn (i.e. these are > typically the > > primary > > sampling unit), I want a score based on the responses > of > > all people in > > the same strata (PSU) as the respondent, but excluding > the > > respondent's > > responses. For example, to compute this score for an > > individual A who > > resides in PSU B, we sum the stigma scores (over all > the 4 > > variables) of > > all individuals in PSU B, with the exceptoin of > respondent > > A. > > > > I would be very grateful if you could give me some > pointers > > about how to > > create this summary score (over all the 4 variables). * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**RE: st: RE: Creating a Non-Self Mean (Score)***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**Re: st: RE: Creating a Non-Self Mean (Score)***From:*Chao Yawo <yawo1964@yahoo.com>

**Re: st: RE: Creating a Non-Self Mean (Score)***From:*Chao Yawo <yawo1964@yahoo.com>

- Prev by Date:
**st: RE: Help with data management** - Next by Date:
**st: Clarify error message** - Previous by thread:
**Re: st: RE: Creating a Non-Self Mean (Score)** - Next by thread:
**RE: st: RE: Creating a Non-Self Mean (Score)** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |