[R] Nelson-Aalen estimator in R

Thomas Lumley tlumley at u.washington.edu
Wed Oct 6 00:14:59 CEST 2004


On Tue, 5 Oct 2004, Wu, Tongtong wrote:

> Hi,
>
> I am taking a survival class.  Recently I need to do the Nelson-Aalen
> estimtor in R.  I searched through the R help manual and internet, but could
> not find such a R function.  I tried another way by calculating the
> Kaplan-Meier estimator and take -log(S).  However, the function only
> provides the summary of KM estimator but no estimated values.  Could you
> please help me with this?  I would highly appreciate your great help!
>

Taking -log(KM) does not give the Nelson-Aalen estimator, though it does 
give another consistent estimator of the cumulative hazard function.

The easiest way to get the Nelson-Aalen estimator is
   basehaz(coxph(Surv(time,status)~1,data=aml))
because the (Breslow) hazard estimator for a Cox model reduces to the 
Nelson-Aalen estimator when there are no covariates.

You can also compute it from information returned by survfit().

> fit <- survfit(Surv(time, status) ~ 1, data = aml)
> str(fit)
List of 12
  $ n        : int 23
  $ time     : num [1:18] 5 8 9 12 13 16 18 23 27 28 ...
  $ n.risk   : num [1:18] 23 21 19 18 17 15 14 13 11 10 ...
  $ n.event  : num [1:18] 2 2 1 1 1 0 1 2 1 0 ...
  $ surv     : num [1:18] 0.913 0.826 0.783 0.739 0.696 ...
  $ type     : chr "right"
  $ std.err  : num [1:18] 0.0643 0.0957 0.1099 0.1239 0.1379 ...
  $ upper    : num [1:18] 1.000 0.996 0.971 0.942 0.912 ...
  $ lower    : num [1:18] 0.805 0.685 0.631 0.580 0.531 ...
  $ conf.type: chr "log"
  $ conf.int : num 0.95
  $ call     : language survfit(formula = Surv(time, status) ~ 1, data = aml)
  - attr(*, "class")= chr "survfit"

so cumsum(fit$n.event/fit$n.risk) is the Nelson-Aalen estimator for the 
times given by fit$times.

If you want -log(S), then -log(fit$surv) will give it to you.


 	-thomas




More information about the R-help mailing list