kapmeier: Implements product-limit (Kaplan-Meier) method

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

Description

Implements product-limit (Kaplan-Meier) method for time-to-event data with censoring.

Usage

1
kapmeier(time, status)

Arguments

time

numeric vector with individual observation times

status

integer vector indicating status at the end of the observation time: 1 = event, 0 = censored

Details

This function implements the product-limit method for estimating survival probability for time-to-event data with censoring:

1
2
    S(t) = product[(nj - dj) / nj] for all tj <= t,
  

where tj are event times (i.e., times at which one or more events occur), nj are the number at risk at time tj (by convention, subjects censored at time tj are considered at-risk and included in nj), and dj are the number of events at time tj.

A primary purpose of this function was to demonstrate the use of available R functions to implement a simple statistical method. For example, kapmeier uses sort, order, duplicated, tapply, unique, cumprod, cbind, and dimnames. Studying this function carefully helps one understand and appreciate the utility of R functions to implement simple methods.

For serious survival analysis load the survival package. The survfit function in this package implements the product-limit method and much more. See examples.

Value

Returns an individual-level data frame

Author(s)

Tomas Aragon, aragon@berkeley.edu, http://www.phdata.science

References

Selvin S. Statistical Analysis of Epidemiologic Data (Monographs in Epidemiology and Biostatistics, V. 35). Oxford University Press; 3rd edition (May 1, 2004)

See Also

See also survfit

Examples

1
2
3
4
##Product-limit method using 'kapmeier' function
tt <- c(1,17,20,9,24,16,2,13,10,3)
ss <- c(1,1,1,1,0,0,0,1,0,1)
round(kapmeier(tt, ss), 3)

Example output

     time n.risk n.events condsurv survival  risk
[1,]    1     10        1    0.900    0.900 0.100
[2,]    3      8        1    0.875    0.788 0.213
[3,]    9      7        1    0.857    0.675 0.325
[4,]   13      5        1    0.800    0.540 0.460
[5,]   17      3        1    0.667    0.360 0.640
[6,]   20      2        1    0.500    0.180 0.820

epitools documentation built on March 26, 2020, 9:14 p.m.

Related to kapmeier in epitools...