R Under development (unstable) (2024-09-25 r87194 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > > library("tram") Loading required package: mlt Loading required package: basefun Loading required package: variables Loading required package: mvtnorm > library("survival") > > ### check if R(Surv(...), as.R.ordered = TRUE) gives > ### results identical to KaplanMeier, also in case > ### of ties. > > ### Bland & Altman, BMJ 1998;317:1572 > prg <- data.frame(time = c(1, 1, 1, 1, 1, 1, 2, 2, + 2, 2, 2, 3, 3, 3, 4, + 4, 4, 6, 6, 9, 9, 9, 10, 13, 16, + 2, 3, 4, 7, 7, 8, 8, 9, 9, 9, + 11, 24, 24), + event = rep(c(1, 0), c(25, 13))) > ut <- with(prg, sort(unique(time[event == 1]))) > > m <- Coxph(R(Surv(time, event), as.R.ordered = TRUE) ~ 1, data = prg) > t1 <- predict(as.mlt(m), newdata = data.frame(time = 1), type = "surv") > t2 <- c(summary(survfit(Surv(time, event) ~ 1, data = prg), time = ut)$surv, 0) > stopifnot(all.equal(t1, t2, check.attributes = FALSE, tol = 1e-4)) > > ### AML > ut <- with(aml, sort(unique(time[status == 1]))) > > m <- Coxph(R(Surv(time, status), as.R.ordered = TRUE) ~ 1, data = aml) > t1 <- predict(as.mlt(m), newdata = data.frame(1), type = "surv") > t2 <- c(summary(survfit(Surv(time, status) ~ 1, data = aml), time = ut)$surv, 0) > > stopifnot(all.equal(t1, t2, check.attributes = FALSE, tol = 1e-4)) > > > proc.time() user system elapsed 0.96 0.21 1.17