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.
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.
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




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



A good Sunday to all of you. Goodbye Zhang.
—
Pass or fail!
ElMaestro
Pass or fail!
ElMaestro
Complete thread:
- Initial sample size guess for the Potvin methods ElMaestro 2017-08-19 15:04 [Two-Stage / GS Designs]
- Initial sample size guess for the Potvin methods Helmut 2017-08-19 16:06
- Initial sample size guess for the Potvin methods ElMaestro 2017-08-19 16:14
- Initial sample size guess for the Potvin methods Helmut 2017-08-19 17:12
- Initial sample size guess for the Potvin methods ElMaestro 2017-08-19 17:17
- Confuse-a-Cat Helmut 2017-08-19 17:33
- Confuse-a-Cat ElMaestro 2017-08-19 17:56
- Confuse-a-Cat Helmut 2017-08-19 17:33
- Initial sample size guess for the Potvin methods ElMaestro 2017-08-19 17:17
- loop ↔ vectorized ↔ direct Helmut 2017-08-20 14:40
- loop ↔ vectorized ↔ direct ElMaestro 2017-08-20 15:22
- loop ↔ vectorized ↔ direct Helmut 2017-08-20 16:23
- loop ↔ vectorized ↔ direct ElMaestro 2017-08-20 17:22
- loop ↔ vectorized ↔ direct Helmut 2017-08-20 16:23
- loop ↔ vectorized ↔ direct ElMaestro 2017-08-20 15:22
- Initial sample size guess for the Potvin methods Helmut 2017-08-19 17:12
- Initial sample size guess for the Potvin methods ElMaestro 2017-08-19 16:14
- The n ext crackpot iteration ElMaestro 2017-08-19 20:04
- The n ext crackpot iteration Helmut 2017-08-20 02:20
- The ultimate crackpot iteration!ElMaestro 2017-08-20 14:35
- The ultimate crackpot iteration! Helmut 2017-08-20 15:11
- The ultimate crackpot iteration! ElMaestro 2017-08-20 15:28
- The ultimate crackpot iteration! Helmut 2017-08-20 16:06
- The ultimate crackpot iteration! ElMaestro 2017-08-20 16:15
- The ultimate crackpot iteration! Helmut 2017-08-20 18:58
- The ultimate crackpot iteration! ElMaestro 2017-08-20 19:32
- Suggested code ElMaestro 2017-08-21 18:13
- Nitpicker! Helmut 2017-08-22 13:33
- Nitpicker! ElMaestro 2017-08-22 17:27
- Nitpicker! Helmut 2017-08-22 17:49
- Nitpicker! ElMaestro 2017-08-22 17:59
- Nitpicker! Helmut 2017-08-22 19:15
- Benchmark code ElMaestro 2017-08-22 22:29
- Benchmark code Helmut 2017-08-23 01:48
- Benchmark code ElMaestro 2017-08-22 22:29
- Nitpicker! Helmut 2017-08-22 19:15
- Nitpicker! ElMaestro 2017-08-22 17:59
- Nitpicker! Helmut 2017-08-22 17:49
- Nitpicker! ElMaestro 2017-08-22 17:27
- Nitpicker! Helmut 2017-08-22 13:33
- Suggested code ElMaestro 2017-08-21 18:13
- The ultimate crackpot iteration! ElMaestro 2017-08-20 19:32
- The ultimate crackpot iteration! Helmut 2017-08-20 18:58
- The ultimate crackpot iteration! ElMaestro 2017-08-20 16:15
- The ultimate crackpot iteration! Helmut 2017-08-20 16:06
- The ultimate crackpot iteration! ElMaestro 2017-08-20 15:28
- The ultimate crackpot iteration! Helmut 2017-08-20 15:11
- Initial sample size guess for the Potvin methods Helmut 2017-08-19 16:06