|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: AW: Compute mean for groups leaving one member out
<000901ca54a3$217ddea0$64799be0$@[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
----------------------------------------
> From: [email protected]
> To: [email protected]
> Subject: RE: st: RE: RE: AW: Compute mean for groups leaving one member o=
ut
> Date: Sat=2C 24 Oct 2009 14:11:34 +0200
>
>
> <>
>
> Am I the only one experiencing weird characters when reading messages fro=
m
> "kokootchke"=2C a.k.a Adrian? Like "=3D2C" and so on... Makes it difficul=
t to
> read them...
>
>
> HTH
> Martin
Sorry about that=2C Martin and others. I don't know why that's happening
and I was not aware of this problem. If anyone has a suggestion (other
than moving this address to gmail=2C Kit! :P=A0 ) please let me know. I
will look into it and see if there's anything I can do to solve this
issue.
Best=2C
Adrian
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of kokootchke
> Sent: Samstag=2C 24. Oktober 2009 06:37
> To: statalist
> Subject: RE: st: RE: RE: AW: Compute mean for groups leaving one member o=
ut
>
> <000201ca5407$fdb4cfb0$f91e6f10$@[email protected]>
> Content-Type: text/plain=3B charset=3D"iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
> MIME-Version: 1.0
>
>
> Thank you=3D2C Martin and NIck. Your suggestions worked beautifully. The =
only=3D
> problem I had was that I think that Martin's code takes the average for a=
l=3D
> l other countries.. but including ALL quarters across years (so=3D2C for =
all =3D
> first quarters=3D2C for all second quarters=3D2C etc. I think the code sh=
ould s=3D
> ay
>
>> bys country quarter: egen totalicrg=3D3D /*
>> */ total(icrg)
>> bys country quarter: egen numobs=3D3D /*
>> */ count(icrg)
>
> but other than that=3D2C everything worked perfectly.
>
> THanks a lot!
> Adrian
>
>
> ----------------------------------------
>> From: [email protected]
>> To: [email protected]
>> Subject: st: RE: RE: AW: Compute mean for groups leaving one member out
>> Date: Fri=3D2C 23 Oct 2009 19:41:02 +0200
>>
>>
>> <>
>> " But also keep track of missing values too."
>>
>>
>> Very true=3D2C and an obvious omission in the rush this morning. As an
>> economist=3D2C I often fall prey to the notion of a perfect world=3D2C m=
arket=3D
> =3D2C model
>> whatever...
>> So here is my modified code that takes account of the missing thing. Not=
e
>> that I voluntarily introduce the missingness with the -drop- command in =
t=3D
> he
>> middle of the code section...
>>
>>
>>
>> *******
>> clear*
>> set obs 40
>>
>> gen country=3D3D_n
>> gen quarter=3D3Dquarterly("1990:1"=3D2C "YQ")
>>
>> expand 68
>> bys country: /*
>> */ replace quarter=3D3Dquarter+_n-1
>> format quarter %tq
>>
>> gen icrg=3D3Drnormal(10=3D2C100)
>>
>> drop if runiform()<.1
>>
>> //calculate mean
>> bys quarter: egen totalicrg=3D3D /*
>> */ total(icrg)
>> bys quarter: egen numobs=3D3D /*
>> */ count(icrg)
>> //divide by # of countries-1
>> gen mymean=3D3D(totalicrg-icrg)/ /*
>> */ (numobs-1)
>>
>> //10 random checks...
>>
>> forv i=3D3D1/10{
>> local a=3D3D 1+int(`c(N)'*runiform())
>> l country quarter mymean in `a'
>> su icrg if quarter=3D3D=3D3Dquarter[`a'] /*
>> */ & country!=3D3Dcountry[`a']
>> }
>> *******
>>
>>
>> HTH
>> Martin
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of Nick Cox
>> Sent: Freitag=3D2C 23. Oktober 2009 19:31
>> To: [email protected]
>> Subject: st: RE: AW: Compute mean for groups leaving one member out
>>
>> In words=3D2C 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
>> [email protected]
>>
>> 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=3D3D_n
>> gen quarter=3D3Dquarterly("1990:1"=3D2C "YQ")
>>
>> expand 68
>> bys country: /*
>> */ replace quarter=3D3Dquarter+_n-1
>> format quarter %tq
>>
>> gen icrg=3D3Drnormal(10=3D2C100)
>>
>> //calculate mean
>> bys quarter: egen totalicrg=3D3D /*
>> */ total(icrg)
>> //divide by # of countries-1
>> gen mymean=3D3D(totalicrg-icrg)/39
>>
>> //10 random checks...
>>
>> forv i=3D3D1/10{
>> local a=3D3D 1+int(`c(N)'*runiform())
>> l country quarter mymean in `a'
>> su icrg if quarter=3D3D=3D3Dquarter[`a'] /*
>> */ & country!=3D3Dcountry[`a']
>> }
>> *************
>>
>>
>>
>> HTH
>> Martin
>>
>>
>> -----Urspr=3DFCngliche Nachricht-----
>> Von: [email protected]
>> [mailto:[email protected]] Im Auftrag von kokootchke
>> Gesendet: Freitag=3D2C 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=3D
> to
>> 2006:4. I would like to compute the average of a variable (called icrg) =
f=3D
> or
>> all countries in a given time period. My problem is that in doing this
>> computation=3D2C I would like to leave one country out of the calculatio=
n.
>>
>> For example=3D2C in period 1990:1 for Mexico=3D2C I would like to comput=
e 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/
>>
>>
>> *
>> * 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/
> =3D20
> _________________________________________________________________
> Windows 7: Simplify your PC. Learn more.
> http://www.microsoft.com/Windows/windows-7/default.aspx?ocid=3D3DPID24727=
::T:=3D
> WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen1:102009=3D
> *
> * 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/
>
> *
> * 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/
=20
_________________________________________________________________
Windows 7: It works the way you want. Learn more.
http://www.microsoft.com/Windows/windows-7/default.aspx?ocid=3DPID24727::T:=
WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen2:102009=
*
* 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/