predict_one_coxfit {shinyCox} | R Documentation |
Compute Cox-model predicted survival function
Description
Computes Cox-model predicted survival function for one new data row using
coxfit
list object created by prep_coxfit()
.
Usage
predict_one_coxfit(coxfit, newdata)
Arguments
coxfit |
This is an object returned by |
newdata |
vector of new data |
Value
data.frame of predicted survival probabilities over time, one column is time, one is probability
Note
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.
Examples
# 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)
[Package shinyCox version 1.1.0 Index]