# [R] significance in difference of proportions

Torsten Hothorn Torsten.Hothorn at rzmail.uni-erlangen.de
Thu Nov 27 18:18:06 CET 2003

```> Hello,
>
> I'm looking for some guidance with the following problem:
>
> I've 2 samples A (111 items) and B (10 items) drawn from the same unknown
> population. Witihn A I find 9 "positives" and in B 0 positives. I'd like to
> know if the 2 samples A and B are different, ie is there a way to find out
> whether the number of "positives" is significantly different in A and B?
>
> I'm currently using prop.test, but unfortunately some of my data contains
> less than 5 items in a group (like in the example above), and the test
> statistics may not hold:

The statistic is fine, the approximation to its null distribution may be
questionable :-)

>
> > prop.test(c(9,0), c(111,10))
>
>         2-sample test for equality of proportions with continuity correction
>
> data:  c(9, 0) out of c(111, 10)
> X-squared = 0.0941, df = 1, p-value = 0.759
> alternative hypothesis: two.sided
> 95 percent confidence interval:
>  -0.02420252  0.18636468
> sample estimates:
>     prop 1     prop 2
> 0.08108108 0.00000000
>
> Warning message:
> Chi-squared approximation may be incorrect in: prop.test(c(9, 0), c(111, 10))
>
>
> Do you have suggestions for an alternative test?
>

you may consider a permutation test for two independent samples:

R> library(exactRankTests)
R> x = c(rep(1, 9), rep(0, 102))
R> y = rep(0, 10)
R> mean(x)
 0.08108108
R> mean(y)
 0
R> perm.test(y, x, exact = TRUE)

2-sample Permutation Test

data:  y and x
T = 0, p-value = 0.6092
alternative hypothesis: true mu is not equal to 0

Best,

Torsten

> 	many thanks for your help,
> 	+kind regards,
>
> 	Arne
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
>

```