Hi,

I'm reading in John Lachin's

This is different compared to:

This article http://www.stat.ucla.edu/~vlew/stat130/WEEK7/dalgaard9.pdf explains power.prop.test computes a binomial approximation to the normal distribution. When should one method be used over the other? I'm using prop.test which computes a chi-square statistic. I know that if we square a standard normal we get a chi-squared. But, I don't understand why I would use one method over another. Additionally, why does prop.test give the option for a one sided or two sided? Edit: alternative=greater or less is only used when comparing a single proportion against a null value. Makes sense.

I'm reading in John Lachin's

*Biostatistical Methods*2nd edition. It suggests a formula for the sample sizes of a two proportion Z-test. I coded it in R below. The etas are the expected sample fractions in each group, pi1 and pi2 are the proportions of interest, Z_alpha and Z_beta are the quantiles for alpha and beta respectively:
Code:

```
sample_size <- function(eta1,eta2,pi1,pi2,Z_alpha,Z_beta){
pi<-(eta1*pi1)+(eta2*pi2)
phi0<-sqrt((pi*(1-pi))*((1/eta1)+(1/eta2)))
phi1<-sqrt(((pi1*(1-pi1))/eta1)+((pi2*(1-pi2))/eta2))
res<-(((Z_alpha*phi0)+(Z_beta*phi1))/(pi1-pi2))^2
print(res)
}
sample_size(.5,.5,.28,.4,qnorm(0.975,mean=0,sd=1),qnorm(0.90,mean=0,sd=1))
```

Code:

`power.prop.test(n = NULL, p1 = .4, p2 = .28, sig.level = 0.05,power = .9,alternative = c("two.sided"))`

Last edited: