3

Because this is such a long question I've broken it down into 2 parts; the first being just the basic question and the second providing details of what I've attempted so far.

Question - Short

How do you fit an individual frailty survival model in R? In particular I am trying to re-create the coefficient estimates and SE's in the table below that were found from fitting the a semi-parametric frailty model to this dataset link. The model takes the form:

h_i(t) = z_i h_0(t) exp(\beta'X_i)

where z_i is the unknown frailty parameter per each patient, X_i is a vector of explanatory variables, \beta is the corresponding vector of coefficients and h_0(t) is the baseline hazard function using the explanatory variables disease, gender, bmi & age ( I have included code below to clean up the factor reference levels). enter image description here

Question - Long

I am attempting to follow and re-create the Modelling Survival Data in Medical Research text book example for fitting frailty mdoels. In particular I am focusing on the semi parametric model for which the textbook provides parameter and variance estimates for the normal cox model, lognormal frailty and Gamma frailty which are shown in the above table

I am able to recreate the no frailty model estimates using

library(dplyr)
library(survival)
dat <- read.table(
    "./Survival of patients registered for a lung transplant.dat",
    header = T
) %>% 
    as_data_frame %>% 
    mutate( disease = factor(disease, levels = c(3,1,2,4))) %>% 
    mutate( gender = factor(gender, levels = c(2,1)))

mod_cox <- coxph( Surv(time, status) ~ age + gender + bmi + disease   ,data = dat)
mod_cox

however I am really struggling to find a package that can reliably re-create the results of the second 2 columns. Searching online I found this table which attempts to summarise the available packages:

enter image description here source

Below I have posted my current findings as well as the code I've used encase it helps someone identify if I have simply specified the functions incorrectly:

frailtyEM - Seems to work the best for gamma however doesn't offer log-normal models

frailtyEM::emfrail(
    Surv(time, status) ~ age + gender + bmi + disease + cluster(patient), 
    data = dat ,
    distribution = frailtyEM::emfrail_dist(dist = "gamma")
)

survival - Gives warnings on the gamma and from everything I've read it seems that its frailty functionality is classed as depreciated with the recommendation to use coxme instead.

coxph( 
    Surv(time, status) ~ age + gender + bmi + disease + frailty.gamma(patient), 
    data = dat 
)
coxph( 
    Surv(time, status) ~ age + gender + bmi + disease + frailty.gaussian(patient), 
    data = dat 
)

coxme - Seems to work but provides different estimates to those in the table and doesn't support gamma distribution

coxme::coxme(
    Surv(time, status) ~ age + gender + bmi + disease + (1|patient),
    data = dat
)

frailtySurv - I couldn't get to work properly and seemed to always fit the variance parameter with a flat value of 1 and provide coefficient estimates as if a no frailty model had been fitted. Additionally the documentation doesn't state what strings are support for the frailty argument so I couldn't work out how to get it to fit a log-normal

frailtySurv::fitfrail(
    Surv(time, status) ~ age + gender + bmi + disease + cluster(patient),
    dat = dat,
    frailty = "gamma"
)

frailtyHL - Produce warning messages saying "did not converge" however it still produced coeficiant estimates however they were different to that of the text books

mod_n <- frailtyHL::frailtyHL(
    Surv(time, status) ~ age + gender + bmi + disease + (1|patient),
    data = dat,
    RandDist = "Normal"
)
mod_g <- frailtyHL::frailtyHL(
    Surv(time, status) ~ age + gender + bmi + disease + (1|patient),
    data = dat,
    RandDist = "Gamma"
)

frailtypack - I simply don't understand the implementation (or at least its very different from what is taught in the text book). The function requires the specification of knots and a smoother which seem to greatly impact the resulting estimates.

parfm - Only fits parametric models; having said that everytime I tried to use it to fit a weibull proportional hazards model it just errored.

phmm - Have not yet tried

I fully appreciate given the large number of packages that I've gotten through unsuccessfully that it is highly likely that the problem is myself not properly understanding the implementation and miss using the packages. Any help or examples on how to successfully re-create the above estimates though would be greatly appreciated.

gowerc
  • 1,039
  • 9
  • 18
  • If your question is only about how to use R, which package, what code, etc., then it is off topic here. This is a big question, it may not get much response on [SO]. You might do best on r-help. Let me know if you want me to migrate this to SO. – gung - Reinstate Monica Mar 09 '18 at 18:13
  • Hi @gung , Indeed I think it is unlikely I will get a reply on SO which is why I posted here as I assumed that the more statistically oriented users here will have a much higher chance of knowing the answer or being able to help. If you are still adamant that this is off topic then yes please can you transfer it to SO; if I do not get any replies there I will try and reach out to r-help as you have suggested. – gowerc Mar 09 '18 at 18:21
  • Do you have the *Survival of patients registered for a lung transplant* data available? Look into survival's `?survreg` where you supply a *distribution*. – Parfait Mar 09 '18 at 20:10
  • Hi @Parfait, I have updated the question to try and clear it up and also attached a direct link to the download the dataset. Thank you for the suggestion; `survreg` though is focused on fitting parametric models, the equivalent in the survival package for semi-parametric models is `coxph` but the frailty component seems to be classed as depreciated in favour of the `coxme` package which I wasn't able to get to work properly – gowerc Mar 10 '18 at 10:41

1 Answers1

1

Regarding

I am really struggling to find a package that can reliably re-create the results of the second 2 columns.

See the Survival Analysis CRAN task view under Random Effect Models or do a search on R Site Search on e.g., "survival frailty".

  • Thank you for the suggestion; from this resource it appears `frailtypack` is the highest scoring package for survival frailty modelling. I had attempted to use this package but struggling to understand it or get it to work properly as the implementation seems very different to what the text book did. In particular you seem to have to specify a number of knot points and smoother values which seem to greatly impact the results (which I'm not sure how to use to re-create the above numbers). – gowerc Mar 10 '18 at 10:43
  • There is [this paper](https://www.jstatsoft.org/article/view/v047i04) and [this paper](https://www.jstatsoft.org/article/view/v081i03) from the Journal of Statistical Software which may help you. – Benjamin Christoffersen Mar 10 '18 at 10:49
  • Thank you; will take a look and see if I can use these to solve my problem – gowerc Mar 10 '18 at 10:51
  • The first paper is likeli the most relevant to you. Though, as far as I recall the packaged is about _correlated survival data_ whereas your problem only involves an individual frailty if I understand your problem correctly? I am not sure whether you can fit such a model with any of the functions in `frailtypack`. – Benjamin Christoffersen Mar 10 '18 at 10:57
  • E.g., the _nested frailty model_ is what you want but without the shared $v_i$ effect on page 3. – Benjamin Christoffersen Mar 10 '18 at 11:03