Learn R Programming

survival (version 2.38-3)

survdiff: Test Survival Curve Differences

Description

Tests if there is a difference between two or more survival curves using the $G^\rho$ family of tests, or for a single curve against a known alternative.

Usage

survdiff(formula, data, subset, na.action, rho=0)

Arguments

formula
a formula expression as for other survival models, of the form Surv(time, status) ~ predictors. For a one-sample test, the predictors must consist of a single offset(sp) term, where sp is a vector giving the surviva
data
an optional data frame in which to interpret the variables occurring in the formula.
subset
expression indicating which subset of the rows of data should be used in the fit. This can be a logical vector (which is replicated to have length equal to the number of observations), a numeric vector indicating which observation numbers are to be inclu
na.action
a missing-data filter function. This is applied to the model.frame after any subset argument has been used. Default is options()$na.action.
rho
a scalar parameter that controls the type of test.

Value

  • a list with components:
  • nthe number of subjects in each group.
  • obsthe weighted observed number of events in each group. If there are strata, this will be a matrix with one column per stratum.
  • expthe weighted expected number of events in each group. If there are strata, this will be a matrix with one column per stratum.
  • chisqthe chisquare statistic for a test of equality.
  • varthe variance matrix of the test.
  • strataoptionally, the number of subjects contained in each stratum.

METHOD

This function implements the G-rho family of Harrington and Fleming (1982), with weights on each death of $S(t)^\rho$, where $S(t)$ is the Kaplan-Meier estimate of survival. With rho = 0 this is the log-rank or Mantel-Haenszel test, and with rho = 1 it is equivalent to the Peto & Peto modification of the Gehan-Wilcoxon test.

If the right hand side of the formula consists only of an offset term, then a one sample test is done. To cause missing values in the predictors to be treated as a separate group, rather than being omitted, use the factor function with its exclude argument.

References

Harrington, D. P. and Fleming, T. R. (1982). A class of rank test procedures for censored survival data. Biometrika 69, 553-566.

Examples

Run this code
## Two-sample test
survdiff(Surv(futime, fustat) ~ rx,data=ovarian)

## Stratified 7-sample test

survdiff(Surv(time, status) ~ pat.karno + strata(inst), data=lung)

## Expected survival for heart transplant patients based on
## US mortality tables
expect <- survexp(futime ~ ratetable(age=(accept.dt - birth.dt),
     sex=1,year=accept.dt,race="white"), jasa, cohort=FALSE,
     ratetable=survexp.usr)
## actual survival is much worse (no surprise)
survdiff(Surv(jasa$futime, jasa$fustat) ~ offset(expect))

Run the code above in your browser using DataLab