This function performs the hypothesis tests for the twostage or threestage designs
with eventfree endpoint from OptimDes
.
1 2 3 4 5 
tan 
Study time (from first accrual) of the analysis. 
tstage 

.
x 
Prespecified time for the eventfree endpoint (e.g., 1 year). 
num.arm 
Number of treatment arms. 
num.stage 
Number of trial stages: 
Y1 
A vector containing the study start times (measured from
the beginning of the study) of patients in the treatment arm.
If times occuring after the analysis time 
T1 
A vector containing the event times corresponding to 
Y0 
A vector containing the study start times (measured from
the beginning of the study) of patients in the control arm. It does not
need to be set for 1arm trials. If times occuring after the analysis time

T0 
A vector containing the event times corresponding to 
p0 
The event rate under the null hypothesis. 
C1L 
The study is terminated for futility after the first stage if the Zstatistic is <=C1. 
C1U 
The study is terminated for efficacy after the first stage if the Zstatistic is >=C1U. 
C2L 
For a threestage design, stop for futility after the second stage if Z<=C2. 
C2U 
For a threestage design, stop for efficacy after the second stage if the Z>=C2U. For a twostage design, reject the null hypothesis at the final stage if the Z>=C2U. 
C3U 
For a threestage design, reject the null hypothesis at the final stage if the Z>=C3U. 
printTest 
If TRUE (default), the result of the test and the interim decision is printed. 
cen1 
The times in 
cen0 
The times in 
The hypothesis tests are performed in two stages as described in Huang, Talukder and Thomas (2010) and Case and Morgan (2003) for singlearm designs, and extended to the randomized twoarm twostage and threestage designs.
For twostage designs:
Stage 1. Accrue patients between time 0 and time t1
. Each
patient will be followed until failure, or for x
years or until
time t1
, whichever is less. Calculate the normalized interim test
statistic Z1
. If Z1<=C1
, stop the study for futility; For
randomized twoarm trials, if Z1>=C1U
, stop the study for efficacy;
otherwise, continue to the next stage.
Stage 2. Accrue patients between t1
and MDA
. Follow all
patients until failure or for x
years, then calculate the
normalized final test statistic Z2
, and reject H0 if
Z2>=C2
.
For threestage designs:
Stage 1. Accrue patients between time 0 and time t1
. Each
patient will be followed until failure, or for x
years or until
time t1
, whichever is less. Calculate the normalized interim test
statistic Z1
. If Z1<=C1
, stop the study for futility; For
randomized twoarm trials, if Z1>=C1U
, stop the study for efficacy;
otherwise, continue to the next stage.
Stage 2. Accrue patients between t1
and t2
. Follow all
patients until failure or for x
years, then calculate the
normalized final test statistic Z2
. If Z2<=C2
, stop the study for futility; For
randomized twoarm trials, if Z2>=C2U
, stop the study for efficacy;
otherwise, continue to the next stage.
Stage 3. Accrue patients between t2
and MDA
. Follow all
patients until failure or for x
years, then calculate the
normalized final test statistic Z3
, and reject H0 if
Z3>=C3
.
The test statistic is based on the NelsonAalen estimator of the cumulative hazard function.
A vector containing results for the interim analysis or the final analysis:
z 
The test statistic 
se 
Standard error of sum of the cummulative hazards (not log
cummulative hazards) at time 
cumL 
A twoelement vector of cummulative hazard estimators at time 
Bo Huang <bo.huang@pfizer.com> and Neal Thomas <neal.thomas@pfizer.com>
Huang B., Talukder E. and Thomas N. Optimal twostage Phase II designs with longterm endpoints. Statistics in Biopharmaceutical Research, 2(1), 51–61.
Case M. D. and Morgan T. M. (2003) Design of Phase II cancer trials evaluating survival probabilities. BMC Medical Research Methodology, 3, 7.
Lin D. Y., Shen L., Ying Z. and Breslow N. E. (1996) Group seqential designs for monitoring survival probabilities. Biometrics, 52, 1033–1042.
Simon R. (1989) Optimal twostage designs for phase II clinical trials. Controlled Clinical Trials, 10, 1–10.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76  ## Not run:
### single arm trial
B.init < c(1, 2, 3, 4, 5)
m.init < c(15, 20, 25, 20, 15)
alpha < 0.05
beta < 0.1
param < c(1, 1.09, 2, 1.40)
x < 1
# H0: S0=0.40 H1: S1=0.60
shape0 < param[1]
scale0 < param[2]
shape1 < param[3]
scale1 < param[4]
object1 < OptimDes(B.init,m.init,alpha,beta,param,x,target="EDA",sf="futility",num.arm=1,num.stage=2)
n < object1$n[2]
t1 < object1$stageTime[1]
C1 < object1$boundary[1]
C1U < object1$boundary[2]
C2 < object1$boundary[3]
b < length(B.init)
l < rank(c(cumsum(m.init),n),ties.method="min")[b+1]
mda < ifelse(l>1,B.init[l1]+(B.init[l]B.init[l1])*(nsum(m.init[1:(l1)]))/m.init[l],B.init[l]*(n/m.init[l]))
### set up values to create a stepwise uniform distribution for accrual
B < B.init[1:l]
B[l] < mda
xv < c(0,B)
M < m.init[1:l]
M[l] < ifelse(l>1,nsum(m.init[1:(l1)]),n)
yv < c(0,M/(diff(xv)*n),0)
# density function of accrual
dens.Y < stepfun(xv,yv,f=1,right=TRUE)
# pool of time points to be simulated from
t.Y < seq(0,mda,by=0.01)
# simulate study times of length n
sample.Y < sample(t.Y,n,replace=TRUE,prob=dens.Y(t.Y))
# simulate failure times of length n under the alternative hypothesis
sample.T < rweibull(n,shape=shape1,scale=scale1)
Y1 < sample.Y[sample.Y<=t1]
T1 < sample.T[sample.Y<=t1]
Y2 < sample.Y[sample.Y>t1]
T2 < sample.T[sample.Y>t1]
# event rate under null hypothesis
p0<pweibull(x,shape=shape0,scale=scale0)
# interim analysis
TestStage(x, C1, C1U, C2, tan=t1,num.arm=1,num.stage=2,Y11=Y1, T11=T1, p0=p0)
# final analysis if the study continues
TestStage(x, C1, C1U, C2, tan=t1,num.arm=1,num.stage=2,Y11=Y1, T11=T1, p0=p0)
# simulate failure times of length n under the null hypothesis
sample.T < rweibull(n,shape=shape0,scale=scale0)
Y1 < sample.Y[sample.Y<=t1]
T1 < sample.T[sample.Y<=t1]
Y2 < sample.Y[sample.Y>t1]
T2 < sample.T[sample.Y>t1]
# interim analysis
TestStage(x, C1, C1U, C2, tan=t1,num.arm=1,num.stage=2,Y11=Y1, T11=T1, p0=p0)
# final analysis if the study continues
TestStage(x, C1, C1U, C2, tan=mda+x,num.arm=1,num.stage=2,Y11=Y1, T11=T1, p0=p0,Y21=Y2,T21=T2)
## End(Not run)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.