Learn R Programming

survcomp (version 1.22.0)

no.at.risk: 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

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.

Value

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

Details

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

See Also

survfit, km.coxph.plot

Examples

Run this code
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)

Run the code above in your browser using DataLab