# NOT RUN {
library(survival)
library(rms)
set.seed(10)
n <- 100
## Cox model
dtS <- sampleData(n,outcome="survival")
dtS$time <- round(dtS$time,1)
dtS$X1 <- factor(rbinom(n, prob = c(0.3,0.4) , size = 2), labels = paste0("T",0:2))
fit=cph(formula = Surv(time,event)~ X1+X2,data=dtS,y=TRUE,x=TRUE)
# }
# NOT RUN {
ateFit1 <- ate(fit, data = dtS, treatment = "X1", contrasts = NULL,
times = 5:8, B = 1e3, y = TRUE, mc.cores=1)
ateFit1 <- ate(fit, data = dtS, treatment = "X1", contrasts = NULL,
times = 5:8, B = 1e1, y = TRUE, mc.cores=1)
ateFit2 <- ate(fit, data = dtS, treatment = "X1", contrasts = NULL,
times = 5:8, B = 0, y = TRUE, band = TRUE, mc.cores=1)
ateFit3 <- ate(fit, data = dtS, treatment = "X1", contrasts = NULL,
times = 5:8, B = 0, y = TRUE, band = TRUE, mc.cores=1,
store.iid = "minimal")
# }
# NOT RUN {
## Competing risks: Cause specific Cox regression
# }
# NOT RUN {
set.seed(17)
n=100
dt <- sampleData(n,outcome="competing.risks")
dt$time <- round(dt$time,1)
dt$X1 <- factor(rbinom(n, prob = c(0.2,0.3,0.2) , size = 3), labels = paste0("T",0:3))
fitCR= CSC(Hist(time,event)~ X1+X8,data=dt,cause=1)
ate(fitCR, data = dt, treatment = "X1", contrasts = NULL,
times = 7, cause = 1, B = 2, mc.cores=1)
atefit=ate(fitCR, data = dt, treatment = "X1", contrasts = NULL,
times = 1:7, cause = 1, mc.cores=1, se = FALSE, band = FALSE)
ate(fitCR, data = dt, treatment = "X1", contrasts = NULL,
times = 5:7, cause = 1, B = 0, se = TRUE, band = TRUE, mc.cores=1)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab