View source: R/predict.sl.time.R
predict.sl.time | R Documentation |
Predict the survival of new observations based on an SL by unsing the sl.time
function.
## S3 method for class 'sl.time'
predict(object, ..., newdata, newtimes)
object |
An object returned by the function |
... |
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 |
newtimes |
The times at which to produce predicted values. The default value is |
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 times (columns). |
Yohann Foucher <Yohann.Foucher@univ-poitiers.fr>
Camille Sabathe <camille.sabathe@univ-nantes.fr>
data(dataDIVAT2)
# The training of the super learner from the first 150 individuals of the data base
sl1<-sl.time(method=c("cox.ridge", "aft.ggamma"), metric="ribs",
data=dataDIVAT2[1:150,], times="times", failures="failures", pro.time = 12,
cov.quanti=c("age"), cov.quali=c("hla", "retransplant", "ecd"), cv=3)
# Individual prediction for 2 new subjects
pred <- predict(sl1,
newdata=data.frame(age=c(52,52), hla=c(0,1), retransplant=c(1,1), ecd=c(0,1)))
plot(y=pred$predictions$sl[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$sl[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"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.