#Gehans' Two stage design: sscal.gehan=function(theta0=0.2,alpha0=0.05,a=1,b=1,n.min=2,n.max=5000){ condl.prob=1 ntry=n.min while(condl.prob>alpha0){ condl.prob=pbeta(theta0,a,b+ntry,lower.tail=F) ntry=ntry+1 if(ntry>n.max){return(c("required sample size>",n.max))} } n.opt=ntry-1 cat(c("n.opt=",n.opt,"(theta0=",theta0,"alpha0=",alpha0,")"),fill=T) #return(n.opt) } #Simons two-stage design: prob.fn=function(theta,r1,n1,r,n){ if(r1>n1){return("r1