instudyfindt: calculate the timeline in study when some or all subjects... In PWEALL: Design and Monitoring of Survival Trials Accounting for Complex Situations

Description

This will calculate the timeline from some timepoint in study when some/all subjects have entered accouting for staggered entry, delayed treatment effect, treatment crossover and loss to follow-up.

Usage

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 instudyfindt(target=400,y=exp(rnorm(300)),z=rbinom(300,1,0.5), d=rep(c(0,1,2),each=100), tcut=2,blinded=1,type0=1,type1=type0, rp20=0.5,rp21=0.5,tchange=c(0,1), rate10=c(1,0.7),rate20=c(0.9,0.7),rate30=c(0.4,0.6),rate40=rate20, rate50=rate20,ratec0=c(0.3,0.3), rate11=rate10,rate21=rate20,rate31=rate30, rate41=rate40,rate51=rate50,ratec1=ratec0, withmorerec=1, ntotal=1000,taur=5,u=c(1/taur,1/taur),ut=c(taur/2,taur),pi1=0.5, ntype0=1,ntype1=1, nrp20=0.5,nrp21=0.5,ntchange=c(0,1), nrate10=rate10,nrate20=rate20,nrate30=rate30,nrate40=rate40, nrate50=rate50,nratec0=ratec0, nrate11=rate10,nrate21=rate20,nrate31=rate30,nrate41=rate40, nrate51=rate50,nratec1=ratec0, eps=1.0e-2,init=tcut*1.1,epsilon=0.001,maxiter=100)

Arguments

 target target number of events y observed times z observed treatment indicator when blinded=0, z=1 denotes the treatment group and 0 the control group d event indicator, 1=event, 0=censored, 2=no event or censored up to tcut, the data cut-point tcut the data cut-point blinded blinded=1 if the data is blinded,=0 if it is unblinded type0 type of the crossover for the observed data in the control group type1 type of the crossover for the observed data in the treatment group rp20 re-randomization prob for the observed data in the control group rp21 re-randomization prob for the observed data in the treatment group tchange A strictly increasing sequence of time points at which the event rates changes. The first element of tchange must be zero. It must have the same length as ratejk, j=1,2,3,4,5,c; k=0,1 rate10 Hazard before crossover for the old subjects in the control group rate20 Hazard after crossover for the old subjects in the control group rate30 Hazard for time to crossover for the old subjects in the control group rate40 Hazard after crossover for the old subjects in the control group for complex case rate50 Hazard after crossover for the old subjects in the control group for complex case ratec0 Hazard for time to censoring for the old subjects in the control group rate11 Hazard before crossover for the old subjects in the treatment group rate21 Hazard after crossover for the old subjects in the treatment group rate31 Hazard for time to crossover for the old subjects in the treatment group rate41 Hazard after crossover for the old subjects in the treatment group for complex case rate51 Hazard after crossover for the old subjects in the treatment group for complex case ratec1 Hazard for time to censoring for the old subjects in the treatment group withmorerec withmorerec=1 if more subjects are needed to be recruited; =0 otherwise ntotal total number of the potential new subjects taur recruitment time for the potential new subjects u Piecewise constant recuitment rate for the potential new subjects ut Recruitment intervals for the potential new subjects pi1 Allocation probability to the treatment group for the potential new subjects ntype0 type of the crossover for the potential new subjects in the control group ntype1 type of the crossover for the potential new subjects in the treatment group nrp20 re-randomization prob for the potential new subjects in the control group nrp21 re-randomization prob for the potential new subjects in the treatment group ntchange A strictly increasing sequence of time points at which the event rates changes. The first element of ntchange must be zero. It must have the same length as nratejk, j=1,2,3,4,5,c; k=0,1 nrate10 Hazard before crossover for the potential new subjects in the control group nrate20 Hazard after crossover for the potential new subjects in the control group nrate30 Hazard for time to crossover for the potential new subjects in the control group nrate40 Hazard after crossover for the potential new subjects in the control group for complex case nrate50 Hazard after crossover for the potential new subjects in the control group for complex case nratec0 Hazard for time to censoring for the potential new subjects in the control group nrate11 Hazard before crossover for the potential new subjects in the treatment group nrate21 Hazard after crossover for the potential new subjects in the treatment group nrate31 Hazard for time to crossover for the potential new subjects in the treatment group nrate41 Hazard after crossover for the potential new subjects in the treatment group for complex case nrate51 Hazard after crossover for the potential new subjects in the treatment group for complex case nratec1 Hazard for time to censoring for the potential new subjects in the treatment group eps A small number representing the error tolerance when calculating the utility function Φ_l(x)=\frac{\int_0^x s^l e^{-s}ds}{x^{l+1}} with l=0,1,2. init initital value of the timeline estimate epsilon A small number representing the error tolerance when calculating the timeline. maxiter Maximum number of iterations when calculating the timeline

