no.at.risk: Function to compute the number of individuals at risk

Description Usage Arguments Details Value Author(s) See Also Examples

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
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)

Example output

Loading required package: survival
Loading required package: prodlim
        risk.factor  0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6
strat=1     strat=1 29   27  26   25  24   22  21   20  19   18  16   16  14
strat=2     strat=2 32   32  32   30  30   30  28   27  23   19  19   18  18
strat=3     strat=3 39   34  34   32  32   28  28   27  24   22  20   17  15
        0.65 0.7 0.75 0.8 0.85 0.9 0.95  1
strat=1   13  11   11   8    8   8    8  6
strat=2   15  15   14  14   13  13   13 10
strat=3   13  13   12  11   11   9    9  9

survcomp documentation built on Nov. 8, 2020, 4:54 p.m.