[R] small sample techniques
Greg Snow
Greg.Snow at intermountainmail.org
Thu Aug 9 23:27:43 CEST 2007
30 is not 30% of 300 (it is 10%), so your prop.test below is testing
something different from your hand calculations. Try:
> prop.test(c(.30,.23)*300,c(300,300), correct=FALSE)
2-sample test for equality of proportions without continuity
correction
data: c(0.3, 0.23) * 300 out of c(300, 300)
X-squared = 3.7736, df = 1, p-value = 0.05207
alternative hypothesis: two.sided
95 percent confidence interval:
-0.000404278 0.140404278
sample estimates:
prop 1 prop 2
0.30 0.23
> sqrt(3.7736)
[1] 1.942576
Notice that the square root of the X-squared value matches your hand
calculations (with rounding error). This is true if Yates continuty
correction is not used (the correct=FALSE in the call to prop.test).
Hope this helps,
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
> -----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 1:02 PM
> To: Nordlund, Dan (DSHS/RDA); r-help at stat.math.ethz.ch
> Subject: Re: [R] small sample techniques
>
> 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
> 2>proportions
> sqrt((0.265 *0.735)*((1/300)+(1/300))) = 0.03603
>
> 3>Evaluation of the difference between sample proportion as a
> deviation
> 3>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.
>
> ______________________________________________
> 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