sample size to test the equality of proportion

I need to compute the sample size to test the equality of proportion. However, I keep getting different answers. alpha =0.10, beta = 0.80 or 0.2, Pa = 0.50 and Pb =0.75

This is the code we need to check our answers:
power.prop.test(power=0.8,p1=0.50,p2=0.75, sig.level = 0.1)

This is my code:
pA=0.50
pB=0.75
kappa=1
alpha=0.10
beta=0.20
(nB=(pA*(1-pA)/kappa+pB*(1-pB))((qnorm(1-alpha/2)+qnorm(1-beta))/(pA-pB))^2)
ceiling(nB) # 70
z=(pA-pB)/sqrt(pA
(1-pA)/nB/kappa+pB*(1-pB)/nB)
(Power=pnorm(z-qnorm(1-alpha/2))+pnorm(-z-qnorm(1-alpha/2)))

I suspect what is meant by "different answers" is that the manually generated code doesn't produce 80% power with the same sample size that is generated using power.prop.test, which provides 80% power at n = 45.31091 per group.

The code I've modified below (in order to get it to run) provides about 80% power with a sample size of 43.2279 per group. These seem to be very close to me, so I'm not entirely sure what the problem is. Perhaps because your code wasn't actually running you were seeing an older value that wasn't getting updated?

pA=0.50
pB=0.75
kappa=1
alpha=0.10
beta=0.20
(nB = (pA * (1-pA) / kappa+pB*(1-pB)) * 
         ((qnorm(1-alpha/2) + qnorm(1-beta)) / (pA-pB))^2)
ceiling(nB) # OP says 70, I get 44
z = (pA-pB) / sqrt(pA * (1-pA) / nB / kappa + pB * (1-pB) / nB)
(Power = pnorm(z - qnorm(1-alpha/2)) + pnorm(-z - qnorm(1-alpha/2)))
2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.