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 LTRCART
Usage
Pred.rpart(formula, train, test)
Arguments
formula
A formula used to fit the survival tree. The response
is a Surv object. If it has the form Surv(time1, time2, event),
then LTRCART is called internally; if response has the form Surv(time, event),
then the rpart is called internally.
train
Training set
test
Test set
Value
A list of predicted KM curves and median survival times.
Examples
## 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)[6] <- "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
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(LTRCtrees)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/LTRCtrees/Pred.rpart.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Pred.rpart
> ### Title: Prediction function for rpart.object
> ### Aliases: Pred.rpart
>
> ### ** Examples
>
> ## 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)[6] <- "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
[[1]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
248.0 144.0 0.0 189.0 90.5 88.4 91.4
[[2]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
248.0 144.0 0.0 189.0 90.5 88.4 91.4
[[3]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
248.0 144.0 0.0 189.0 90.5 88.4 91.4
[[4]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
248.0 144.0 0.0 189.0 90.5 88.4 91.4
[[5]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
248.0 144.0 0.0 189.0 90.5 88.4 91.4
[[6]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
144.0 56.0 0.0 131.0 83.8 81.0 86.7
[[7]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
248.0 144.0 0.0 189.0 90.5 88.4 91.4
[[8]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
248.0 144.0 0.0 189.0 90.5 88.4 91.4
[[9]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
248.0 144.0 0.0 189.0 90.5 88.4 91.4
[[10]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
248.0 144.0 0.0 189.0 90.5 88.4 91.4
[[11]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
248.0 144.0 0.0 189.0 90.5 88.4 91.4
[[12]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
248.0 144.0 0.0 189.0 90.5 88.4 91.4
[[13]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
144.0 56.0 0.0 131.0 83.8 81.0 86.7
[[14]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
248.0 144.0 0.0 189.0 90.5 88.4 91.4
[[15]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
86.0 47.0 0.0 75.0 87.0 84.2 89.3
[[16]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
248.0 144.0 0.0 189.0 90.5 88.4 91.4
[[17]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
248.0 144.0 0.0 189.0 90.5 88.4 91.4
[[18]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
248.0 144.0 0.0 189.0 90.5 88.4 91.4
[[19]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
248.0 144.0 0.0 189.0 90.5 88.4 91.4
[[20]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
144.0 56.0 0.0 131.0 83.8 81.0 86.7
[[21]]
Call: survfit(formula = Formula, data = subset)
records n.max n.start events median 0.95LCL 0.95UCL
144.0 56.0 0.0 131.0 83.8 81.0 86.7
> LTRCART.pred$Medians ## vector of predicted median survival time
[1] 90.5 90.5 90.5 90.5 90.5 83.8 90.5 90.5 90.5 90.5 90.5 90.5 83.8 90.5 87.0
[16] 90.5 90.5 90.5 90.5 83.8 83.8
>
>
>
>
>
>
> dev.off()
null device
1
>