# [R] coxph and frailty

gc4@duke.edu gc4 at duke.edu
Mon Aug 4 22:55:48 CEST 2003

```Hi:

I have a few clarification questions about the elements returned by
the coxph function used in conjuction with a frailty term.

I create the following group variable:

group <- NULL
group[id<50] <- 1
group[id>=50 & id<100] <- 2
group[id>=100 & id<150] <- 3
group[id>=150 & id<200] <- 4
group[id>=200 & id<250] <- 5
group[id>=250 & id<300] <- 6
group[id>=300] <- 7

I estimate the following model, using the Pbc data (with time-varying
covariates) from Therneau and Grambsch's book:

fitf <- coxph(Surv(start,stop,event==2) ~ age + log(bili) + log(protime) +
log(albumin) + edema + frailty(group),
na.action=na.exclude, data=Pbcseq)

Then I obtain:

> fitf[10]
\$frail
[1]  0.06273372  0.16192093  0.10050877  0.37716999 -0.20853156 -0.71887977
[7] -0.10922275

And:

> fitf[11]
\$fvar
[1] 0.03631634 0.03261972 0.03750465 0.04459689 0.05113802 0.08107876 0.11482236

My understanding is that fitf\$frail are the group level frailty terms. But
what is fitf\$fvar?

Moreover, if I estimate the same model as the one above, but with a
`group' variable with only 4 groups (instead of 7 as in the example
above), the coxph object does not contain those two elements.

Instead, it reports a \$coef object that includes the frailty terms:

> fitf2\$coef
age    log(bili) log(protime) log(albumin)        edema      gamma:1
0.05413962   1.11244236   2.64338176  -3.89824452   0.71347526   0.15547991
gamma:2      gamma:3      gamma:4
0.25794637  -0.47470789  -0.08834457

And a \$means objects with 9 elements:

> fitf2\$means
[1] 49.25963095  0.60313783  2.39101856  1.20878208  0.18226221  0.39845758
[7]  0.33727506  0.23804627  0.02622108

What do the means fitf2\$means[6:9] correspond to?

I am asking these questions because I would like to clarify how the
frailty terms enter into the computation of the baseline cumulative hazard
via the basehaz(fitf, centered=FALSE) function. It would seem that the way
the basehaz function operates is different dependening upon how many
frailty groups there are.

Thank you very much for your help.
giacomo

```