predict_one_coxfit {shinyCox} | R Documentation |
Computes Cox-model predicted survival function for one new data row using
coxfit
list object created by prep_coxfit()
.
predict_one_coxfit(coxfit, newdata)
coxfit |
This is an object returned by |
newdata |
vector of new data |
data.frame of predicted survival probabilities over time, one column is time, one is probability
This function's primary use is within the shiny app, where a coxph
object
is not available. It can be used outside of that context but that is the
main purpose of this function, and why it only accepts the return object
of prep_coxfit()
. In the context of the shiny app, the new data is taken
from user inputs.
# First, fit model using coxph
library(survival)
bladderph <- coxph(Surv(stop, event) ~ rx + number + size, bladder,
model = TRUE, x = TRUE)
# Use coxph object with function
bladderfit <- prep_coxfit(bladderph)
# Take first row of bladder as 'new data'
newdata <- bladder[1, ]
predictions <- predict_one_coxfit(bladderfit, newdata)