Plots an aggTrees object.

# S3 method for aggTrees
plot(x, leaves = get_leaves(x$tree), sequence = FALSE, ...)

Arguments

x

An aggTrees object.

leaves

Number of leaves of the desired tree. This can be used to plot subtrees.

sequence

If TRUE, the whole sequence of optimal groupings is displayed in a short animation.

...

Further arguments from prp.

Value

Plots an aggTrees object.

Details

Nodes are colored using a diverging palette. Nodes with predictions smaller than the ATE (i.e., the root prediction) are colored in blue shades, and nodes with predictions larger than the ATE are colored in red shades. Moreover, predictions that are more distant in absolute value from the ATE get darker shades. This way, we have an immediate understanding of the groups with extreme GATEs.

References

Author

Riccardo Di Francesco

Examples

# \donttest{
## Generate data.
set.seed(1986)

n <- 1000
k <- 3

X <- matrix(rnorm(n * k), ncol = k)
colnames(X) <- paste0("x", seq_len(k))
D <- rbinom(n, size = 1, prob = 0.5)
mu0 <- 0.5 * X[, 1]
mu1 <- 0.5 * X[, 1] + X[, 2]
Y <- mu0 + D * (mu1 - mu0) + rnorm(n)

## Construct sequence of groupings. CATEs estimated internally,
groupings <- build_aggtree(Y, D, X, method = "aipw")

## Plot.
plot(groupings)

plot(groupings, leaves = 3)

plot(groupings, sequence = TRUE)# }