predict.flexsurv: Prediction from an Flexible Parametric Model

View source: R/predict.flexsurv.R

predict.flexsurvR Documentation

Prediction from an Flexible Parametric Model

Description

Predict the survival of new observations based on an flexible parametric model from an object of the class flexsurv.

Usage

## S3 method for class 'flexsurv'
predict(object, ..., newdata, newtimes)

Arguments

object

An object returned by the function aft.ggamma, aft.gamma, aft.weibull, ph.exp, or ph.gompertz.

...

Further arguments passed.

newdata

An optional data frame containing covariate values at which to produce predicted values. There must be a column for every covariate included in cov.quanti and cov.quali included in the training sample. The default value isNULL, the predicted values are computed for the subjects of the training sample.

newtimes

The times at which to produce predicted values. The default value isNULL, the predicted values are computed for the observed times in the training data frame.

Details

The model object is obtained from the flexsurvreg package.

Value

times

A vector of numeric values with the times of the predictions.

predictions

A matrix with the predictions of survivals of each subject (lines) for each observed times (columns).

Author(s)

Yohann Foucher <Yohann.Foucher@univ-poitiers.fr>

Camille Sabathe <camille.sabathe@univ-nantes.fr>

Examples


data(dataDIVAT2)

# The estimation of the model from the first 200 lignes
model<-ph.gompertz(times="times", failures="failures", data=dataDIVAT2[1:200,],
  cov.quanti=c("age"),  cov.quali=c("hla", "retransplant", "ecd"))

# Predicted survival for 2 new subjects
pred <- predict(model,
  newdata=data.frame(age=c(52,52), hla=c(0,1), retransplant=c(1,1), ecd=c(0,1)))

plot(y=pred$predictions[1,], x=pred$times, xlab="Time (years)", ylab="Predicted survival",
     col=1, type="l", lty=1, lwd=2, ylim=c(0,1))

lines(y=pred$predictions[2,], x=pred$times, col=2, type="l", lty=1, lwd=2)

legend("bottomright", col=c(1,2), lty=1, lwd=2, c("Subject #1", "Subject #2"))

RISCA documentation built on March 31, 2023, 11:06 p.m.