## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", message = FALSE, warning = FALSE, fig.width = 6.2, fig.height = 5, fig.align = "center" ) set.seed(1) ## ----load--------------------------------------------------------------------- library(survrec) ## ----data-mmc----------------------------------------------------------------- data(MMC) head(MMC) ## ----data-colon--------------------------------------------------------------- data(colon) head(colon) ## ----survr-------------------------------------------------------------------- x <- Survr(MMC$id, MMC$time, MMC$event) ## ----fit-basic---------------------------------------------------------------- fit <- survfitr(Survr(id, time, event) ~ 1, data = MMC, type = "wang-chang") fit ## ----quantiles---------------------------------------------------------------- quantile(fit, probs = c(0.25, 0.5, 0.75)) ## ----autoplot-basic, fig.cap = "Wang-Chang estimate of the MMC gap-time survival."---- autoplot(fit) ## ----estimators, fig.cap = "The three estimators on the MMC data."------------ plotEstimators(x) ## ----frailty------------------------------------------------------------------ mle <- mlefrailty_fit(x, alpha.console = FALSE) mle$alpha ## ----frailties---------------------------------------------------------------- round(mle$frailties, 3) ## ----colon-fit, fig.cap = "PSH estimates of the rehospitalization gap times by Dukes stage."---- fit.dukes <- survfitr(Survr(hc, time, event) ~ as.factor(dukes), data = colon, type = "pena" ) autoplot(fit.dukes) ## ----tidy--------------------------------------------------------------------- head(as.data.frame(fit.dukes)) ## ----mcf, fig.cap = "Mean cumulative number of rehospitalizations by Dukes stage."---- autoplot(mcf(Survr(hc, time, event) ~ as.factor(dukes), data = colon)) ## ----survdiffr---------------------------------------------------------------- b <- survdiffr(Survr(hc, time, event) ~ as.factor(dukes), data = colon, q = 0.5, B = 199, boot.F = "WC", seed = 2026 ) ## ----survdiffr-summary-------------------------------------------------------- summary(b) ## ----survdiffr-plot, fig.cap = "Bootstrap distributions of the median rehospitalization-free time."---- autoplot(b) ## ----bootci------------------------------------------------------------------- boot::boot.ci(b$"1", type = c("norm", "basic", "perc")) ## ----session------------------------------------------------------------------ sessionInfo()