Learn R Programming

survminer (version 0.4.2)

surv_pvalue: Compute P-value Comparing Survival Curves

Description

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.

Usage

surv_pvalue(fit, data = NULL, method = "survdiff", test.for.trend = FALSE,
  combine = FALSE, ...)

Arguments

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:

  • "survdiff", log-rank;

  • "1": log-rank, LR; --> Regular log-rank test, sensitive to detect late differences.

  • "n": Gehan-Breslow (generalized Wilcoxon), GB; --> detect early differences.

  • "sqrtN": Tarone-Ware, TW; --> detect early differences.

  • "S1": Peto-Peto's modified survival estimate, PP; --> more robust than Tharone-Whare or Gehan-Breslow, detect early differences

  • "S2": modified Peto-Peto (by Andersen), mPP

  • "FH_p=1_q=1": Fleming-Harrington(p=1, q=1), FH

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. To learn more about the mathematical background behind the different log-rank weights, read the following blog post on R-Addict: Comparing (Fancy) Survival Curves with Weighted Log-rank Tests

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.

Value

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

Examples

Run this code
# NOT RUN {
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)

# }

Run the code above in your browser using DataLab