surv_test | R Documentation |
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).
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
)
object |
a |
details |
logical; |
formula , data , rho , ... |
passed to |
pFUN |
logical; if |
method |
for |
tau , iter , seed |
arguments passed to |
digits , conf , show_conf |
for |
formula1 , formula2 |
for |
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.
survdiff_pairs
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.