plot.stabletree: Visualizing Tree Stability Assessments

View source: R/stabletree.R

plot.stabletreeR Documentation

Visualizing Tree Stability Assessments

Description

Visualizations of tree stability assessments carried out via stabletree.

Usage

## S3 method for class 'stabletree'
plot(x, select = order(colMeans(x$vs), decreasing = TRUE), 
  type.breaks = "levels", col.breaks = "red", lty.breaks = "dashed",
  cex.breaks = 0.7,  col.main = c("black", "gray50"), main.uline = TRUE,
  args.numeric = NULL, args.factor = NULL, args.ordered = NULL, main = NULL,
  original = TRUE, ...)

## S3 method for class 'stabletree'
barplot(height, main = "Variable selection frequencies",
  xlab = "", ylab = "", horiz = FALSE, col = gray.colors(2),
  names.arg = NULL, names.uline = TRUE, names.diag = TRUE,
  cex.names = 0.9, 
  ylim = if (horiz) NULL else c(0, 100), xlim = if (horiz) c(0, 100) else NULL,
  original = TRUE, ...)

## S3 method for class 'stabletree'
image(x, main = "Variable selections",
  ylab = "Repetitions", xlab = "", col = gray.colors(2),
  names.arg = NULL, names.uline = TRUE, names.diag = TRUE, 
  cex.names = 0.9, xaxs = "i", yaxs = "i",
  col.tree = 2, lty.tree = 2, xlim = c(0, length(x$vs0)), ylim = c(0, x$B),
  original = TRUE, ...)

Arguments

x, height

an object of class stabletree.

original

logical. Should the original tree information be highlighted?

select

An vector of integer or character values representing the number(s) or the name(s) of the variable(s) to be plotted. By default all variables are plotted. The numbers correspond to the ordering of all partitioning variables used in the call of the fitted model object that was passed to stabletree.

type.breaks

A character specifying the type of information added to the lines that represent the splits in the complete data tree. type.breaks = "levels" adds the level of the splits. type.breaks = "nodeids" adds the nodeid of the splits. type.breaks = "breaks" adds the cutpoint of the splits. type.breaks = "none" suppresses any labeling.

col.breaks

Coloring of the lines and the texts that represent the splits in the complete data tree.

lty.breaks

Type of the lines that represent the splits in the complete data tree.

cex.breaks

Size of the texts that represent the splits in the complete data tree.

col.main

A vector of colors of length two. The first color is used for titles of variables that are selected in the complete data tree. The second color is used for titles of variables that are not selected in the complete data tree.

main.uline

A logical value. If TRUE, variables selected in the complete data tree are underlined. If FALSE, underlining is suppressed.

args.numeric

A list of arguments passed to the internal function that is used for plotting a histogram of the cutpoints in numerical splits. breaks is passed to hist (see hist for details). Further arguments in the list are passed to plot.histogram such as col, border etc.

args.factor

A list of arguments passed to the internal function that is used for plotting an image plot of the cutpoints in categorical splits. col (a vector of two colors) is used to illustrate categorical splits. Please note that the default colors are optimized for color vision deficiency. col.na defines the color used to highlight missing categories. Further arguments in the list are passed to the function plot.default.

args.ordered

A list of arguments passed to the internal function that is used for plotting a barplot of the cutpoints in ordered categorical splits. All arguments in the list are passed to the function barplot.default, such as col, border etc.

...

further arguments passed to plotting functions, especially for labeling and annotation.

main, xlab, ylab

character. Annotations of axes and main title, respectively.

horiz

A logical value. If FALSE, the bars are drawn vertically with the first bar to the left. If TRUE, bars are drawn horizontally with the first at the bottom.

col

A vector of colors of length two used for coloring in the barplot and image methods. The first color represents selected and the second color represents not selected partitioning variables.

names.arg

A vector of labels to be plotted below each bar (in case of barplot) or each column (in case of image). If the argument is omitted, then the variable names are taken as labels.

names.uline

A logical value. If TRUE, the labels representing variables that are used for splitting in the complete data tree, are underlined. If FALSE, labels are not underlined.

names.diag

A logical value (omitted if horiz = TRUE). If TRUE, the labels are drawn diagonally. If FALSE, labels are drawn horizontally.

cex.names

Expansion factor for labels.

xlim, ylim

The limits of the plot.

xaxs, yaxs

The style of axis interval calculation to be used (see par for details).

col.tree, lty.tree

color and line type to indicate differences from the original tree that was resampled.

Details

  • plot visualizes the variability of the cutpoints.

  • barplot visualizes the variable selection frequency.

  • image visualizes the combinations of variables selected.

See Also

stabletree

Examples




## build a tree
library("partykit")
m <- ctree(Species ~ ., data = iris)
plot(m)

## investigate stability
set.seed(0)
s <- stabletree(m, B = 500)

## show variable selection proportions
## with different labels and different ordering
barplot(s)
barplot(s, cex.names = 0.8)
barplot(s, names.diag = FALSE)
barplot(s, names.arg = c("a", "b", "c", "d"))
barplot(s, names.uline = FALSE)
barplot(s, col = c("lightgreen", "darkred"))
barplot(s, horiz = TRUE)

## illustrate variable selections of replications
## with different labels and different ordering
image(s)
image(s, cex.names = 0.8)
image(s, names.diag = FALSE)
image(s, names.arg = c("a", "b", "c", "d"))
image(s, names.uline = FALSE)
image(s, col = c("lightgreen", "darkred"))

## graphical cutpoint analysis, selecting variable by number and name
## with different numerical of break points
plot(s)
plot(s, select = 3)
plot(s, select = "Petal.Width")
plot(s, args.numeric = list(breaks = 40))

# change labels of splits in complete data tree
plot(s, select = 3, type.breaks = "levels")
plot(s, select = 3, type.breaks = "nodeids")
plot(s, select = 3, type.breaks = "breaks")
plot(s, select = 3, type.breaks = "none")




stablelearner documentation built on April 14, 2023, 12:40 a.m.