Re: [R] How to estimate a hazard ratio using an external hazard function

From: Terry Therneau <>
Date: Thu, 10 Apr 2008 08:09:34 -0500 (CDT)

----included message ----

I would like to compare the hazard functions of two samples using the Cox proportional hazards model. For sample 1 I have individual time-to- event data. For sample 2 I don't have individual data, but grouped data that allows to obtain a hazard function.

I am wondering if there is an R function that allows to obtain a hazard ratio of the two hazard funtions (under the proportionality assumption) taking into account the censoring of the data?

I am aware of survexp and survdiff functions, but I am not sure if that is the best way to do what I need.

Any help will be highly appreciated.

  The functions for population expected survival are designed for just this problem, i.e., those that use the US death rate tables. Under the assumption that the second (grouped data set) has a much larger sample size than the first (sample) data:

    For each subject in sample 1, compute the expected number of events for that subject, using the rates found in sample 2 = (time at risk) * (rate during that time). For population rate tables this turns out to be a sum: the external rates are a function of age so one gets ......+ (# days at age 55)*(rate for 55 year olds) + (# days at age 56)*(rate for 56 year olds) + .... Call the result "expected", a vector with one element per subject.

    Now fit a Poisson model with offset(log(expected)) as one of the predictors. This is a proportional hazards model, with the usual Cox baseline hazard lambda_0 replaced by the known hazard function from sample 2.

        Terry Therneau mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Thu 10 Apr 2008 - 13:32:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 11 Apr 2008 - 22:30:28 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive