Learn R Programming

LongCART (version 3.2)

text: Place text on SurvCART or LongCART tree

Description

Labels the current plot of the tree generated from SurvCART or LongCART object with text.

Usage

# S3 method for SurvCART
text(x, splits = TRUE, all = FALSE,
             use.n = FALSE, minlength = 1L, ...)
# S3 method for LongCART
text(x, splits = TRUE, all = FALSE,
             use.n = FALSE, minlength = 1L, ...)

Arguments

x

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

splits

similar to text.rpart; logical flag. If TRUE (default), then the splits in the tree are labeled with the criterion for the split.

all

similar to text.rpart; Logical. If TRUE, all nodes are labeled, otherwise just terminal nodes.

use.n

similar to text.rpart; Logical. If TRUE, adds n to label.

minlength

similar to text.rpart; the length to use for factor labels. A value of 1 causes them to be printed as 'a', 'b', ..... Larger values use abbreviations of the label names. See the labels.rpart function for details.

...

arguments to be passed to or from other methods.

References

Kundu, M. G., and Harezlak, J. (2019). Regression trees for longitudinal data with baseline covariates. Biostatistics & Epidemiology, 3(1):1-22.

Kundu, M. G., and Ghosh, S. (2021). Survival trees based on heterogeneity in time-to-event and censoring distributions using parameter instability test. Statistical Analysis and Data Mining: The ASA Data Science Journal, 14(5), 466-483.

See Also

plot, SurvCART, LongCART

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()
out<- SurvCART(data=GBSG2, patid="subjid", censorvar="cens", timevar="time", event.ind=1, 
        gvars=c('horTh1', 'age', 'menostat1', 'tsize', 'tgrade1', 'pnodes', 'progrec', 'estrec'),  
        tgvars=c(0,1,0,1,0,1, 1,1),          
        alpha=0.05, minsplit=80,  
        minbucket=40, print=TRUE)

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

Run the code above in your browser using DataLab