Learn R Programming

DStree (version 1.0)

plot.DStree: Plot a DStree Object

Description

This function plots a DStree object on the current graphic device. It visualizes the fitted tree as well as the estimated survival/hazard probabilites for every terminal node.

Usage

"plot"(x, prob = "surv", select = NULL, ...)

Arguments

x
a fitted object of class "DStree"
prob
a string that indicates which probability should be plotted. "surv" draws survival probabilities, "haz" draws hazard probabilities.
select
a vector of strings that indicate terminal leaves for which the survival/hazard probabilities should be drawn. If not specified probabilities for every terminal leaf are drawn.
...
extra prp arguments to modify the appearance of the tree (from R package rpart.plot)

Examples

Run this code
data(cost)
# Discretize observed days to years
d.cost<-dis.cost(cost)

# Grow tree
fit <- DStree(time~prevStroke+age+sex+alcohol+smoke,status="status",data=d.cost)

#Plot tree and survival probabilities
plot(fit)
#survival probabilities are in the first plot

#Plot tree and hazard probabilities for terminal leaves 4 and 15
plot(fit,prob="haz",select=c("2","7"))

Run the code above in your browser using DataLab