Glance accepts a model object and returns a tibble::tibble() with exactly one row of model summaries. The summaries are typically goodness of fit measures, p-values for hypothesis tests on residuals, or model convergence information.

Glance never returns information from the original call to the modelling function. This includes the name of the modelling function or any arguments passed to the modelling function.

Glance does not calculate summary measures. Rather, it farms out these computations to appropriate methods and gathers the results together. Sometimes a goodness of fit measure will be undefined. In these cases the measure will be reported as NA.

# S3 method for survfit
glance(x, ...)

Arguments

x

An survfit object returned from survival::survfit().

...

Additional arguments. Not used. Needed to match generic signature only. Cautionary note: Misspelled arguments will be absorbed in ..., where they will be ignored. If the misspelled argument has a default value, the default value will be used. For example, if you pass conf.lvel = 0.9, all computation will proceed using conf.level = 0.95. Additionally, if you pass newdata = my_tibble to an augment() method that does not accept a newdata argument, it will use the default value for the data argument.

See also

Value

A tibble::tibble() with exactly one row and columns:

events

number of events

n.max

Maximum number of subjects at risk.

n.start

Initial number of subjects at risk.

records

number of observations

rmean

Restricted mean (see [survival::print.survfit()]).

rmean.std.error

Restricted mean standard error

conf.low

lower end of confidence interval on median

conf.high

upper end of confidence interval on median

median

median survival

Examples

library(survival) cfit <- coxph(Surv(time, status) ~ age + sex, lung) sfit <- survfit(cfit) tidy(sfit)
#> # A tibble: 186 x 8 #> time n.risk n.event n.censor estimate std.error conf.high conf.low #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 5 228 1 0 0.996 0.00419 1 0.988 #> 2 11 227 3 0 0.983 0.00845 1.000 0.967 #> 3 12 224 1 0 0.979 0.00947 0.997 0.961 #> 4 13 223 2 0 0.971 0.0113 0.992 0.949 #> 5 15 221 1 0 0.966 0.0121 0.990 0.944 #> 6 26 220 1 0 0.962 0.0129 0.987 0.938 #> 7 30 219 1 0 0.958 0.0136 0.984 0.933 #> 8 31 218 1 0 0.954 0.0143 0.981 0.927 #> 9 53 217 2 0 0.945 0.0157 0.975 0.917 #> 10 54 215 1 0 0.941 0.0163 0.972 0.911 #> # ... with 176 more rows
glance(sfit)
#> # A tibble: 1 x 9 #> records n.max n.start events rmean rmean.std.error median conf.low conf.high #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 228 228 228 165 381. 20.3 320 285 363
library(ggplot2) ggplot(tidy(sfit), aes(time, estimate)) + geom_line() + geom_ribbon(aes(ymin=conf.low, ymax=conf.high), alpha=.25)
# multi-state fitCI <- survfit(Surv(stop, status * as.numeric(event), type = "mstate") ~ 1, data = mgus1, subset = (start == 0)) td_multi <- tidy(fitCI) td_multi
#> # A tibble: 474 x 9 #> time n.risk n.event n.censor estimate std.error conf.high conf.low state #> * <dbl> <int> <int> <int> <dbl> <dbl> <dbl> <dbl> <fct> #> 1 6 0 0 0 0 0 NaN NA 2 #> 2 7 0 0 0 0 0 NaN NA 2 #> 3 31 0 0 0 0 0 NaN NA 2 #> 4 32 0 0 0 0 0 NaN NA 2 #> 5 39 0 0 0 0 0 NaN NA 2 #> 6 60 0 0 0 0 0 NaN NA 2 #> 7 61 0 0 0 0 0 NaN NA 2 #> 8 152 0 0 0 0 0 NaN NA 2 #> 9 153 0 0 0 0 0 NaN NA 2 #> 10 174 0 0 0 0 0 NaN NA 2 #> # ... with 464 more rows
ggplot(td_multi, aes(time, estimate, group = state)) + geom_line(aes(color = state)) + geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .25)