Contains functions for fitting shared frailty models with a semi-parametric baseline hazard with the Expectation-Maximization algorithm. Supported data formats include clustered failures with left truncation and recurrent events in gap-time or Andersen-Gill format. Several frailty distributions, such as the the gamma, positive stable and the Power Variance Family are supported.
This is an R package for fitting semiparametric shared frailty models
with the EM algorithm. You can check the “issues” section to see about
known issues. For the gamma frailty model, the results are identical
with those from the
survival pacakage, although
frailtyEM provides a
more readable output, including confidence intervals for the frailty
variance. Other supported distributions include the PVF, compound
Poisson, inverse Gaussian, positive stable. Univariate and multivariate
data with left truncation are supported, including recurrent events data
in Andersen-Gill formulation.
The stable version may be installed from
and the development version from
The bulk of the documentation of the package can be found in the
vignette. If the package is installed from
GitHub, then the vignette
is installed if the pacakge is installed like this:
devtools::install_github("tbalan/frailtyEM", build_vignettes = TRUE)
The main fitting function is
emfrail(), which in general returns an
emfrail() object. Several plots can be produced from this objects, via
autoplot.emfrail() methods (the latter using
Another useful tool is the Commenges-Andersen score test for
heterogeneity. This test does not require estimating the shared frailty
ca_test() function may be used in conjunction with a
coxph object to calculate this.
emfrail_control()so that the result of the
cox.zphfor the frailty model is also returned. This can be used to for goodness of fit. A guide on that soon to come!
Major update. Now stratified models are supported! Several improvements in the documentation and in the performance section.
Smaller fixes, as compared to the previoius CRAN release:
rev(cumsum(rev(rowsum)))statement and replaced with an Rcpp function
solve, seems that this is way better for symmetric matrices (0.7.16)
summary()that control what is printed (if you want the output of a package to fit on one slide, for example) (0.7.15)
ca_testthat was not reading correctly the input because of the partial matching of arguments in R (0.7.14)
As compared to the previous CRAN release, 0.7.2:
emfrailwould crash when the cluster colum would be a character vector
frailvector is named, the
autoplot.emfrail()gives a nicer plot)
As compared to the previous CRAN release, 0.7.0:
ca_test()now provides an interface to use the Commenges-Andersen test for heterogeneity outside the
emfrail()function. It takes as input a
coxphobject. Therefore, it can work with other baseline hazard estimators and with strata.
As usual, feedback is welcome.
ca_test(): no more model frame needed, works well with strata.
ca_test(), a small bug that was leading to wrong answers sometimes. Now it should give the sam result as the one in
ca_test()now works for
coxphmodels properly as long as they have covariates
coxphobjects. Basically this is also done in
emfrail(), but now you can also use
strataor other things that are not supported by
predict.emfrailmethod suffered some alterations: first of all, it now gives predictions for each
lpor each row of
newdata, and it also gained the argumnet
individual. If true, then the
newdataargument is taken as coming from the same individual. This can be used with time-dependent covariates and adjusting the time at risk.
emfrailobject type has been re-vamped into a more conventional object
emfrail(formula, data, stuff)phrasing of the main fitting function.
.dataarguments are still used.
controlargument and the
summary(), plots using
ggplot2, and numerous bug fixes.
ggplot_emfrail()added! Now the same plots (and more) can be done with the good looking
summary.emfrail()now has a new argument
print_optsthat is used in
print.emfrail_summary(); if the output becomes too big, then some parts of the output may be ommitted
theta. This should be tuned somehow in the future. The problem lies in the M step where
agreg.fitcan't deal with large offset values.
summary.emfrail, first of all
Likelihood based confidence intervals are here!
Removed the maximization by
optimx and doing it with
optimize(), since it's one dimensional.
A hessian estimate is obtained from
Minor bug fixes
Some big changes in how the confidence intervals are constructed in predict.emfrail. Now - they are first constructed with the delta method for the log(cumulative hazard) and then exponentiated, so they do not have to be truncated at 0 or 1 any more.
Further improved compatibility with CRAN policies and added a bunch of stuff in the examples in
\dontrun statements (now they should be less than 5 seconds runtime)
Improved compatibility with R-devel 3.4.0. Registered C++ files to get rid of an R CMD check NOTE. Small modifications in the C++ file - for some reason a segfault started happening out of nowhere, think it's fixed now.
Added vignette, fixed small things for R CMD check R CMD check: PASS, 0 warnings, 1 note / about new developer, that's ok.
Added the Commenges-Andersen test for heterogeneity.
The test is implemented in a pretty non-efficient way, and it can be skipped with a proper
emfrail_control() call, see
?emfrail_control. Also there I added an option to just calculate the test, instead of doing anything else, and then just that is returned. A nice idea would be to implement this as a post-hoc calculation for
coxph objects but that seems like another project atm.
R CMD check: PASS, 0 warnings, 0 notes.
Changed name to the more professional
Added CI and SE for Kendall's tau with gamma
bugfixes: CI for tau with stable is now ok
newdata option for the
predict method and for the
This can be used instead of
lp, and basically calculates the corresponding linear predictor for the
given covariate values.
There is an option now to calculate the unadjusted SE or no SE at all
NEWS.mdfile to track changes to the package.