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: restricting the number of groups within a t-test [was: something unreadable]


From   Maarten buis <[email protected]>
To   [email protected]
Subject   st: RE: restricting the number of groups within a t-test [was: something unreadable]
Date   Mon, 22 Nov 2010 11:41:00 +0000 (GMT)

--- Amal Khanolkar wrote:
> I have a categorical variable with 4 sub categories. I was wondering if 
> its possible to compare means of just 2 categories using the t-test?
> When I looked up help for t-test, there didn't seem to be any options
> to tell stata to restrict the test to means of just 2 categories.

I guess that the easiest way is to create a new variable that has the
observed values when an observation belongs to one of the two groups 
you want to compare and a missing value otherwise. So in the example
below I wanted to compare autos with repair status 2 and 3. This is
what the -if inlist(rep78, 2, 3)- part does. For more see 
-help inlist-.

*----------- begin example -------------
sysuse auto, clear
gen rep2 = rep78 if inlist(rep78, 2,3)
ttest mpg, by(rep2)
*------------ end example --------------
(For more on examples I sent to the Statalist see: 
http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index