# [R] small sample techniques

Moshe Olshansky m_olshansky at yahoo.com
Fri Aug 10 04:03:03 CEST 2007

```Hi Murli,

First of all, regarding prop.test, you made a typo:
you should have used prop.test(c(69,90),c(300,300))
which gives you the squared value of 3.4228, and it's
square root is 1.85 which is not too far from 1.94.

I would use Fisher Exact Test (fisher.test).  Two
sided test has a p-value of 0.06411 so you do not
reject H0, One sided test (i.e. H1 is that the first
probability of success is smaller than the second) has
a p-value of 0.03206, so you reject H0 (with 95%
confidence level).
You get similar results with two-sided and one-sided
t-test.

Moshe.

P.S. if you use paired t-test you get nonsense since
it uses pairwise differences, and in your case only 21
of 300 differences are non-zero!

--- "Nair, Murlidharan T" <mnair at iusb.edu> wrote:

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