Kaplan-Meier Estimates vs. a Continuous Variable
Function to divide x (e.g. age, or predicted survival at time
u created by survest) into g quantile groups, get
Kaplan-Meier estimates at time u (a scaler), and to return a
matrix with columns x=mean x in quantile, n=number
of subjects, events=no. events, and KM=K-M survival at
time u, std.err = s.e. of -log K-M. Confidence intervals
are based on -log S(t). Instead of supplying g, the user can
supply the minimum number of subjects to have in the quantile group
(m, default=50). If cuts is given
(e.g. cuts=c(0,.1,.2,...,.9,.1)), it overrides m and
g. Calls Therneau's survfitKM in the survival
package to get Kaplan-Meiers estimates and standard errors.
groupkm(x, Srv, m=50, g, cuts, u,
pl=FALSE, loglog=FALSE, conf.int=.95, xlab, ylab,
lty=1, add=FALSE, cex.subtitle=.7, ...)x |
variable to stratify |
Srv |
a |
m |
desired minimum number of observations in a group |
g |
number of quantile groups |
cuts |
actual cuts in |
u |
time for which to estimate survival |
pl |
TRUE to plot results |
loglog |
set to |
conf.int |
defaults to |
xlab |
if |
ylab |
if |
lty |
line time for primary line connecting estimates |
add |
set to |
cex.subtitle |
character size for subtitle. Default is |
... |
plotting parameters to pass to the plot and errbar functions |
matrix with columns named x (mean predictor value in interval), n (sample size
in interval), events (number of events in interval), KM (Kaplan-Meier
estimate), std.err (standard error of -log KM)
n <- 1000 set.seed(731) age <- 50 + 12*rnorm(n) cens <- 15*runif(n) h <- .02*exp(.04*(age-50)) d.time <- -log(runif(n))/h label(d.time) <- 'Follow-up Time' e <- ifelse(d.time <= cens,1,0) d.time <- pmin(d.time, cens) units(d.time) <- "Year" groupkm(age, Surv(d.time, e), g=10, u=5, pl=TRUE) #Plot 5-year K-M survival estimates and 0.95 confidence bars by #decile of age. If omit g=10, will have >= 50 obs./group.
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.