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, based on either cause-specific hazards or mixture models.
-- text --
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.
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.
Slightly more efficient likelihood calculations, and removed spurious warning from likelihood with interval censoring.
Tests modified to work with the latest (and current) testthat.
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).
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.
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.
Major new release, so version number bumped from 0.3 to 0.5.
New package vignettes: a user guide and a vignette of examples.
Development moved from r-forge to https://github.com/chjackson/flexsurv-dev.
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 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.
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",...)
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).
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.
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.
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.
R-forge only release.
Case weights supported in flexsurvreg and flexsurvspline.
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.
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.
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.
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.
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.
Initial CRAN release.
More features in print output for flexsurvreg and flexsurvspline models.