# Re: st: -ttest- or -prtest-?

 From Bert Jung To statalist@hsphsun2.harvard.edu Subject Re: st: -ttest- or -prtest-? Date Sun, 26 Apr 2009 22:34:42 -0400

```Thanks Richard, much appreciated.  Here an example code to play with;
the p-values are very close in most cases I tried.

Bert

* Comparing -ttest-, -prtest- and -logit- for binary outcomes

clear
set obs 100

* Proportion of sample set to y = 1 in each of group 0, 1
scalar r1 = 0.4
scalar r2 = 0.5

* Two groups (x = 0, 1) with equal number of obs
gen x = 1 if _n<=_N/2
recode x (.=0)

gen y = 0
replace y = 1 if x==1 & _n <= r1* (_N/2)
replace y = 1 if x==0 & _n > _N - ( r2* (_N/2) )

tab y x, miss

ttest y, by(x)
prtest y, by(x)
logit y x

On Sat, Apr 25, 2009 at 12:15 AM, Richard Williams
<Richard.A.Williams.5@nd.edu> wrote:
> At 10:04 PM 4/24/2009, Bert Jung wrote:
>>
>> Dear Statalisters,
>>
>> I have an embarrassingly basic question: I am looking at a binary
>> variable, 0 for "no response" and 1 for "response".  I want to compare
>> 2 groups (treatment/control, also binary).  In this situation is a
>> -ttest- appropriate or does it have to be a test of proportions
>> -prtest-?
>>
>> My vague memory of stats 101 suggests to use -prtest- since the
>> dependent variable is categorical.  But I can interpret my variable as
>> numerical.  My understanding is that with many numerical categories a
>> t-test may be ok.  But here the outcome is 0 or 1 and clearly limited
>> in that range, which calls for a -prtest-.  The two tests would be
>> quite different in this case, so the choice matters.  Any comments and
>> views much appreciated.
>
> Use prtest.  See the last page of
>
> http://www.nd.edu/~rwilliam/stats1/TwoSample-Stata.pdf
>
> In practice, though, it may not matter if you use a t-test instead, at least
> if the samples are large.
>
> The above is basically a "how to."  For more of an explanation, see the last
> few pages of
>
> http://www.nd.edu/~rwilliam/stats1/x42.pdf
>
> Note too that you could also set this up as a 2 by 2 table and do a
> chi-square test of the model of independence.  You can also then use
> Fisher's exact test, which could be handy if the sample is small.  See pp.
> 4-7 of
>
> http://www.nd.edu/~rwilliam/stats1/Categorical-Stata.pdf
>
> Yet another strategy is to do logistic regression, e.g.
>
> logit y x
>
>> As add-on: how can I obtain chi2 values for the proportional test when
>> using complex survey data?
>
> I'm not sure you ever even get chi-square stats when using survey data - you
> usually get F values or t values, I believe.  The first thing that leaps to
> mind is to do logistic regression, e.g.
>
> svy: logit y x
>
>
> -------------------------------------------
> Richard Williams, Notre Dame Dept of Sociology
> OFFICE: (574)631-6668, (574)631-6463
> HOME:   (574)289-5227
> EMAIL:  Richard.A.Williams.5@ND.Edu
> WWW:    http://www.nd.edu/~rwilliam
>
> *
> *   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/
```