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: means compairison with weights and unequal variance
From
Nick Cox <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
RE: st: means compairison with weights and unequal variance
Date
Mon, 21 Nov 2011 10:32:45 +0000
Still wrong.
ttesti `=N1[1]' `=av1[1]' `=sd1[1]' `=N2[1]' `=av2[1]' `=sd2[1]', unequal
Must get my eyes retested...
Nick
[email protected]
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: 21 November 2011 09:34
To: [email protected]
Subject: Re: st: means compairison with weights and unequal variance
ttesti `=N1[1]' `=av1[1]' `=sd1[1]' `=N2[1]' `=av2'[1] `=sd2[1]', unequal
On Mon, Nov 21, 2011 at 9:33 AM, Nick Cox <[email protected]> wrote:
> This would work. But it is in no sense superior to John's original.
>
> sysuse auto, clear
> sum mpg if foreign [aw=weight]
> gen N1 = r(N)
> gen av1 = r(mean)
> genl sd1 = r(sd)
>
> sum mpg if !foreign [aw=weight]
> genl N2 = r(N)
> gen av2 = r(mean)
> gen sd2 = r(sd)
>
> ttesti `=N1[1]' `=av1[1]' `=sd1[1]'' `=N2[1]' `=av2'[1] `sd2[1]', unequal
>
> The [1] subscripts are possibly superfluous; I have not tested this.
>
>
> On Mon, Nov 21, 2011 at 9:09 AM, Nick Cox <[email protected]> wrote:
>> The syntax ` ' only de-references local macro names. Once you change
>> the syntax as you did, the --ttesti- call reduces to
>>
>> ttesti, unequal
>>
>> which makes no sense. There is no reason to change it anyway.
>>
>> Nick
>>
>> On Mon, Nov 21, 2011 at 9:02 AM, David Ashcraft
>> <[email protected]> wrote:
>>> John,
>>>
>>> I am trying to implement the code but replacing local with gen. Why I am not getting the same result, if I use gen rather than local?
>>>
>>> David
>>>
>>>
>>> ----- Original Message -----
>>> From: John Luke Gallup <[email protected]>
>>> To: [email protected]
>>> Cc:
>>> Sent: Monday, November 21, 2011 8:40:40 AM
>>> Subject: Re: st: means compairison with weights and unequal variance
>>>
>>> Barbro,
>>>
>>> A simple alternative is to calculate the means and standard deviations for each group using -summarize- with weights, and then run -ttesti ..., unequal-:
>>>
>>> sysuse auto, clear
>>>
>>> sum mpg if foreign [aw=weight]
>>> local N1 = r(N)
>>> local av1 = r(mean)
>>> local sd1 = r(sd)
>>>
>>> sum mpg if !foreign [aw=weight]
>>> local N2 = r(N)
>>> local av2 = r(mean)
>>> local sd2 = r(sd)
>>>
>>> ttesti `N1' `av1' `sd1' `N2' `av2' `sd2', unequal
>>>
*
* 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/