[R] Frailty and coxph

Thomas Lumley tlumley at u.washington.edu
Tue Oct 8 18:36:30 CEST 2002


On Tue, 8 Oct 2002, [iso-8859-1] Göran Broström wrote:

>
> Does someone know the rules by which 'coxph' returns 'frail', the
> predicted frailty terms? In my test function:
>
> -----------------------------------------------
> fr <- function(){
>   #testing(frailty terms in 'survival'
>   require(survival)
>   dat <- data.frame(exit = 1:6,
>                     event = rep(1, 6),
>                     x = rep(c(0, 1), 3),
>                     id = rep(1:2, rep(3, 2))
>                     )
>    fit1 <- coxph(Surv(exit, event) ~ x +
>                 frailty(id, dist = "gaussian"), data = dat)
>   return(fit$frail)
> }
> -----------------------------------------------
>
> the result is 'NULL', but with 'real data', I usually get the predicted
> frailties. The help pages doesn't even mention the component 'frail', but
> in the code I can see that 'frail' is reurned if  'nfrail > 0'. And
> (from 'coxpenal.fit.s'):


The frailties are always returned. However, they aren't always returned
in the same place.  They are returned in $frail if they are computed by
the sparse algorithm described in help(frailty), and in $coef if the full
Newton-Raphson algorithm is used.

By default, then, frailties on more than 5 individuals will be in $frail,
fewer than five in $coef. In your example we have
> coef(fit1)
         x    gauss:1    gauss:2
-0.1143062  1.4837374 -1.4837374

which are the missing frailties.

You can use frailty(id, dist="gaussian", sparse=TRUE) to force the
frailties to be returned in $frail or sparse=FALSE to force them to be in
$coef.

	-thomas


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list