Pred.rpart {LTRCtrees}R Documentation

Prediction function for rpart.object

Description

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


[Package LTRCtrees version 1.1.1 Index]