Predictions from flexible survival models
Predict outcomes from flexible survival models at the covariate values specified in newdata
.
## S3 method for class 'flexsurvreg' predict( object, newdata, type = "response", times, conf.int = FALSE, conf.level = 0.95, se.fit = FALSE, p = c(0.1, 0.9), ... )
object |
Output from |
newdata |
Data frame containing covariate values at which to produce fitted values. There must be a column for every covariate in the model formula used to fit If |
type |
Character vector for the type of predictions desired.
|
times |
Vector of time horizons at which to compute fitted values. Only applies when If not specified, predictions for For |
conf.int |
Logical. Should confidence intervals be returned? Default is |
conf.level |
Width of symmetric confidence intervals, relative to 1. |
se.fit |
Logical. Should standard errors of fitted values be returned? Default is |
p |
Vector of quantiles at which to return fitted values when |
... |
Not currently used. |
For the list-column of data frames - the dimensions of each data frame will be identical. Rows are added for each value of times
or p
requested.
fitg <- flexsurvreg(formula = Surv(futime, fustat) ~ age, data = ovarian, dist = "gengamma") ## Simplest prediction: mean or median, for covariates defined by original dataset predict(fitg) predict(fitg, type = "quantile", p = 0.5) ## Simple prediction for user-defined covariate values predict(fitg, newdata = data.frame(age = c(40, 50, 60))) predict(fitg, type = "quantile", p = 0.5, newdata = data.frame(age = c(40,50,60))) ## Predict multiple quantiles and unnest require(tidyr) pr <- predict(fitg, type = "survival", times = c(600, 800)) tidyr::unnest(pr, .pred)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.