This function implements the product-limit method for estimating
survival probability for time-to-event data with censoring:
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.