power2x2 which calls exact2x2 function repeatedly. Default (strict=FALSE) does not count rejections in the wrong direction.
Sample size is calculated by ss2x2 which calls power2x2 repeatedly finding the lowest sample size that has at least the nominal power, using the uniroot.integer function from the ssanv package.power2x2(p0,p1,n0,n1=NULL,sig.level=0.05,
alternative=c("two.sided","one.sided"),paired=FALSE,
strict=FALSE,tsmethod=NULL,nullOddsRatio=1,
errbound=10^-6,approx=FALSE)
ss2x2(p0,p1,power=.80,n1.over.n0=1,sig.level=0.05,
alternative=c("two.sided","one.sided"),paired=FALSE,
strict=FALSE,tsmethod=NULL,nullOddsRatio=1,
errbound=10^-6,print.steps=FALSE, approx=FALSE)exact2x2 for details.power2x2 and ss2x2 return an object of class 'power.htest'. A list with elementsapprox=TRUE for power2x2 use a continuity corrected normal approximation (Fleiss, 1981, p. 44). For ss2x2ss.nonadh function (refinement="Fisher.exact") from the ssanv package for calculation that accounts for nonadherence in proportion of subjects. That function calls fisher.testpower2x2(.2,.8,12,15)
# calculate sample size with 2:1 allocation to groups
ss2x2(.2,.8,n1.over.n0=2,power=.8,approx=TRUE)
ss2x2(.2,.8,n1.over.n0=2,power=.8,print.steps=TRUE)Run the code above in your browser using DataLab