# overallvar: calculate the overall variance In PWEALL: Design and Monitoring of Survival Trials Accounting for Complex Situations

## Description

This will calculate the overall variance accouting for staggered entry, delayed treatment effect, treatment crossover and loss to follow-up.

## Usage

 1 2 3 4 5 6 7 8 overallvar(tfix=2.0,taur=5,u=c(1/taur,1/taur),ut=c(taur/2,taur),pi1=0.5, rate11=c(1,0.5),rate21=rate11,rate31=c(0.7,0.4), rate41=rate21,rate51=rate21,ratec1=c(0.5,0.6), rate10=rate11,rate20=rate10,rate30=rate31, rate40=rate20,rate50=rate20,ratec0=c(0.6,0.5), tchange=c(0,1),type1=1,type0=1, rp21=0.5,rp20=0.5, eps=1.0e-2,veps=1.0e-2,beta=0) 

## Arguments

 tfix The time point where the overall variance is computed. taur Recruitment time u Piecewise constant recuitment rate ut Recruitment intervals pi1 Allocation probability for the treatment group rate11 Hazard before crossover for the treatment group rate21 Hazard after crossover for the treatment group rate31 Hazard for time to crossover for the treatment group rate41 Hazard after crossover for the treatment group for complex case rate51 Hazard after crossover for the treatment group for complex case ratec1 Hazard for time to censoring for the treatment group rate10 Hazard before crossover for the control group rate20 Hazard after crossover for the control group rate30 Hazard for time to crossover for the control group rate40 Hazard after crossover for the control group for complex case rate50 Hazard after crossover for the control group for complex case ratec0 Hazard for time to censoring for the control 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 rate11, rate21, rate31, etc. type1 Type of crossover in the treatment group type0 Type of crossover in the control group rp21 re-randomization prob in the treatment group rp20 re-randomization prob in the control 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. veps A small number representing the error tolerance when calculating the Fisher information. beta The value at which the varaince is computed.

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

## Value

 vbeta The variance of the overall log hazard ratio at the specified beta vs The variance of the score function at the specified beta xdenom Fisher information at the specified beta EA value of the score function EA2 The first part of the variance AB Half of the second part of the variance

## Note

Version 1.0 (7/19/2016)

Xiaodong Luo

## References

Luo, et al. (2017)

pwe,rpwe,qpwe,ovbeta,innervar
  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 taur<-1.2 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) ###variance with beta=0, calculate log-rank variance under the alternative vbeta0<-overallvar(tfix=2.0,taur=taur,u=u,ut=ut,pi1=0.5, rate11=r11,rate21=r21,rate31=r31,rate41=r41,rate51=r51,ratec1=rc1, rate10=r10,rate20=r20,rate30=r30,rate40=r40,rate50=r50,ratec0=rc0, tchange=c(0,1),type1=1,type0=1,eps=1.0e-2,veps=1.0e-2,beta=0) ###variance with beta=0, calculate log-rank variance under the alternative ###Estimate the overall beta getbeta<-ovbeta(tfix=2.0,taur=taur,u=u,ut=ut,pi1=0.5, rate11=r11,rate21=r21,rate31=r31,rate41=r41,rate51=r51,ratec1=rc1, rate10=r10,rate20=r20,rate30=r30,rate40=r40,rate50=r50,ratec0=rc0, tchange=c(0,1),type1=1,type0=1,eps=1.0e-2,veps=1.0e-2,beta0=0, epsbeta=1.0e-4,iterbeta=25) vbeta<-overallvar(tfix=2.0,taur=taur,u=u,ut=ut,pi1=0.5, rate11=r11,rate21=r21,rate31=r31,rate41=r41,rate51=r51,ratec1=rc1, rate10=r10,rate20=r20,rate30=r30,rate40=r40,rate50=r50,ratec0=rc0, tchange=c(0,1),type1=1,type0=1,eps=1.0e-2,veps=1.0e-2,beta=getbeta$b1) cbind(vbeta0$vs,vbeta\$vs)