Calculates and adds a p-value comparing the survival curves of each
stratified model in a table created with tbl_survfit(). Called as
add_p() on a tbl_survfit object.
Arguments
x(tbl_survfit)
A table created withtbl_survfit().test(stringor formula-list)
The test: one of"logrank","survdiff","petopeto_gehanwilcoxon","coxph_lrt","coxph_wald"and"coxph_score". A string applies to every model; a formula list sets the test per variable, e.g.list(trt ~ "logrank", grade ~ "survdiff"). Default is"logrank". See tests for how each is computed.test.args(namedlistor formula-list)
Additional arguments passed to the test, e.g.list(rho = 0.5)for a test of the G-rho family withtest = "survdiff". A named list applies to every model; a formula list sets the arguments per variable.pvalue_fun(function)
Function that rounds and formats the p-values. Default islabel_style_pvalue(digits = 1).include(selector)
The stratified models to compute a p-value for. Default iseverything()....Not used.
Note
The p-values are computed by survival::survdiff() or
survival::coxph() from the formula and data of the original survfit()
call, so both must be evaluable; see the formula specification section
of tbl_survfit() and tbl_survfit_errors.
See also
Other survival tables:
add_n_survfit,
add_nevent_survfit,
tbl_survfit(),
tbl_survfit_errors
Examples
library(survival)
tbl <- list(
survfit(Surv(ttdeath, death) ~ grade, trial),
survfit(Surv(ttdeath, death) ~ trt, trial)
) |>
tbl_survfit(times = c(12, 24))
# Example 1 ----------------------------------
tbl |>
add_p()
# Example 2 ----------------------------------
# a test of the G-rho family, with `rho` passed to `survdiff()`
tbl |>
add_p(test = "survdiff", test.args = list(rho = 0.5))