The output of
LTRCART is an rpart object, and as a result the
usual predict function on such an object returns the predicted
relative risk on the test set.
Pred.rpart returns the predicted
Kaplan-Meier curves and median survival times on the test set,
which in some circumstances might be desirable in practice.
Note that this function can be applied to any rpart survival tree
object, not just one produced by
A formula used to fit the survival tree. The response
is a Surv object. If it has the form Surv(time1, time2, event),
A list of predicted KM curves and median survival times.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
## The Assay of serum free light chain data in survival package ## Adjust data & clean data library(survival) library(LTRCtrees) Data <- flchain Data <- Data[!is.na(Data$creatinine),] Data$End <- Data$age + Data$futime/365 DATA <- Data[Data$End > Data$age,] names(DATA) <- "FLC" ## Setup training set and test set Train = DATA[1:500,] Test = DATA[1000:1020,] ## Predict median survival time and Kaplan Meier survival curve ## on test data using Pred.rpart LTRCART.pred <- Pred.rpart(Surv(age, End, death) ~ sex + FLC + creatinine, Train, Test) LTRCART.pred$KMcurves ## list of predicted KM curves LTRCART.pred$Medians ## vector of predicted median survival time
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.