Learn R Programming

LongCART (version 3.1)

KMPlot.SurvCART: KM plot for SurvCART object

Description

Generates KM plot for sub-groups (i.e., terminal nodes) associated with survival tree generated by SurvCART()

Usage

KMPlot.SurvCART(x, scale.time = 1, type = 1, ...)

Arguments

x

a fitted object of class "SurvCART", containing a survival tree.

scale.time

Divides the time variable by the factor of scale.time. For example, if times are collected in days, then to plot time in years, specify 365.25.

type

1 for KM plot of survival probabilities, 2 for KM plot of censoring probabilities

...

arguments to be passed to or from other methods.

References

Kundu, M. G.(2020). Survival trees based on score based parameter instability test.

See Also

text.SurvCART, plot.SurvCART, SurvCART, StabCat.surv, StabCont.surv

Examples

Run this code
# NOT RUN {
#--- Get the data
data(GBSG2)

#numeric coding of character variables
GBSG2$horTh1<- as.numeric(GBSG2$horTh)
GBSG2$tgrade1<- as.numeric(GBSG2$tgrade)
GBSG2$menostat1<- as.numeric(GBSG2$menostat)

#Add subject id
GBSG2$subjid<- 1:nrow(GBSG2)

#--- Run SurvCART() with time-to-event distribution: exponential, censoring distribution: None  
out<- SurvCART(data=GBSG2, patid="subjid", censorvar="cens", timevar="time", 
        gvars=c('horTh1', 'age', 'menostat1', 'tsize', 'tgrade1', 'pnodes', 'progrec', 'estrec'),  
        tgvars=c(0,1,0,1,0,1, 1,1),          
        event.ind=1,  alpha=0.05, minsplit=80, minbucket=40, print=TRUE)

#--- Plot tree
par(xpd = TRUE)
plot(out, compress = TRUE)
text(out, use.n = TRUE)

#Plot KM plot of survival probabilities for sub-groups identified by tree
KMPlot.SurvCART(out, scale.time=365.25, type=1)

#Plot KM plot of censoring probabilities for sub-groups identified by tree
KMPlot.SurvCART(out, scale.time=365.25, type=1)
# }

Run the code above in your browser using DataLab