Flexible Parametric Survival and Multi-State Models

Flexible parametric models for time-to-event data, including the Royston-Parmar spline model, generalized gamma and generalized F distributions. Any user-defined parametric distribution can be fitted, given at least an R function defining the probability density or hazard. There are also tools for fitting and predicting from fully parametric multi-state models.


News

-- text --

Version 1.1 (2017-??-??)

  • Substantial speed improvements in fitting most of the built-in models, from implementing their PDFs and CDFs in C++. Thanks to Paul Metcalfe for contributing this. Results may therefore differ from previous versions in edge cases.

  • As a result the package now depends on Rcpp.

  • Mean, median and restricted mean included as built-in functions in summary.flexsurvreg. Thanks to Jordan Amdahl for the contribution.

  • Documentation migrated to roxygen. Thanks to Paul Metcalfe for the contribution.

  • Various minor bug fixes, see github commits.

Version 1.0.2 (2016-09-26)

  • Bug fix: "start" was being ignored by plot.flexsurvreg. Thanks to Ruth Keogh.

  • Built-in distribution names are now case-insensitive. Thanks to Jordan Amdahl.

  • Fix for Weibull hazard function to avoid numeric instability. Thanks to Jordan Amdahl.

  • Fix to hsurvspline when t includes 0. Thanks to Jordan Amdahl.

  • Vectorised parameters supported in qgeneric.

Version 1.0.1 (2016-05-31)

  • Bug fix: covariates were labelled wrongly in summary.flexsurvreg tidy output. Thanks to Owain Saunders.

Version 1.0.0 (2016-05-10)

  • Version number bumped to 1.0.0 to accompany the publication of the vignette in Journal of Statistical Software.

Version 0.7.1 (2016-03-24)

  • Slightly more efficient likelihood calculations, and removed spurious warning from likelihood with interval censoring.

  • Tests modified to work with the latest (and current) testthat.

