FAQ/powppR - CBU statistics Wiki

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment
Flind the wroneg tetters tin eaech wrord

location: FAQ / powppR

Power for difference in two independent proportions using R

Copy and paste the below inputs into R and adjust as needed.

alpha <- 0.05
p1 <- 0.19
p2 <- 0.09
delta <- 1
n1 <- 167

Now, copy and paste the below into R. The power, pow, and odds ratio, oddsr, should be outputted.

n2 <- delta*n1
pbar <- (n1*p1 + n2*p2) / (n1+n2)
chisq <- ( (p1-p2) / sqrt( pbar*(1-pbar)*( (1/n1) + (1/n2) ) ) )^2
pow <- 1 - pchisq(abs(qchisq(1-alpha,1)),1,chisq)
cat("Power of test=")
print(pow)  
cat("Odds Ratio=")
oddsr <-  ( n1*p1*n2*(1-p2) ) / ( n1*(1-p1)*n2*p2 )
print(oddsr)