[R] Trend test for hazard ratios

Therneau, Terry M., Ph.D. therneau at mayo.edu
Tue Apr 15 15:32:31 CEST 2014

You can do statistical tests within a single model, for whether portions of it fit or do 
not fit.  But one cannot take three separate fits and compare them.  The program needs 
context to know how the three relate to one another.  Say that "group" is your strata 
variable, trt the variable of interest, and x1, x2 are adjusters.

    fit <- coxph(Surv(time,status) ~ trt * strata(group) + x1 + x2, data=mydata)

Will fit a model with a separate treatment coefficient for each of the groups, and a 
separate baseline hazard for each.  One can now create a contrast that corresponds to your 
trend test, using vcov(fit) for the variance matrix and coef(fit) to retrieve the 

Terry T.

On 04/15/2014 05:00 AM, r-help-request at r-project.org wrote:
> Hello,
> I have the following problem. I stratified my patient cohort into three
> ordered groups and performed multivariate adjusted Cox regression analysis
> on each group separately. Now I would like to calculate a p for trend across
> the hazard ratios that I got for the three groups. How can I do that if I
> only have the HR and the confidence interval? For example I got the
> following HRs for one endpoint:
> 1.09(0.68-1.74),	1.29(0.94-1.76) and 1.64(1.01-2.68).
> There is a trend but how do I calculate if it is significant?
> Best regards
> Marcus Kleber

More information about the R-help mailing list