kmdiff: Difference in two Kaplan-Meier estimates

kmdiffR Documentation

Difference in two Kaplan-Meier estimates

Description

Draw a confidence band for comparing two survival curves. The shaded region is centered at the midpoint of the two survival estimates, and the height is half the width of the approximate conf.int pointwise confidence region. Curves not overlapping the shaded area are approximately significantly different at the 1 - conf.int level.

Usage

kmdiff(object, col = adjustcolor("grey", 0.5), conf.int = 0.95)

Arguments

object

an object of class survfit

col

color used for the band

conf.int

the level of the two-sided confidence interval

See Also

Adapted from rms::survdiffplot

Examples

library('survival')
fit <- survfit(Surv(time, status) ~ sex, lung)

## survival:::plot.survfit
plot(fit, mark.time = TRUE, col = 1:2)
kmdiff(fit)

## rawr::kmplot (add = TRUE to add to plot before resetting par)
kmplot(fit, add = TRUE)
kmdiff(fit)
legend(
  'topright', fill = adjustcolor('grey', 0.5),
  legend = sprintf('Difference\n1/2 %s CL', fit$conf.int)
)


raredd/rawr documentation built on May 19, 2024, 1:02 p.m.