surv_test: Survival curve tests

surv_testR Documentation

Survival curve tests

Description

Internal functions for survdiff and survfit objects. Current methods include log-rank (lr_*) and pairwise (pw_*) log-rank tests (by default although the exact test may be controlled with the rho parameter passed to survdiff); a trend test described by Tarone (tt_*); and Wald tests of coefficients in a Cox regression (hr_*).

*_pval functions take (survfit or survdiff) objects or formulas and compute test statistics, p-values, etc. and return a numeric vector or list.

*_text functions format the test results for plotting and return an expression or vector of character strings.

Note that pw_pval and pw_text do not support formulas with more than one predictor, e.g., y ~ a + b. An equivalent formula is acceptable, e.g., y ~ x where x is the interaction(a, b) or similar. See survdiff_pairs for more details and examples.

c_text, cc_pval, and cc_text are convenience functions for Inf.Cval and Inf.Cval.Delta to compute and compare c-statistics on censored data. c_text shows c for a single model where cc_text and cc_pval compare two models; see Uno (2011).

Usage

lr_pval(object, details = FALSE, data = NULL, ...)

lr_text(formula, data, rho = 0, ..., details = TRUE, pFUN = NULL)

tt_pval(object, details = FALSE, data = NULL, ...)

tt_text(formula, data, ..., details = TRUE, pFUN = NULL)

hr_pval(object, details = FALSE, data = NULL, ...)

hr_text(formula, data, ..., details = TRUE, pFUN = NULL)

pw_pval(object, details = FALSE, data = NULL, ..., method = "none")

pw_text(formula, data, ..., details = TRUE, pFUN = NULL, method = "none")

c_text(
  formula,
  data,
  tau = NULL,
  iter = 1000L,
  seed = 1L,
  digits = 2L,
  conf = 0.95,
  show_conf = TRUE,
  details = FALSE
)

cc_pval(formula1, formula2, data, tau = NULL, iter = 1000L, seed = 1L)

cc_text(
  formula1,
  formula2,
  data,
  tau = NULL,
  iter = 1000L,
  seed = 1L,
  digits = 2L,
  conf = 0.95,
  show_conf = TRUE,
  details = TRUE
)

Arguments

object

a survfit, survdiff, or coxph object; alternatively a survival formula in which case data must be given

details

logical; TRUE returns statistic, degrees of freedom, and p-value where FALSE returns only a pvalue

formula, data, rho, ...

passed to survdiff or coxph

pFUN

logical; if TRUE, p-values are formatted with pvalr; if FALSE, no formatting is performed; alternatively, a function can be passed which should take a numeric value and return a character string (or a value to be coerced) for printing

method

for pw_*, the method used to adjust p-values for multiple comparisons (default is "none"); see p.adjust.methods

tau, iter, seed

arguments passed to Inf.Cval or Inf.Cval.Delta

digits, conf, show_conf

for c_text and cc_text, options to control the text output

formula1, formula2

for cc_pva and cc_text, the formulas of the two models to compare

References

Tarone, Robert E. Tests for Trend in Life Table Analysis. Biometrika 62 vol. 62 (Dec 1975), 679-82.

Tarone, see also: https://stat.ethz.ch/pipermail/r-help/2008-April/160209.html

Uno, Hajime, et al. On the C-statistics for Evaluating Overall Adequacy of Risk Prediction Procedures with Censored Survival Data. Statistics in Medicine 30 vol. 10 (May 2011), 1105-17.

See Also

survdiff_pairs

Examples

## Not run: 
library('survival')
data('larynx', package = 'KMsurv')
larynx$stage <- factor(larynx$stage)

form <- Surv(time, delta) ~ stage
sf <- survfit(form, larynx)
sd <- survdiff(form, larynx)

kmplot(sf, lr_test = TRUE)


## log-rank
rawr:::lr_pval(sf)
rawr:::lr_pval(sd, TRUE)
rawr:::lr_text(Surv(time, delta) ~ stage, larynx)


## pairwise log-rank
sf$call$formula <- form
rawr:::pw_pval(sf)
rawr:::pw_text(sf)


## tarone trend
rawr:::tt_pval(sf)
rawr:::tt_pval(sd, TRUE)
rawr:::tt_text(Surv(time, delta) ~ stage, larynx)

## compare
chi <- coxph(Surv(time, delta) ~ stage, larynx)$score
list(chi = chi, p.value = pchisq(chi, 1, lower.tail = FALSE))


## hazard ratio/wald p-values
rawr:::hr_pval(sf)
rawr:::hr_pval(sd, TRUE)
rawr:::hr_text(Surv(time, delta) ~ stage, larynx)


## c-statistics for censored data (uno, 2011)
f1 <- Surv(time, delta) ~ stage
f2 <- Surv(time, delta) ~ stage + age
rawr:::c_text(f1, larynx)
rawr:::c_text(f2, larynx, details = TRUE)
rawr:::cc_text(f1, f2, larynx)
rawr:::cc_pval(f1, f2, larynx)

## End(Not run)


raredd/rawr documentation built on March 4, 2024, 1:36 a.m.