[R] small sample techniques

Nair, Murlidharan T mnair at iusb.edu
Thu Aug 9 21:01:32 CEST 2007


n=300
30% taking A relief from pain
23% taking B relief from pain
Question; If there is no difference are we likely to get a 7% difference?

Hypothesis
H0: p1-p2=0
H1: p1-p2!=0 (not equal to)

1>Weighed average of two sample proportion
    300(0.30)+300(0.23)
    ------------------- = 0.265
      300+300
2>Std Error estimate of the difference between two independent proportions
      sqrt((0.265 *0.735)*((1/300)+(1/300))) = 0.03603

3>Evaluation of the difference between sample proportion as a deviation from the hypothesized difference of zero
         ((0.30-0.23)-(0))/0.03603 = 1.94


z did not approach 1.96 hence H0 is not rejected. 

This is what I was trying to do using prop.test. 

prop.test(c(30,23),c(300,300)) 

What function should I use? 


-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch on behalf of Nordlund, Dan (DSHS/RDA)
Sent: Thu 8/9/2007 1:26 PM
To: r-help at stat.math.ethz.ch
Subject: Re: [R] small sample techniques
 
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Nair, 
> Murlidharan T
> Sent: Thursday, August 09, 2007 9:19 AM
> To: Moshe Olshansky; Rolf Turner; r-help at stat.math.ethz.ch
> Subject: Re: [R] small sample techniques
> 
> Thanks, that discussion was helpful. Well, I have another question 
> I am comparing two proportions for its deviation from the hypothesized
> difference of zero. My manually calculated z ratio is 1.94. 
> But, when I calculate it using prop.test, it uses Pearson's 
> chi-squared
> test and the X-squared value that it gives it 0.74. Is there 
> a function
> in R where I can calculate the z ratio? Which is 
> 
> 
>    ('p1-'p2)-(p1-p2)
>  Z= ----------------
> 	     S
> 		('p1-'p2)
> 
> Where S is the standard error estimate of the difference between two
> independent proportions
> 
> Dummy example 
> This is how I use it 
> prop.test(c(30,23),c(300,300))
> 
> 
> Cheers../Murli
> 
> 

Murli,

I think you need to recheck you computations.  You can run a t-test on your data in a variety of ways.  Here is one: 

> x<-c(rep(1,30),rep(0,270))
> y<-c(rep(1,23),rep(0,277))
> t.test(x,y)

        Welch Two Sample t-test

data:  x and y 
t = 1.0062, df = 589.583, p-value = 0.3147
alternative hypothesis: true difference in means is not equal to 0 
95 percent confidence interval:
 -0.02221086  0.06887752 
sample estimates:
 mean of x  mean of y 
0.10000000 0.07666667 

Hope this is helpful,

Dan

Daniel J. Nordlund
Research and Data Analysis
Washington State Department of Social and Health Services
Olympia, WA  98504-5204

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list