# NOT RUN {
d <- sampleData(1e2, outcome = "survival")
d$entry <- 0
d$id <- 1:NROW(d)
##
library(survival)
mCoxS <- coxph(Surv(time, event) ~ strata(X1)+strata(X2), data = d, x = TRUE, y = TRUE)
resInfo <- CoxVariableName(mCoxS)
Ostrata <- CoxStrata(mCoxS, stratavars = resInfo$stratavars)
CoxStrata(mCoxS, data = d, sterms = resInfo$sterms, stratavars = resInfo$stratavars,
levels = levels(Ostrata), stratalevels = resInfo$stratalevels)
##
library(rms)
mCoxS <- cph(Surv(time, event) ~ strat(X1)+strat(X2), data = d, y = TRUE)
resInfo <- CoxVariableName(mCoxS)
Ostrata <- CoxStrata(mCoxS, stratavars = resInfo$stratavars)
CoxStrata(mCoxS, data = d, sterms = resInfo$sterms, stratavars = resInfo$stratavars,
levels = levels(Ostrata), stratalevels = resInfo$stratalevels)
##
library(mets)
mCoxS <- phreg(Surv(entry, time, event) ~ strata(X1)+X2+cluster(id), data = d)
resInfo <- CoxVariableName(mCoxS)
Ostrata <- CoxStrata(mCoxS, stratavars = resInfo$stratavars)
CoxStrata(mCoxS, data = d, sterms = resInfo$sterms, stratavars = resInfo$stratavars,
levels = levels(Ostrata), stratalevels = resInfo$stratalevels)
# }
Run the code above in your browser using DataLab