K <- HF %>%
filter(serum_creatinine <= 1.8, ejection_fraction > 25, age > 79)
pred_k <- ctree(Surv(time, DEATH_EVENT) ~ ., data = K)
https://archive.ics.uci.edu/ml/datasets/Heart+failure+clinical+records
I'm wanting to get the survival rate at t=150. This is my first ever Kaplan Meier model. Just don't know how to extract it.
Using summary(pred_k) doesn't return calculations for some reason.

To apply the
summary()method to the Kaplan-Meier estimates you need to extract thesurvfitobject first. You can do so either by re-fittingsurvfit()to all of the terminal nodes of the tree simultaneously. Or, alternatively, by usingpredict()to obtain the fitted Kaplan-Meier curve for every individual observation.To make the example easily reproducible, let's consider the following illustration from
?ctreeinpartykit:Now we can extract the IDs of the terminal nodes (3, 4, 6, 7) for every observation in the learning data by:
And then we can build the corresponding four-group
survfitobject for the entire learning data and work with it "as usual" insurvival.Alternatively, you can extract the
survfitfor an individual observation as well, here we extract the object for the first observation in the learning data: