Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

plot.grf_tree

Plot a GRF tree object.


Description

The direction NAs are sent are indicated with the arrow fill. An empty arrow indicates that NAs are sent that way. If trained without missing values, both arrows are filled.

Usage

## S3 method for class 'grf_tree'
plot(x, include.na.path = NULL, ...)

Arguments

x

The tree to plot

include.na.path

A boolean toggling whether to include the path of missing values or not. It defaults to whether the forest was trained with NAs.

...

Additional arguments (currently ignored).

Examples

## Not run: 
# Plot a tree in the forest (requires the `DiagrammeR` package).
n <- 500
p <- 10
X <- matrix(rnorm(n * p), n, p)
W <- rbinom(n, 1, 0.5)
Y <- pmax(X[, 1], 0) * W + X[, 2] + pmin(X[, 3], 0) + rnorm(n)
c.forest <- causal_forest(X, Y, W)
plot(tree <- get_tree(c.forest, 1))
# Saving a plot in .svg can be done with the `DiagrammeRsvg` package.
install.packages("DiagrammeRsvg")
tree.plot = plot(tree)
cat(DiagrammeRsvg::export_svg(tree.plot), file = 'plot.svg')

## End(Not run)

grf

Generalized Random Forests

v1.2.0
GPL-3
Authors
Julie Tibshirani [aut, cre], Susan Athey [aut], Rina Friedberg [ctb], Vitor Hadad [ctb], David Hirshberg [ctb], Luke Miner [ctb], Erik Sverdrup [ctb], Stefan Wager [aut], Marvin Wright [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.