Function to compute the number of individuals at risk

Description

Function to compute the number of individuals at risk at certain time points, as used in the Kaplan-Meier estimator for instance, depending on stratification.

Usage

1
no.at.risk(formula.s, data.s, sub.s = "all", t.step, t.end)

Arguments

formula.s

formula composed of a Surv object and a strata variable (i.e. stratification).

data.s

data frame composed of the variables used in the formula.

sub.s

vector of booleans specifying if only a subset of the data should be considered.

t.step

time step at which the number of individuals at risk is computed.

t.end

maximum time to be considered.

Details

The original version of this function was kindly provided by Dr Christos Hatzis (January, 17th 2006).

Value

number of individuals at risk at each time step specified in t.step up to t.end.

Author(s)

Christos Hatzis, Benjamin Haibe-Kains

See Also

survfit, km.coxph.plot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
require(survival)
set.seed(12345)
stime <- rexp(100)
cens   <- runif(100,.5,2)
sevent  <- as.numeric(stime <= cens)
stime <- pmin(stime, cens)
strat <- sample(1:3, 100, replace=TRUE)
dd <- data.frame("surv.time"=stime, "surv.event"=sevent, "strat"=strat)
no.at.risk(formula.s=Surv(surv.time,surv.event) ~ strat, data.s=dd,
  sub.s="all", t.step=0.05, t.end=1)

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.