Learn R Programming

flexsurv (version 0.1.5)

flexsurvreg: Flexible parametric regression for time-to-event data

Description

Parametric regression for time-to-event data using the generalized F and other flexible distributions. Users may easily extend this function with their own survival distributions.

Usage

flexsurvreg(formula, data, dist, inits, fixedpars=NULL, cl=0.95,...)

Arguments

formula
A formula expression in conventional R linear modelling syntax. The response must be a survival object as returned by the Surv function, and any covariates are given on the right-hand side. For ex
data
A data frame in which to find variables supplied in formula. If not given, the variables should be in the working environment.
dist
Either one of the following strings identifying a built-in distribution: ll{ "gengamma" Generalized gamma (stable parameterisation) "gengamma.orig" Generalized gamma (original parameterisation
inits
A numeric vector giving initial values for each unknown parameter. If not specified, default initial values are chosen from a simple summary of the uncensored survival time, for example the mean is often used to initialize scale parameters.
fixedpars
Vector of indices of parameters whose values will be fixed at their initial values during the optimisation. The indices are ordered with parameters of the baseline distribution coming first, followed by covariate effects. For example, in a s
cl
Width of symmetric confidence intervals for maximum likelihood estimates, by default 0.95.
...
Optional arguments to the general-purpose Roptimisation routine optim. Useful options include method="BFGS" for using a quasi-Newton optimisation algorithm, which can often be faster than

Value

  • A list of class "flexsurvreg" with the following elements.
  • callA copy of the function call, for use in post-processing.
  • dlistList defining the survival distribution used.
  • resMatrix of maximum likelihood estimates and confidence limits.
  • loglikLog-likelihood
  • AICAkaike's information criterion (-2*log likelihood + 2*number of estimated parameters)

encoding

latin1

Details

Parameters are estimated by maximum likelihood using the algorithms available in the standard R optim function. Parameters defined to be positive are estimated on the log scale. Confidence intervals are estimated from the Hessian at the maximum, and transformed back to the original scale of the parameters.

flexsurvreg is intended to be as similar as possible to survreg in the survival package.

References

Jackson, C. H. and Sharples, L. D. and Thompson, S. G. (2010) Survival models in health economic evaluations: balancing fit and parsimony to improve prediction. International Journal of Biostatistics 6(1):Article 34.

Cox, C. (2008) The generalized $F$ distribution: An umbrella for parametric survival analysis. Statistics in Medicine 27:4301-4312.

Cox, C., Chu, H., Schneider, M. F. and Mu�oz, A. (2007) Parametric survival analysis and taxonomy of hazard functions for the generalized gamma distribution. Statistics in Medicine 26:4252-4374

See Also

flexsurvspline for flexible survival modelling using the spline model of Royston and Parmar.

plot.flexsurvreg and lines.flexsurvreg to plot fitted survival, hazards and cumulative hazards from models fitted by flexsurvreg and flexsurvspline.

Examples

Run this code
data(ovarian)
## Compare generalized gamma fit with Weibull
fitg <- flexsurvreg(formula = Surv(futime, fustat) ~ 1, data = ovarian, dist="gengamma")
fitg
fitw <- flexsurvreg(formula = Surv(futime, fustat) ~ 1, data = ovarian, dist="weibull")
fitw
plot(fitg)
lines(fitw, col="blue")
## Identical AIC, probably not enough data in this simple example for a
## very flexible model to be worthwhile. 

## Custom distribution 
library(eha)  ## make "dllogis" and "pllogis" available to the working environment 
custom.llogis <- list(name="llogis",
                      pars=c("shape","scale"),
                      location="scale",
                      transforms=c(log, log),
                      inv.transforms=c(exp, exp),
                      inits=function(t){ c(1, median(t)) })
fitl <- flexsurvreg(formula = Surv(futime, fustat) ~ 1, data = ovarian, dist=custom.llogis)
fitl
lines(fitl, col="purple")

Run the code above in your browser using DataLab