Description Usage Arguments Details Value Author(s) References See Also Examples
These two functions estimate the covariance and correlations between the two arbitrary weight functions, which are not necessary to be Fleming-Harrington family.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
survival |
The time to event or censoring, not that, it's the follow-up time after entoring, you may also consider as the total at-risk time. |
delta |
The event indicator, with 1 indicating observed events, and 0 indicating censoring. |
trt |
The treatment assignment indicator, with 1 indicating treatment group, and 0 as control group. |
w1 |
It has the default function which will return standard log-rank test with weight 1 and thus the function will be reduced to a variance for log-rank tests, and correlation always equals 1. If the two weights are identical, |
w2 |
Same requirements as the other argument |
Any two weight functions can be assigned to arguments w1
and w2
. Two examples, one is Fleming-Harrington family and the other is not, are demonstrated in the examples section.
The two functions, WLR.test.cov
returns the covariance, WLR.test.cor
returns the correlation coefficient estimate solely based on the input data.
Lili Wang
Hasegawa, T. (2016). Group sequential monitoring based on the weighted log‐rank test statistic with the Fleming–Harrington class of weights in cancer vaccine studies. Pharmaceutical statistics, 15(5), 412-419.
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 | # install.packages("devtools")
# library(devtools)
# install_github("keaven/nphsim")
library(nphsim)
eps<-2 # delayed effect
p<-0.5 #treatment assignment
b<-30 # an intrinsic parameter to decide the number of intervals per time unit
tau<- 18 # end of the study
R<-14 # accrual period [0,R]
omega<- tau-R
lambda<-log(2)/6 # control group risk hazard
theta<-0.7 # hazard ratio
lambda.trt<- lambda*theta #hazard after the change point for the treatment arm
rho<- 0 # parameter for the weights
gamma<-1 #parameter for the weights
alpha<-0.025 #type 1 error
beta<-0.1 #type 2 error
# First we decide the sample size:
size_FH <- sample.size_FH(eps,p,b,tau,omega,lambda,lambda.trt,rho, gamma,alpha,beta)
n_FH <-size_FH$n
n_event_FH<-size_FH$n_event
d_fixed<-ceiling(-0.6*n_event_FH)
accrual.rt<-n_FH/R # the needed arrual rate
#Generate data accordingly, use eta=1e-5 to inhibit censoring
data_temp <- nphsim(nsim=1,lambdaC=lambda, lambdaE = c(lambda,lambda.trt),
ssC=ceiling(n_FH*(1-p)),intervals = c(eps),ssE=ceiling(n_FH*p),
gamma=accrual.rt, R=R, eta=1e-5, fixEnrollTime = TRUE)$simd
# Example 1 for WLR.test.cov and WLR.test.cor: Fleming-Harrington family Weights
# I will let w1 be the default 1
# define a WLRT for w2 accodring to the rho and gamma defined above.
w2<-function(...){survKM_minus(...)^rho*(1-survKM_minus(...))^gamma}
data_interim<-data.trim.d(d_fixed,data_temp)[[1]] #data trimmed at the interim stage, the second enry on the list is the interim time, refer to function data.trim.d for details.
data_final<-data.trim.d(n_event_FH,data_temp)[[1]] #data trimmed at the final stage
WLR.test.cov(survival=data_interim$survival,delta=data_interim$delta,trt=data_interim$trt,w2=w2)
WLR.test.cor(survival=data_interim$survival,delta=data_interim$delta,trt=data_interim$trt,w2=w2)
# The variance should be identical to the output from I_t and correlation is 1 if two weights are identical.
WLR.test.cov(survival=data_interim$survival,delta=data_interim$delta,trt=data_interim$trt,w1=w2,w2=w2)
I_t.2(data_interim,data_interim,rho,gamma)
WLR.test.cor(survival=data_interim$survival,delta=data_interim$delta,trt=data_interim$trt,w1=w2,w2=w2)
#Example 2 for WLR.test.cov and WLR.test.cor: any Weights
w2_2<-function(v,...){1-exp(-v*0.25)}
WLR.test.cov(survival=data_interim$survival,delta=data_interim$delta,trt=data_interim$trt,w2=w2_2)
WLR.test.cor(survival=data_interim$survival,delta=data_interim$delta,trt=data_interim$trt,w2=w2_2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.