Details

The hazard functions corresponding to rate11,...,rate51,ratec1, rate10,...,rate50,ratec0 are all piecewise constant function taking the form λ(t)=∑_{j=1}^m λ_j I(t_{j-1}≤ t<t_j), where λ_1,…,λ_m are the corresponding elements of the rates and t_0,…,t_{m-1} are the corresponding elements of tchange, t_m=∞. Note that all the rates must have the same tchange. The hazard functions corresponding to nrate11,...,nrate51,nratec1, nrate10,...,nrate50,nratec0 are all piecewise constant functions and all must have the same ntchange.

Value

 t1 the calculated timeline dvalue the number of events dvprime the derivative of the event cummulative function at time t1 tvar the variance of the timeline estimator ny total number of subjects that could be in the study eps final tolerance iter Number of iterations performed t1hist the history of the iteration for timeline dvaluehist the history of the iteration for the event count dvprimehist the history of the iteration for the derivative of event count with respect to time

Note

Version 1.0 (7/19/2016)

Xiaodong Luo

References

Luo, et al. (2017)

 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 n<-1000 target<-550 ntotal<-1000 pi1<-0.5 taur<-2.8 u<-c(1/taur,1/taur) ut<-c(taur/2,taur) r11<-c(1,0.5) r21<-c(0.5,0.8) r31<-c(0.7,0.4) r41<-r51<-r21 rc1<-c(0.5,0.6) r10<-c(1,0.7) r20<-c(0.5,1) r30<-c(0.3,0.4) r40<-r50<-r20 rc0<-c(0.2,0.4) tchange<-c(0,1.873) tcut<-2 ####generate the data E<-T<-C<-Z<-delta<-rep(0,n) E<-rpwu(nr=n,u=u,ut=ut)$r Z<-rbinom(n,1,pi1) n1<-sum(Z) n0<-sum(1-Z) C[Z==1]<-rpwe(nr=n1,rate=rc1,tchange=tchange)$r C[Z==0]<-rpwe(nr=n0,rate=rc0,tchange=tchange)$r T[Z==1]<-rpwecx(nr=n1,rate1=r11,rate2=r21,rate3=r31, rate4=r41,rate5=r51,tchange=tchange,type=1)$r T[Z==0]<-rpwecx(nr=n0,rate1=r10,rate2=r20,rate3=r30, rate4=r40,rate5=r50,tchange=tchange,type=1)$r y<-pmin(pmin(T,C),tcut-E) y1<-pmin(C,tcut-E) delta[T<=y]<-1 delta[C<=y]<-0 delta[tcut-E<=y & tcut-E>0]<-2 delta[tcut-E<=y & tcut-E<=0]<--1 ys<-y[delta>-1] Zs<-Z[delta>-1] ds<-delta[delta>-1] nplus<-sum(delta==-1) nd0<-sum(ds==0) nd1<-sum(ds==1) nd2<-sum(ds==2) ntaur<-taur-tcut nu<-c(1/ntaur,1/ntaur) nut<-c(ntaur/2,ntaur) ###calculate the timeline at baseline xt<-pwecxpwufindt(target=target,ntotal=n,taur=taur,u=u,ut=ut,pi1=pi1, rate11=r11,rate21=r21,rate31=r31,ratec1=rc1, rate10=r10,rate20=r20,rate30=r30,ratec0=rc0, tchange=tchange,eps=0.001,init=taur,epsilon=0.000001,maxiter=100) ###calculate the timeline in study yt<-instudyfindt(target=target,y=ys,z=Zs,d=ds, tcut=tcut,blinded=0,type1=1,type0=1,tchange=tchange, rate10=r10,rate20=r20,rate30=r30,ratec0=rc0, rate11=r11,rate21=r21,rate31=r31,ratec1=rc1, withmorerec=1, ntotal=nplus,taur=ntaur,u=nu,ut=nut,pi1=pi1, ntype1=1,ntype0=1,ntchange=tchange, nrate10=r10,nrate20=r20,nrate30=r30,nratec0=rc0, nrate11=r11,nrate21=r21,nrate31=r31,nratec1=rc1, eps=1.0e-2,init=2,epsilon=0.001,maxiter=100) ##timelines c(yt$t1,xt$t1) ##standard errors of the timeline estimators c(sqrt(yt$tvar/yt$ny),sqrt(xt$tvar/n)) ###95 percent CIs c(yt$t1-1.96*sqrt(yt$tvar/yt$ny),yt$t1+1.96*sqrt(yt$tvar/yt$ny)) c(xt$t1-1.96*sqrt(xt$tvar/n),xt$t1+1.96*sqrt(xt$tvar/n))