General Semiparametric Shared Frailty Model

Simulates and fits semiparametric shared frailty models under a wide range of frailty distributions using a consistent and asymptotically-normal estimator. Currently supports: gamma, power variance function, log-normal, and inverse Gaussian frailty models.


frailtySurv is an R package for simulating and fitting semiparametric shared frailty models.

For the latest stable version, install from CRAN:

install.packages("frailtySurv")

The development version can be installed from github using devtools.

devtools::install_github("vmonaco/frailtySurv")

The following code shows how to generate data and fit the model.

set.seed(1234)
library(frailtySurv)
#> Welcome to frailtySurv v1.3.1
dat <- genfrail(N=200, K=2, beta=c(log(2),log(3)), 
                frailty="gamma", theta=2,
                censor.rate=0.35,
                Lambda_0=function(t, tau=4.6, C=0.01) (C*t)^tau)
 
fit <- fitfrail(Surv(time, status) ~ Z1 + Z2 + cluster(family), 
                dat, frailty="gamma")
fit
#> Call: fitfrail(formula = Surv(time, status) ~ Z1 + Z2 + cluster(family), 
#>     dat = dat, frailty = "gamma")
#> 
#>      Covariate     Coefficient
#>             Z1           0.654
#>             Z2           1.006
#> 
#> Frailty distribution   gamma(1.802), VAR of frailty variates = 1.802
#> Log-likelihood         -1575.752
#> Converged (method)     10 iterations, 2.83 secs (maximized log-likelihood)

Parameter traces are given by

plot(fit, "trace")

The estimated cumulative baseline hazard is given by

plot(fit, "hazard")

The results can be compared to other estimation techniques.

library(survival)
library(frailtypack)
coxph(Surv(time, status) ~ Z1 + Z2 + frailty.gamma(family), data=dat)
#> Call:
#> coxph(formula = Surv(time, status) ~ Z1 + Z2 + frailty.gamma(family), 
#>     data = dat)
#> 
#>                           coef se(coef)      se2    Chisq  DF       p
#> Z1                      0.6651   0.0941   0.0852  49.9190   1 1.6e-12
#> Z2                      1.0282   0.1046   0.0941  96.5685   1 < 2e-16
#> frailty.gamma(family)                            475.6283 150 < 2e-16
#> 
#> Iterations: 7 outer, 58 Newton-Raphson
#>      Variance of random effect= 1.88   I-likelihood = -1319.6 
#> Degrees of freedom for terms=   0.8   0.8 149.7 
#> Likelihood ratio test=576  on 151 df, p=0  n= 400
frailtyPenal(Surv(time, status) ~ Z1 + Z2 + cluster(family), data=dat, n.knots=10, kappa=2)
#> 
#> Be patient. The program is computing ... 
#> The program took 0.34 seconds
#> Call:
#> frailtyPenal(formula = Surv(time, status) ~ Z1 + Z2 + cluster(family), 
#>     data = dat, n.knots = 10, kappa = 2)
#> 
#> 
#>   Shared Gamma Frailty model parameter estimates  
#>   using a Penalized Likelihood on the hazard function 
#> 
#>        coef exp(coef) SE coef (H) SE coef (HIH)       z          p
#> Z1 0.672355   1.95884   0.0994872     0.0994872 6.75820 1.3972e-11
#> Z2 1.048828   2.85430   0.1191790     0.1191790 8.80045 0.0000e+00
#> 
#>     Frailty parameter, Theta: 1.92375 (SE (H): 0.319542 ) p = 8.703e-10 
#>  
#>       penalized marginal log-likelihood = -1378.15
#>       Convergence criteria: 
#>       parameters = 6.38e-05 likelihood = 5.61e-07 gradient = 4.67e-10 
#> 
#>       LCV = the approximate likelihood cross-validation criterion
#>             in the semi parametrical case     = 3.48287 
#> 
#>       n= 400
#>       n events= 256  n groups= 200
#>       number of iterations:  13 
#> 
#>       Exact number of knots used:  10 
#>       Value of the smoothing parameter:  2, DoF:  11.96

You can clone the repository and build the project from source using RStudio. To create a project in RStudio from this repository, you must have both RStudio and git installed.

  • In RStudio, go to File -> New Project -> Version Control -> Git
  • Name the project (eg. frailtySurv), choose location, and specify the Repository URL as https://github.com/vmonaco/frailtySurv

More information about RStudio and git

Also see the chapter in the R packages book

To load the package (simulate installing and loading with library(frailty)):

devtools::load_all()

or shortuct: Ctrl+Shift+L

Use this command to build a source package (binary = FALSE by default)

devtools::build()

Other usefull commands and shortcuts:

  • Build and reload everything: Ctrl+Shift+B
  • Check the package, devtools::check(): Ctrl+Shift+E
  • Run all tests, devtools::test(): Ctrl+Shift+T

Build the vignettes with the command:

devtools::build_vignettes()

Compiled vignettes will reside in inst/doc. In particular, see frailtySurv.pdf

Use RStudio to pull the latest code if you've already cloned the repository. In the "git" pane, look for the Pull button. You can also view the commit history from there and see the diff between modified files, if any.

News

Version 1.3.1 (December 2016)

  • Added numeric integration control parameters to genfrail (see genfrail.control)
  • Removed unnecssary imports

Version 1.3 (June 2016)

  • Added init.beta and init.theta control parameters for parameter initialization
  • Added censor.time parameter to genfrail for user-defined censorship times
  • Added option to specify Lambda.times when plotting residuals
  • Made both loglik and score fit methods use the same convergence control parameters
  • Improved loglik parameter estimation and convergence
  • Fixed the labels of residuals boxplot x-axis
  • Fixed clang warning with static casts

Version 1.2.2 (September 2015)

  • Fixed ambiguous C++ calls to pow

Version 1.2.1 (September 2015)

  • Resolved undefined global vars
  • Added Lambda.all to the fitted model object for estimated cumulative baseline hazard at all observed times
  • Minor changes to man pages

Version 1.2.0 (September 2015)

  • Renamed package to frailtySurv
  • Added uniform censorship to genfrail

Version 1.1.1 (September 2015)

  • Fixed bug in summary.fitfrail
  • Fixed censor.param parameter in genfrail

Version 1.1.0 (September 2015)

  • Control parameters for numerical integration (int.iter, int.reltol, int.abstol)
  • Added summary.fitfrail for summarizing the survival curve
  • Added parameter to fitfrail to compute the SE of parameter estimates
  • Renamed Lambda.time to Lambda.times (not backwards compatible)
  • Improved print.fitfrail
  • Remove missing observations
  • Improved print.summary.genfrail
  • Added sanity checks to frailty distribution params
  • Fixed parallel support on Windows (runs in serial with a warning for now)

Version 1.0.0 (August 2015)

Initial release

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("frailtySurv")

1.3.2 by John V. Monaco, 8 months ago


https://github.com/vmonaco/frailtySurv/


Report a bug at https://github.com/vmonaco/frailtySurv/issues


Browse source code at https://github.com/cran/frailtySurv


Authors: John V. Monaco [aut, cre], Malka Gorfine [aut], Li Hsu [aut]


Documentation:   PDF Manual  


Task views: Survival Analysis


LGPL-2 license


Imports stats, nleqslv, reshape2, ggplot2, numDeriv

Depends on survival

Suggests knitr, parallel, gridExtra

Linking to Rcpp


See at CRAN