Learn R Programming

survMisc (version 0.4.6)

tne: Time, No. at risk, No. events

Description

Time, No. at risk, No. events

Usage

tne(x, ...)

## S3 method for class 'Surv': tne(x, ..., eventsOnly = FALSE)

## S3 method for class 'survfit': tne(x, ..., eventsOnly = FALSE, what = c("table", "list", "all"), nameStrata = TRUE)

## S3 method for class 'coxph': tne(x, ..., eventsOnly = FALSE, what = c("table", "list", "all"), nameStrata = TRUE)

## S3 method for class 'formula': tne(x, ..., eventsOnly = FALSE, what = c("table", "list", "all"), nameStrata = TRUE)

Arguments

x
A object of class Surv, survfit, coxph or formula.
...
Additional arguments (not implemented)
eventsOnly
If eventsOnly=TRUE shows only times at which at least one event occurred. Otherwise shows all times recorded (i.e. including those censored)
what
See Value below
nameStrata
Applies only if what=="list" or what=="all". The default is to name the elements of the list after each stratum. As the names for each stratum are made by concatenating the predictor names, this can become unwieldly

Value

  • For a Surv object: A data.table with columns:
  • ttime
  • nno. at risk
  • eno. events
  • For a survfit, coxph or formula: If what="table" (the default), a data.table with columns as above. In addition:
  • sstratum; predictor names are separated with an underscore '_'
  • nsno. at risk (by strata)
  • Esno. events expected (by strata)
  • e_Esno. events minus no. events expected
  • Additional columns returned match those of the predictors in the model.frame (for survfit objects) or model.matrix (in other cases). If what="list" = then instead a list with one element for each stratum, where each elements is a data.table with columns t, n and e as for a Surv object. If what="all", a data.table with a columns t, n and e as above. There are additional columns for n and e for each stratum.

References

Example using kidney data is from: K&M. Example 7.2, pg 210.

Examples

Run this code
### Surv object
df0 <- data.frame(t=c(1,1,2,3,5,8,13,21),
                  e=rep(c(0,1),4))
s1 <- Surv(df0$t, df0$e, type="right")
tne(s1)
tne(s1, eventsOnly=TRUE)
### survfit object
data(kidney, package="KMsurv")
s1 <- survfit(Surv(time=time, event=delta) ~ type, data=kidney)
tne(s1)
tne(s1, what="all")
tne(s1, what="all", eventsOnly=TRUE)
tne(survfit(Surv(time=time, event=delta) ~ 1, data=kidney))
data(larynx, package="KMsurv")
tne(survfit(Surv(time, delta) ~ factor(stage) + age, data=larynx))
data(bmt, package="KMsurv")
tne(survfit(Surv(t2, d3) ~ z3 +z10, data=bmt), what="all")
tne(survfit(Surv(t2, d3) ~ 1, data=bmt))
### coxph object
data(kidney, package="KMsurv")
c1 <- coxph(Surv(time=time, event=delta) ~ type, data=kidney)
tne(c1)
tne(c1, what="list")
tne(coxph(Surv(t2, d3) ~ z3*z10, data=bmt))
### formula object
data(kidney, package="KMsurv")
### this doesn't work
### s1 <- survfit(Surv(t2, d3) ~ z3*z10, data=bmt)
tne(Surv(time=t2, event=d3) ~ z3*z10, data=bmt, what="all")
tne(Surv(time=t2, event=d3) ~ ., data=bmt)
### example where each list element has only one row
### also names are impractical
tne(Surv(time=t2, event=d3) ~ ., data=bmt, what="list", nameStrata=FALSE)

Run the code above in your browser using DataLab