kmm_legend | R Documentation |
kmm
Compute metrics for two or more survfit
objects,
and plot results as a legend
.
kmm_legend(
list,
times = NULL,
metric = c("rmse", "mse", "sse", "mae", "sae"),
plot = TRUE,
...
)
list |
a list of two or more |
times |
a vector of times to compare curves |
metric |
the metric to show; default is the square root of the mean
squared errors |
plot |
logical; if |
... |
additional arguments passed to |
library('survival')
set.seed(1)
lung2 <- within(lung, {
time <- time / 100
## generate different curves with human error
time2 <- time + runif(nrow(lung))
time3 <- time + runif(nrow(lung), 0, 0.25)
})
truth <- survfit(Surv(time, status) ~ 1, lung2)
recap1 <- survfit(Surv(time2, status) ~ 1, lung2)
recap2 <- survfit(Surv(time3, status) ~ 1, lung2)
plot(truth, conf.int = FALSE)
lines(recap1, col = 2, conf.int = FALSE)
lines(recap2, col = 3, conf.int = FALSE)
l <- list(truth = truth, recap1 = recap1, recap2 = recap2)
## error using all unique times
kmm_legend(l)
## error using interpolated times 0-10 (ie, asymptotic error)
kmm_legend(l, times = seq(0, 10, length.out = 1e4), inset = c(0, 0.25))
## error of interpolated time interval 0-2
kmm_legend(l, times = seq(0, 2, length.out = 1e4), inset = c(0, 0.5))
## error of interpolated time interval 6-10
kmm_legend(l, times = seq(6, 10, length.out = 1e4), inset = c(0, 0.75))
## mean squared error
kmm_legend(l, metric = 'mse', x = 'top')
kmm_legend(l, times = seq(0, 10, length.out = 1e4),
metric = 'mse', x = 'top', inset = c(0, 0.25))
kmm_legend(l, times = seq(0, 2, length.out = 1e4),
metric = 'mse', x = 'top', inset = c(0, 0.5))
kmm_legend(l, times = seq(6, 10, length.out = 1e4),
metric = 'mse', x = 'top', inset = c(0, 0.75))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.