# [R] Computing Mean Lifetime from Hazard

Ravi Varadhan RVaradhan at jhmi.edu
Fri Sep 26 21:18:27 CEST 2008

```Hi, there was a typo in the last formula of my previous email.  The correct
formula is:

mean life time = int_{0} ^{\inf} u * f(u) du

Ravi.
----------------------------------------------------------------------------
-------

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan at jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

----------------------------------------------------------------------------
--------

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Ravi Varadhan
Sent: Friday, September 26, 2008 2:55 PM
To: 'Alan Cox'; r-help at r-project.org
Subject: Re: [R] Computing Mean Lifetime from Hazard

Hi,

The fundamental relation b/w hazard (h), survival (S), and density (f)
functions is:

f(t) = h(t) * S(t)

Where S(t) = exp ( - int_{0} ^{t} h(u) du )

mean life time = int_{0} ^{\inf} f(u) du

If you have a piecewise constant h(t), you can either smooth it and compute
the required integrals using the smoothed version, or compute the areas
using tapezoidal or simpson's rule (if data is equally spaced).

Ravi.

----------------------------------------------------------------------------
-------

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan at jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

----------------------------------------------------------------------------
--------

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Alan Cox
Sent: Friday, September 26, 2008 11:31 AM
To: r-help at r-project.org
Subject: [R] Computing Mean Lifetime from Hazard

Hello,
If all I have access to is an empirically calculated hazard function, is it
possible to compute an approximate value for the mean lifetime?

I know that if the hazard function is essentially constant, the mean
lifetime is 1/hazard rate.  But if I'm confident that the empirical hazard
function is not constant, I'm not sure how to go about calculating an
estimate of mean lifetime.

For instance, suppose someone goes about generating a muhaz object by doing
the following:

>  haz <- muhaz(runif(1000,30,40))

and then gives me only the haz object.  I can plot it, and see pretty
quickly that it isn't constant.  The person who generated the muhaz object
would know that the average lifetime is approx. 35.  Is there anyway that I
can learn that from looking only haz?

Does the process for doing this differ based on whether the lifetimes are
generated from a well-known distribution?

Thanks for your help,
Alan

--
Alan Cox
Director, User Experience
iContact, Corp.
p 919.459.1038 f 919.287.2475

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

```

More information about the R-help mailing list