WLR.test.cov: Estimate the covariance and correlation between two arbitrary...

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/Hasegawa2016.R

Description

These two functions estimate the covariance and correlations between the two arbitrary weight functions, which are not necessary to be Fleming-Harrington family.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
WLR.test.cov(
  survival,
  delta,
  trt,
  w1 = function(v, ...) {     1 },
  w2 = function(v, ...) {     1 }
)

WLR.test.cor(
  survival,
  delta,
  trt,
  w1 = function(v, ...) {     1 },
  w2 = function(v, ...) {     1 }
)

Arguments

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, WLR.test.cov is equivalent to the estimated variance, and WLR.test.cor is always equal to 1. The function can be any non-negative functions with a basic argument v as the input time vector, which are corresponding to the follow-up times. Optionally, there are two additional variables,follow-up time survival and event indicator delta to make the weights dependent on the survival functions (like the Fleming-Harrington family). It would be better if the function itself has ... as the last argument, so that it can be robust to any misspecification of the variable names, and thus, it will just ignore the misspecified ones. Please refer to the examples to figure out how to define the Fleming-Harrington and any other weight functions.

w2

Same requirements as the other argument w1. Just not that if they are identical, WLR.test.cov returns the variance like I.t, and WLR.test.cor always returns 1.

Details

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.

Value

The two functions, WLR.test.cov returns the covariance, WLR.test.cor returns the correlation coefficient estimate solely based on the input data.

Author(s)

Lili Wang

References

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.

See Also

cor.0,cor.1, I_t.

Examples

 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)

lilywang1988/IAfrac documentation built on March 11, 2021, 11:53 a.m.