0
$\begingroup$

I am trying to modify power.prop.test is R to adapt for cases where n1 and n2 (two sample sizes) are not equal. That is, they can not be given by one constant n.

The equation in R for n1 = n2 = n is:

p.body <- quote(pnorm(((sqrt(n) * abs(p1 - p2) - (qnorm(sig.level/tside, 
lower.tail = FALSE) 
* sqrt((p1 + p2) * (1 - (p1 + p2)/2))))
/sqrt(p1 *(1 - p1) + p2 * (1 - p2)))))

Is the below equation correct if n1 and n2 are different. here r = n2/n1 (proportions known)

pnorm(((abs(p1 - p2) - (qnorm(sig.level/tside, lower.tail = FALSE) * 
              sqrt((p1 + p2)/2 * (1 - (p1 + p2)/2) * (1/n + 1/(n*r)) ))) /
              sqrt(p1 * (1 - p1) * (1/n) + p2 * (1 - p2) * ( 1/(n * r)))))

is there any theory of how this formula was derived? Can someone explain the math behind this formula?

I used this as reference: R power.prop.test and power equation in the difference between proportions

$\endgroup$
  • $\begingroup$ Cross Validated is not supposed to be a site for software tech support (even though a lot of questions end up including code). It is OK to have code, but can you make this question about the underlying math / statistical computations? Someone may provide code in an answer anyway, or you may have to translate a response into R code yourself. Without this, your Q may be closed. $\endgroup$ – gung Aug 13 at 17:57
  • $\begingroup$ You could use the pwr package: rpubs.com/sypark0215/223385 $\endgroup$ – william3031 Aug 14 at 4:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.