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