no.at.risk {survcomp} | R Documentation

## 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.

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

    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)

[Package survcomp version 1.37.1 Index]