surv_pvalue | R Documentation |
Compute p-value from survfit objects or parse it when provided by
the user. Survival curves are compared using the log-rank test (default).
Other methods can be specified using the argument method
.
surv_pvalue(
fit,
data = NULL,
method = "survdiff",
test.for.trend = FALSE,
combine = FALSE,
...
)
fit |
A survfit object. Can be also a list of survfit objects. |
data |
data frame used to fit survival curves. Can be also a list of data. |
method |
method to compute survival curves. Default is "survdiff" (or "log-rank"). Allowed values are one of:
To specify method, one can
use either the weights (e.g.: "1", "n", "sqrtN", ...), or the full name
("log-rank", "gehan-breslow", "Peto-Peto", ...), or the acronyme LR, GB,
.... Case insensitive partial match is allowed. |
test.for.trend |
logical value. Default is FALSE. If TRUE, returns the test for trend p-values. Tests for trend are designed to detect ordered differences in survival curves. That is, for at least one group. The test for trend can be only performed when the number of groups is > 2. |
combine |
logical value. Used only when fit is a list of survfit objects. If TRUE, combine the results for multiple fits. |
... |
other arguments including pval, pval.coord, pval.method.coord. These are only used internally to specify custom pvalue, pvalue and pvalue method coordinates on the survival plot. Normally, users don't need these arguments. |
Return a data frame with the columns (pval, method, pval.txt and variable). If additional arguments (pval, pval.coord, pval.method.coord, get_coord) are specified, then extra columns (pval.x, pval.y, method.x and method.y) are returned.
pval: pvalue
method: method used to compute pvalues
pval.txt: formatted text ready to use for annotating plots
pval.x, pval.y: x & y coordinates of the pvalue for annotating the plot
method.x, method.y: x & y coordinates of pvalue method
library(survival)
# Different survfits
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::
fit.null <- surv_fit(Surv(time, status) ~ 1, data = colon)
fit1 <- surv_fit(Surv(time, status) ~ sex, data = colon)
fit2 <- surv_fit(Surv(time, status) ~ adhere, data = colon)
fit.list <- list(sex = fit1, adhere = fit2)
# Extract the median survival
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::
surv_pvalue(fit.null)
surv_pvalue(fit2, colon)
surv_pvalue(fit.list)
surv_pvalue(fit.list, combine = TRUE)
# Grouped survfit
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::
fit.list2 <- surv_fit(Surv(time, status) ~ sex, data = colon,
group.by = "rx")
surv_pvalue(fit.list2)
# Get coordinate for annotion of the survival plots
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::
surv_pvalue(fit.list2, combine = TRUE, get_coord = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.