tocoxme: Transform data to fit coxme for comparison

Description Usage Arguments Details Value See Also Examples

View source: R/Gaussian_PPL_src.R

Description

Transform the output dataset from gen.data to fit in coxme for comparison.

Usage

1
2

Arguments

data

a list object from gen.data

Details

tocoxme is designed for positively correlated two events, and tocoxme_n is designed for negatively correlated two events.

Value

time

follow-up times

delta

event status

joint

indicator for the two event types

b0,b1,b2

indicators of the three frailties, b0 is the shared one which accounts for the correlations, b1 and b2 are for the first and second event types

Z1,Z2

covariates for the two event types

Z0

Only in tocoxme_n,

mi

number of events within each cluster

N

number of clusters

See Also

coxme

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
# install coxme by:
#   install.packages("coxme")

library(coxme) 

set.seed(100)
N<-100 # number of clusters
beta1 <- c(0.5,-0.3,0.5) # regression parameters for event type 1
beta2 <- c(0.8,-0.2,0.3) # regression parameters for event type 2
beta  <- c(beta1,beta2)
theta <- c(0.25,0.25,-0.125) # variance-covariance matrix for the bivariate frailty (denoted as D), it is a vector (D[1,1],D[2,2], D[1,2])
lambda01 <- 1
lambda02 <- 1
cen <- 10 # maximum censoring time
centype <- TRUE # fixed censoring time at cen

data <- gen.data(N,beta1,beta2,theta,lambda01,lambda02)
ptm<-proc.time()
res <- BivPPL(data,check.log.lik=TRUE) # check the convergence of the log-likelihood
proc.time() - ptm
res$beta_hat
res$beta_ASE
res$D_hat
data_coxme <- tocoxme(data) # assume that we do not know the two events are negatively associated and we transform the data to be positively associated
ptm<-proc.time()
res_coxme <- coxme(Surv(data_coxme$time,data_coxme$delta)~data_coxme$Z1+data_coxme$Z2+(1|data_coxme$b0)+(1|data_coxme$b1)+(1|data_coxme$b2)+strata(data_coxme$joint),eps=1e-6,list(reltol = 1e-5),sparse=c(1001,0.001),refine.n=0) # disable the Hessian matrix sparsening and likelihood refining
proc.time() - ptm
res_coxme$coefficients 
sqrt(diag(vcov(res_coxme)))
assemble(as.vector(unlist(res_coxme$vcoef)))

data_coxme_n <- tocoxme_n(data) # assume that we know the two events are negatively associated 
ptm<-proc.time()
res_coxme_n<- coxme(Surv(data_coxme_n$time,data_coxme_n$delta)~data_coxme_n$Z1+data_coxme_n$Z2+(data_coxme_n$Z0|data_coxme_n$b0)+(1|data_coxme_n$b1)+(1|data_coxme_n$b2)+strata(data_coxme_n$joint),eps=1e-6,list(reltol = 1e-5),sparse=c(1001,0.001),refine.n=0)
proc.time() - ptm
res_coxme_n$coefficients 
sqrt(diag(vcov(res_coxme_n)))
assemble_n(as.vector(unlist(res_coxme_n$vcoef)))

lilywang1988/BivPPL documentation built on Aug. 9, 2019, 6:14 p.m.