knitr::opts_chunk$set(prompt = TRUE, comment = "", collapse = TRUE)

In this vignette, we demonstrate how to use the rocTree function in rocTree package to fit the proposed Receiver Operating Characteristic (ROC) guided survival tree.

Simulated data

We will demonstrate the usage of rocTree function with a simulated data prepared by the simu function. ```{R load, message = FALSE} library(rocTree) set.seed(0) dat <- simu(n = 100, cen = 0.25, sce = 2.3, summary = TRUE) head(dat)

## The `rocTree` function 

The complete list of arguments in `rocTree` are as follow:
```{R rocTree-arg}
args(rocTree)

The arguments are as follows

The control options

The argument control defaults to a list with the following values:

Growing a survival tree

We first load the survival package to enable the Surv() function, which we will use to specify the survival response. The fully grown (un-pruned) time-invariant survival tree can be constructed as follow: ```{R tree} library(survival) system.time(fit <- rocTree(Surv(Time, death) ~ z1 + z2, id = id, data = dat, ensemble = FALSE, control = list(numFold = 0)))

The function `rocTree` returns an object of S3 class with the following major components:

* `Frame` is a data frame describe the resulting tree. The columns are 
  * `p` indicate which covariate was split at the node. 
  * `left` indicate the row number for the left child (if the current node splittable).
  * `right` indicate the row number for the right child (if the current node splittable).
  * `cutVal` indicate the covariate value (after transformation) being split at the node.
  * `cutOrd` indicate the rank of the covariate value being split at the node.
  * `nd` indicates the node number in display.
  * `is.terminal` describe the node characteristic; `0` if a node is internal, `1` if a node is a terminal node.

The time-invariant survival tree can be printed directly or with the generic function `print`.
```r
fit

The survival tree is printed in the structure similar to that in the data.tree package.

Plotting the survival tree

The survival tree can also be plotted with the GraphViz/DiagrammeR engine via the generic function plot.

plot(fit)

The plot feature also allows the following arguments adopted from the Graphviz/DiagrammeR environment to be passed to option:

The following codes illustrate some of the different options.

plot(fit, rankdir = "LR", shape = "rect", digits = 2)
plot(fit, shape = "egg", nodeOnly = TRUE)
plot(fit, output = "visNetwork", digits = 2)

Pruning the survival tree

Pruning reduces the complexity of the final classifier, and hence improves predictive accuracy by the reduction of overfitting. Setting prune = TRUE in the control list will prune the survival tree. In the following example, we used five-fold cross-validation to choose the tuning parameter in the concordance-complexity measure: ```{R tree2, tidy = TRUE} system.time(fit2 <- rocTree(Surv(Time, death) ~ z1 + z2, id = id, data = dat, ensemble = FALSE, control = list(numFold = 10))) fit2 plot(fit2)

The resulting tree is much smaller than the un-pruned tree in `fit`. 

## Survival/Hazard estimates at terminal notes

The time-invariant partition considered allows a sparse model and an easy interpretation
of the decision rule. At each fixed time $t$, the tree partitions the survivor population and predicts the instantaneous failure risk.
Thus the interpretation at a fixed time point is along the same line as classification and regression trees. 
Since the risk within each terminal node changes with time, it is essential to look at the hazard curves of each terminal
The smoothed hazard estimates at terminal nodes can be easily plotted with the generic function `plot` with `type = "survival"` or `type = "hazard"`.
The feature is demonstrated below.
```{R haz, fig.align = "center"}
plot(fit2, type = "hazard")

Prediction

Suppose we have a new data that is generated as below: ```{R newDat} newdat <- dplyr::tibble(Time = sort(unique(dat$Time)), z1 = 1 * (Time < median(Time)), z2 = 0.5) newdat

The predicted survival curve can be plotted with the following codes.
```{R pred}
(pred <- predict(fit2, newdat, type = "survival"))
plot(pred)
(pred <- predict(fit2, newdat, type = "hazard"))
plot(pred)


stc04003/rocTree documentation built on Sept. 25, 2020, 11:51 a.m.