predict.libsl {survivalSL} | R Documentation |
Prediction from an Flexible Parametric Model
Description
Predict the survival based on a model or algorithm from an object of the class libsl
.
Usage
## S3 method for class 'libsl'
predict(object, newdata, newtimes, ...)
Arguments
object |
An object of the class |
newdata |
An optional data frame containing covariate values at which to produce predicted values. The default value is |
newtimes |
The times at which to produce predicted values. The default value is |
... |
For future methods. |
Value
times |
A vector of numeric values with the times of the |
predictions |
A matrix with the predictions of survivals of each subject (lines) for each observed time (columns). |
Examples
data("dataDIVAT2")
# The estimation of the model from the first 200 lines
formula<-Surv(times,failures) ~ age + hla + retransplant + ecd
model <- LIB_PHgompertz(formula, data=dataDIVAT2[1:200,])
# 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"))
[Package survivalSL version 0.98 Index]