Add cox time dependend analysis for death and sm
Simple analysis of influence of relapse and sm on death. The SM part is not working currently (due to limited events).
This commit is contained in:
parent
00d96d77f2
commit
465ce64487
53
cox-time.R
Normal file
53
cox-time.R
Normal file
@ -0,0 +1,53 @@
|
||||
# Cox time-depended hazard models for death and sm
|
||||
#
|
||||
# License: GPL version 3
|
||||
# Jens Mathis Sauer (c) 2020
|
||||
|
||||
sma_cox_time_death_setup <- function() {
|
||||
data <- tmerge(data1 = secmal %>% select(uuid),
|
||||
data2 = secmal,
|
||||
id = uuid,
|
||||
tstop = event_time_asct)
|
||||
data <- tmerge(data, secmal, id = uuid, death = event(event_time_asct,
|
||||
event_status))
|
||||
data <- tmerge(data, secmal, id = uuid, relapse = tdc(
|
||||
event_time_asct - event_time_relapse))
|
||||
data <- tmerge(data, secmal, id = uuid, sm = tdc(
|
||||
event_time_asct - event_time_sm))
|
||||
|
||||
return(data)
|
||||
}
|
||||
|
||||
# Calculate HR of death with time dependend relapse status
|
||||
sma_cox_death_relapse <- function() {
|
||||
data <- sma_cox_time_death_setup()
|
||||
cox <- coxph(Surv(tstart, tstop, death) ~ relapse + cluster(uuid), data)
|
||||
|
||||
return(cox)
|
||||
}
|
||||
|
||||
sma_cox_death_sm <- function() {
|
||||
data <- sma_cox_time_death_setup()
|
||||
cox <- coxph(Surv(tstart, tstop, death) ~ sm + cluster(uuid), data)
|
||||
|
||||
return(cox)
|
||||
}
|
||||
|
||||
sma_cox_time_sm_setup <- function() {
|
||||
data <- tmerge(data1 = secmal %>% select(uuid),
|
||||
data2 = secmal,
|
||||
id = uuid,
|
||||
tstop = time_at_risk)
|
||||
data <- tmerge(data, secmal, id = uuid, sm = event(event_time_sm))
|
||||
data <- tmerge(data, secmal, id = uuid, relapse = tdc(
|
||||
event_time_asct - event_time_relapse))
|
||||
|
||||
return(data)
|
||||
}
|
||||
|
||||
sma_cox_sm_rel <- function() {
|
||||
data <- sma_cox_time_sm_setup()
|
||||
cox <- coxph(Surv(tstart, tstop, sm) ~ relapse + cluster(uuid), data)
|
||||
|
||||
return(cox)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user