plot.flexsurvreg: Plots of fitted flexible survival models

Description Usage Arguments Note Author(s) See Also


Plot fitted survival, cumulative hazard or hazard from a parametric model against nonparametric estimates to diagnose goodness-of-fit.


## S3 method for class 'flexsurvreg'
plot(x, X=NULL, type="survival", t=NULL, start=NULL,
        est=TRUE, ci=NULL, B=1000, cl=0.95,
        col.obs="black", lty.obs=1, lwd.obs=1,
        col="red", lty=1, lwd=2,,,,



Output from flexsurvreg or flexsurvspline, representing a fitted survival model object.


Matrix of covariate values to produce fitted survival curves for. Columns represent different covariates, and rows represent multiple curves. For example matrix(c(1,2),nrow=2) if there is only one covariate in the model, and we want to plot curves for covariate values of 1 and 2.

For “factor” (categorical) covariates, the values of the contrasts representing factor levels (as returned by the contrasts function) should be used. For example, for a covariate agegroup specified as an unordered factor with levels 20-29, 30-39, 40-49, 50-59, and baseline level 20-29, there are three contrasts. To plot curves for groups 20-29 and 40-49, supply X = rbind(c(0,0,0), c(0,1,0)), since all contrasts are zero for the baseline level, and the second contrast is “turned on” for the third level 40-49.

If there are only factor covariates in the model, then Kaplan-Meier curves are plotted for all distinct groups, and by default, fitted curves are also plotted for these groups. To plot Kaplan-Meier and fitted curves for only a subset of groups, use plot(survfit()) followed by lines.flexsurvreg().

If there are any continuous covariates, then a single population Kaplan-Meier curve is drawn. By default, a single fitted curve is drawn with the covariates set to their mean values in the data - for categorical covariates, the means of the 0/1 indicator variables are taken.


"survival" for survival, to be plotted against Kaplan-Meier estimates from plot.survfit.

"cumhaz" for cumulative hazard, plotted against transformed Kaplan-Meier estimates from plot.survfit.

"hazard" for hazard, to be plotted against smooth nonparametric estimates from muhaz. The nonparametric estimates tend to be unstable, and these plots are intended just to roughly indicate the shape of the hazards through time. The min.time and max.time options to muhaz may sometimes need to be passed as arguments to plot.flexsurvreg to avoid an error here.


Vector of times to plot fitted values for, see summary.flexsurvreg.


Left-truncation points, see summary.flexsurvreg.


Plot fitted curves (TRUE or FALSE.)


Plot confidence intervals for fitted curves. By default, this is TRUE if one observed/fitted curve is plotted, and FALSE if multiple curves are plotted.


Number of simulations controlling accuracy of confidence intervals, as used in summary. Decrease for greater speed at the expense of accuracy, or set B=0 to turn off calculation of CIs.


Width of confidence intervals, by default 0.95 for 95% intervals.


Colour of the nonparametric curve.


Line type of the nonparametric curve.


Line width of the nonparametric curve.


Colour of the fitted parametric curve(s).


Line type of the fitted parametric curve(s).


Line width of the fitted parametric curve(s).

Colour of the fitted confidence limits, defaulting to the same as for the fitted curve.

Line type of the fitted confidence limits.

Line width of the fitted confidence limits.


If TRUE, add lines to an existing plot, otherwise new axes are drawn.


Other options to be passed to plot.survfit or muhaz, for example, to control the smoothness of the nonparametric hazard estimates. The min.time and max.time options to muhaz may sometimes need to be changed from the defaults.


Some standard plot arguments such as "xlim","xlab" may not work. This function was designed as a quick check of model fit. Users wanting publication-quality graphs are advised to set up an empty plot with the desired axes first (e.g. with plot(...,type="n",...)), then use suitable lines functions to add lines.


C. H. Jackson

See Also


Search within the flexsurv package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.