# [R] pwr.2p2n.test when the ratio of n1/n2 is known

Chuck Cleland ccleland at optonline.net
Fri Oct 24 12:07:17 CEST 2008

```On 10/24/2008 5:02 AM, Daniel Brewer wrote:
> Hi,
>
> I am trying to do a power calculation for a difference in proportions
> test where I want to estimate the sample size required.  I know (well
> estimate) that group one (n1) is 10% of the population and group 2 (n2)
> is 90% of the population.  I know the effect size (h).  pwr.2p2n.test
> only allows one variable to be left null whereas I would like both n1
> and n2 to be determined where I know there relative proportions.  Any
> ideas how to do this?  Is there a different function?

library(pwr)

i <- 2

while(pwr.2p2n.test(h=.20, n1=i, n2=i*9)\$power < .80) {i <- i + 1}

pwr.2p2n.test(h=.20, n1=i, n2=i*9)

difference of proportion power calculation for binomial
distribution (arcsine transformation)

h = 0.2
n1 = 219
n2 = 1971
sig.level = 0.05
power = 0.8017491
alternative = two.sided

NOTE: different sample sizes

> Thanks
>
> Dan

--
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

```