[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 |
st: RE: AW: Compute mean for groups leaving one member out |

Date |
Fri, 23 Oct 2009 18:31:04 +0100 |

In words, you get 1. the total of every value but one value 2. the number of values - 1 and divide. But also keep track of missing values too. Nick n.j.cox@durham.ac.uk Martin Weiss "Could you suggest a simple way of doing this?" Taking a cue from Nick`s FAQ cited earlier: ************* clear* set obs 40 gen country=_n gen quarter=quarterly("1990:1", "YQ") expand 68 bys country: /* */ replace quarter=quarter+_n-1 format quarter %tq gen icrg=rnormal(10,100) //calculate mean bys quarter: egen totalicrg= /* */ total(icrg) //divide by # of countries-1 gen mymean=(totalicrg-icrg)/39 //10 random checks... forv i=1/10{ local a= 1+int(`c(N)'*runiform()) l country quarter mymean in `a' su icrg if quarter==quarter[`a'] /* */ & country!=country[`a'] } ************* HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von kokootchke Gesendet: Freitag, 23. Oktober 2009 07:39 An: statalist Betreff: st: Compute mean for groups leaving one member out Dear all: I have a panel dataset of 40 countries at quarterly frequency from 1990:1 to 2006:4. I would like to compute the average of a variable (called icrg) for all countries in a given time period. My problem is that in doing this computation, I would like to leave one country out of the calculation. For example, in period 1990:1 for Mexico, I would like to compute the average of icrg for ALL other countries in this period EXCLUDING Mexico. Could you suggest a simple way of doing this? * * 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/

**Follow-Ups**:**st: RE: RE: AW: Compute mean for groups leaving one member out***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**References**:**st: Random walk simplex***From:*"Akshay Shanker" <Akshay.Shanker@standards.org.au>

**st: Compute mean for groups leaving one member out***From:*kokootchke <kokootchke@hotmail.com>

**st: AW: Compute mean for groups leaving one member out***From:*"Martin Weiss" <martin.weiss1@gmx.de>

- Prev by Date:
**st: R: RE: Problem with Left Truncation** - Next by Date:
**st: RE: RE: AW: Compute mean for groups leaving one member out** - Previous by thread:
**st: AW: Compute mean for groups leaving one member out** - Next by thread:
**st: RE: RE: AW: Compute mean for groups leaving one member out** - Index(es):

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