<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>FAQ/powppR</title><revhistory><revision><revnumber>2</revnumber><date>2013-03-08 10:17:11</date><authorinitials>localhost</authorinitials><revremark>converted to 1.6 markup</revremark></revision><revision><revnumber>1</revnumber><date>2008-02-27 15:29:29</date><authorinitials>PeterWatson</authorinitials></revision></revhistory></articleinfo><section><title>Power for difference in two independent proportions using R</title><para>Copy and paste the below inputs into R and adjust as needed. </para><screen><![CDATA[alpha <- 0.05
p1 <- 0.19
p2 <- 0.09
delta <- 1
n1 <- 167]]></screen><para>Now, copy and paste the below into R. The power, pow, and odds ratio, oddsr, should be outputted. </para><screen><![CDATA[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)]]></screen></section></article>