Version 0.7 (2015-11-13)

  • flexsurvspline now allows the log cumulative hazard (or its alternatives) to be modelled as a spline function of time instead of log time.

  • The routine for generating initial values in flexsurvspline has been improved. This now obeys the constraint that the log cumulative hazard is increasing, thus avoiding errors from optim() when this wasn't satisfied. Cox regression is used as a fallback to initialise covariate effects if this fails.

  • As a result, flexsurv now depends on the "quadprog" package.

  • dweibullPH and related functions give the Weibull distribution in proportional hazards parameterisation, and "weibullPH" is supported as a built-in model for flexsurvreg.

  • Option to summary.flexsurvreg to return a tidy data frame.

  • New "logliki" component in model objects, containing vector of log-likelihoods for each observation at the estimated or fixed parameters.

  • Fix of various bugs with supplying "newdata" to summary functions (github issue #7). The behaviour here should now be like predict.lm, e.g. variables in newdata that were originally factors should be supplied as factor or character, not numeric.

  • Fix of bug that prevented plots being drawn by categorical covariates by default.

  • Fix of bugs with spline models and no data censored, or all data interval censored (github issue #3).

  • Fix of bugs with subsetting in flexsurvspline (github issue #6).

Version 0.6 (2015-04-13)

  • CRAN release. Also includes the changes from Version 0.5.1.

  • Full support for multi-state models fitted as a list of independent transition-specific models.

  • New function pars.fmsm to return transition-specific parameters in multi-state models.

  • Bug fix for empirical hazard plots with categorical covariates. Thanks to Milan Bouchet-Valat.

Version 0.5.1 (2015-02-24)

  • github-only release.

  • Log-logistic distribution built in to flexsurvreg, and distribution functions provided.

  • Bug fix in tcovs option in semi-Markov model simulation.

  • "digits" argument supported by default model print function. This is passed to "format" to format the parameter estimates, and defaults to 3.

  • Bug fix in "events" printed output for interval censored data. Thanks to Sabrina Russo.

  • pgompertz returns Inf for q=Inf, even for parameters denoting "living forever", since the CDF is P(X <= q) not P(X < q). This affected some fits of the Gompertz distribution.

Version 0.5 (2014-09-22)

Spline models and ancillary covariates:

  • Major rewrite of flexsurvspline. This now works by calling flexsurvreg with a custom distribution written dynamically. Models can now include covariate effects that vary as spline functions of time, by including covariates on "gamma1" or on any further parameters.

  • New argument "anc" to flexsurvreg, as an alternative and preferred way of modelling covariates on ancillary parameters.

  • New general utility "unroll.function" which converts a function with matrix arguments to the equivalent function with vector arguments. The new flexsurvspline works by unrolling "dsurvspline".

  • Quantile, random number, hazard and cumulative hazard functions for spline distribution.

  • Autogeneration of initial values for flexsurvspline now accounts for left-truncation. Thanks to Ana Borges for the report.

Other new modelling features:

  • Several utilities for parametric multi-state modelling, including transition probabilities and simulation ("pmatrix.fs", "totlos.fs", "sim.fmsm","pmatrix.simfs", "totlos.simfs"). An "msfit.flexsurvreg" method also gives cumulative transition-specific hazards in the format of the "mstate" package.

  • Interval censoring supported in the Surv() response.

  • Relative survival models, using the "bhazard" argument to flexsurvreg to specify the expected mortality rate.

  • flexsurvreg now uses survreg internally to fit Weibull, exponential and log-normal models, unless there is left-truncation.

Custom distributions:

  • Custom distributions can be defined through the hazard function. This can be optionally supplemented with the cumulative hazard function, otherwise this is obtained by numerical integration.

  • In custom distributions specified by the density, the cumulative distribution can now be omitted, and it will be calculated by numerical integration.

  • New arguments "dfns" and "aux" to flexsurvreg, which can be used to supply custom distribution functions and arguments to pass to them.

  • Document that density functions for custom distributions need "log" argument.

  • Documented how to supply derivatives of custom distributions for use in optimisation.

Output functions:

  • New "newdata" argument to summary.flexsurvreg and plot.flexsurvreg for an easier way of supplying covariate values.

  • User-defined summary functions can be used in summary.flexsurvreg and plot.flexsurvreg as an alternative to survival, hazard or cumulative hazard.

  • New function "normboot.flexsurvreg" to simulate parameters from the asymptotic normal distribution of their estimates. Used for representing uncertainty in any function of the parameters.

  • summary.flexsurvreg can be called with ci=FALSE to omit confidence intervals.

  • "start" argument defaults to 0 for all prediction times in summary.flexsurvreg.

  • Bug fix in summary.flexsurvreg for left-truncated models, which was returning probabilities > 1 before the truncation time.

  • New model.frame and model.matrix methods to extract the data from fitted flexsurvreg objects.

  • Accept vector X in summary.flexsurvreg, and give informative error if X in wrong format. Thanks to Mark Danese.

  • Extra arguments can be passed to both muhaz and plot.muhaz in plot.flexsurvreg(...,type="hazard",...)

Printed output:

  • Use format() not signif() for printing flexsurvreg objects, to avoid spurious zero significant figures. Thanks to Kenneth Chen.

  • Standard errors included in printed output of flexsurvreg, but only for parameters optimised on natural or log scales (which includes all built-in distributions).

Distribution functions:

  • Bug fix in rgengamma for Q=0 (log-normal) and sigma not equal to 1.

  • Don't warn for shape parameters being exactly zero in generalized gamma and F, just give NaN.

  • basis() and fss() functions for the natural cubic spline basis made available to users.

Version 0.3.1 (2014-02-14)

  • R-forge only release.

  • Distribution functions tidied up, making special value handling and vectorisation consistent. Hazard and cumulative hazard functions for all supported distributions.

  • Vectors of different col, lwd and lty can be passed to plot.flexsurvreg for multiple fitted lines. Thanks to Julia Sandberg for the report.

Version 0.3 (2014-01-19)

  • CRAN release. Includes changes from 0.2.1 to 0.2.3.

Version 0.2.3 (2013-10-09)

  • R-forge only release.

  • Parameters other than the location parameter can now have covariates on them in flexsurvreg. Thanks to Milan Bouchet-Valat for help with this.

  • subset and na.action arguments in flexsurvreg and flexsurvspline.

  • coef, vcov and confint methods for all fitted model objects.

  • Distribution functions for generalized gamma, generalized F, and Gompertz, now allow all parameters to be vectorised.

  • Bug fix in analytic derivatives for Weibull.

  • Restored print output introduced in 0.1.2 which had been accidentally removed in 0.1.5.

Version 0.2.2 (2013-07-26)

  • R-forge only release.

  • Case weights supported in flexsurvreg and flexsurvspline.

Version 0.2.1 (2013-07-03)

  • R-forge only release.

  • Default left truncation times were being set wrongly for user-supplied times in summary.flexsurvreg, giving wrong confidence intervals. These now default to 0.

  • Confidence intervals set to 1 for t=0 under spline models. Thanks to Paul Pynsent.

  • dgompertz,dgengamma,dgengamma.orig,dgenf,dgenf.orig fixed to return -Inf instead of 0 when density is zero and log=TRUE. Thanks to Gao Zheng.

Version 0.2 (2013-05-13)

  • New summary() method for fitted flexsurvreg and flexsurvspline model objects gives fitted survival, cumulative hazard or hazard curves, with confidence intervals mosly computed by a simulation method.

  • This allows plot.flexsurvreg to plot confidence intervals for the fitted survival, hazard or cumulative hazard.

  • Left-truncated survival observations are supported in flexsurvreg and flexsurvspline.

  • New psurvspline and dsurvspline functions giving distribution and density function for the spline model.

  • Analytic derivatives used in optimisation for spline (odds and hazard scale, not normal), exponential, Weibull and Gompertz models.

  • Default to BFGS optimisation method, which uses derivatives where available and should be much faster, instead of Nelder-Mead.

  • Work around NaN warnings from spline models presumably due to parameters violating implicit constraints.

  • If "knots" specified, boundary knots set to min/max of uncensored times, not all times, to match results when "k" is specified. Thanks to Paul Pynsent.

Version 0.1.5 (2012-08-29)

  • Data are now stored in fitted flexsurvreg and flexsurvspline model objects, avoiding environment search errors and allowing package functions to be called within other functions. Thanks to Hanna Daniel for the report.

  • Gompertz documentation clarified for the case when there is a chance of living forever. qgompertz and rgompertz now return Inf in these cases, with no warning, instead of NaN. Thanks to Michael Sweeting.

Version 0.1.4 (2012-03-22)

  • maxt argument in plot.flexsurvreg.

  • Plots no longer complain if data named "dat".

  • Corrected wrong bug fix from Version 0.1.3 for transforming parameter estimates in output when fixedpars=TRUE.

  • AIC penalty corrected for models with some fixed parameters.

  • qgengamma corrected for parameter Q<0. Thanks to Benn Ackley.

Version 0.1.3 (2012-01-17)

  • No longer complains about invalid initial values when there are zero survival times.

  • Don't transform parameter estimates in output when fixedpars=TRUE.

  • Checking functions for distribution utilities don't complain about vectorised parameter values.

Version 0.1.2 (2011-11-08)

  • Initial CRAN release.

  • More features in print output for flexsurvreg and flexsurvspline models.

Version 0.1.1 (2011-04-19)

  • Fix of drop=FALSE bug in flexsurvspline.inits which caused flexsurvspline to fail with single covariates.

Version 0.1 (2011-03-14)

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("flexsurv")

1.1.1 by Christopher Jackson, 4 months ago


https://github.com/chjackson/flexsurv-dev


Report a bug at https://github.com/chjackson/flexsurv-dev/issues


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


Authors: Christopher Jackson [aut, cre] , Paul Metcalfe [ctb] , Jordan Amdahl [ctb]


Documentation:   PDF Manual  


Task views: Probability Distributions, Survival Analysis


GPL (>= 2) license


Imports mstate, muhaz, mvtnorm, deSolve, quadprog, Rcpp, tidyr, tibble

Depends on survival

Suggests eha, numDeriv, testthat, msm, knitr, TH.data, colorspace

Linking to Rcpp


Imported by CopulaCenR, Countr, SurvGSD, educineq, hesim, parmsurvfit, rocTree, surv2sampleComp.

Depended on by flexsurvcure, survHE.

Suggested by fic, fitteR, heemod, mlt.docreg, msm, multistateutils, rprev, simsurv, survminer.


See at CRAN