data(dataDIVAT2)
#Raw effect of the treatment
cox.raw <- coxph(Surv(times,failures) ~ ecd, data=dataDIVAT2, x=TRUE)
summary(cox.raw)
#Conditional effect of the treatment
cox.cdt <- coxph(Surv(times,failures) ~ ecd + age + retransplant,
data=dataDIVAT2, x=TRUE)
summary(cox.cdt)
#Marginal effect of the treatment (ATE): use 1000 iterations instead of 10
#We restricted to 10 to respect the CRAN policy in terms of time for computation
gc.ate <- gc.survival(object=cox.cdt, data=dataDIVAT2, group="ecd", times="times",
failures="failures", max.time=max(dataDIVAT2$times), iterations=10, effect="ATE",
n.cluster=1)
gc.ate
#Sum-up of the 3 HRs
data.frame( raw=exp(cox.raw$coefficients),
conditional=exp(cox.cdt$coefficients[1]),
marginal.ate=exp(gc.ate$logHR[,1]) )
#Plot the survival curves
plot(gc.ate, ylab="Confounder-adjusted survival",
xlab="Time post-transplantation (years)", col=c(1,2))
Run the code above in your browser using DataLab