## The ultimate crackpot iteration! [Two-Stage / GS Designs]

Hi all,

what am I thinking???

For any given GMR(assumed) and any given target power we can calculate the sample size necessary to achieve the power on basis of an observed CV.

We can look at that in reverse: For any given sample size there exists a level of CV which keeps the power at the desired level. We can call that a criticial CV. If the CV is above that critical CV for any given sample size then the power is lower than the target.
So let us get the critical CV's.

Here done with D&C, I am sure this can be improved a lil bit. This time I am also giving a power.calc function    And remember I am expressing it as Nps, not total number of subjects.

 alpha1=0.05 alpha2=0.0294 vecQT1=c(1:2000) vecQT2=c(1:2000) for (i in 1:2000)    {     vecQT1[i]=qt(p=1-alpha1, df=i)     vecQT2[i]=qt(p=1-alpha2, df=i)    } Power.calc=function(Nps, GMR, CV, Is.St2=0) {   s=sqrt(log(1+CV*CV))   nom1=log(1.25/GMR)   nom2=-log(1.25*GMR)   den=s*sqrt(2/(2*Nps))   df=Nps*2-2   if (Is.St2==T) df=df-1   ##cat("1-a=", 1-alpha, "df=",df,"\n")   if (Is.St2==0) q=vecQT1[df]     else         q=vecQT2[df]   pw=pt( (nom1/den) -q, df) - pt( (nom2/den) +q, df)   if (pw<0) pw=0.01   return(pw) } FindCritCV=function(Pwr.T, GMR, Nps, Is.St2=1, toler=0.000001) {   CV1=0.0123   CV2=8.7654   while (abs(Power.calc(Nps, GMR, CV1, Is.St2)) - abs(Power.calc(Nps, GMR, CV2, Is.St2))>toler)   {    CV3=0.5*(CV1+CV2)    tmp=Pwr.T-Power.calc(Nps, GMR, CV3, Is.St2)    if (tmp>0) CV2=CV3       else    CV1=CV3   }   return(0.5*(CV2+CV1) )   } vecCritCVs=rep(0,1000) for (Nps in 6:1000)   vecCritCVs[Nps]=FindCritCV(0.8, 0.95, Nps, 1, 1e-12) ##let's have a look print(vecCritCVs) ##so how do we use this in practice? GetNps=function(CV) {   Nps=1   while (vecCritCVs[Nps]<=CV) Nps=Nps+1   return(Nps)  } ## GetNps(0.165) ##should be 9, right?? Power.calc(9, 0.95, 0.1764 , Is.St2=1) ##should be a tiny bit lower than 0.8 since the critical                                        ##CV level is 0.1763761 

I hereby officially declare all sample size iterations in Potvin runs unnecessary, apart from the three-liner above   Play around with tolerances and lenghts and include your own error trapping.
A good Sunday to all of you. Goodbye Zhang.

I could be wrong, but...

Best regards,
ElMaestro

"Pass or fail" (D. Potvin et al., 2008) Ing. Helmut Schütz 