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'): --------------------------- if (any(sparse)) { ... }else{ nfrail <- 0 ... } --------------------------- and --------------------------- sparse <- sapply(pattr, function(x) !is.null(x$sparse) && x$sparse) --------------------------- but here I lose track (lost patience:() of what is happening. I would like to have the predicted frailty terms _always_ when I have a frailty term in the model. What can I do? Or can someone explain in simple words what the rules are that decide whether I get the predicted vaues or not? G?ran -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Tue, 8 Oct 2002, G?ran Brostr?m wrote:> > Does someone know the rules by which 'coxph' returns 'frail', the > predicted frailty terms? In my test function:[...] Expanding my example function: ------------------------------------------------------------- fr <- function(lup){ #testing(frailty terms in 'survival' require(survival) lupp <- 2 * lup dat <- data.frame(exit = 1:lupp, event = rep(1, lupp), x = rep(c(0, 1), lup), family = sample(rep(1:lup, 2)) ) fit1 <- coxph(Surv(exit, event) ~ x + frailty(family, dist = "gaussian"), data = dat) return(fit1$frail) -------------------------------------------------------------> fr(5)NULL> fr(6)[1] 0.04036113 0.17815670 0.02927139 -0.12160991 0.13439779 -0.26057710 'lup' larger than 5 (only) returns predicted frailty terms. G?ran -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._