plot.aggTrees {aggTrees} | R Documentation |
Plot Method for aggTrees Objects
Description
Plots an aggTrees
object.
Usage
## S3 method for class 'aggTrees'
plot(x, leaves = get_leaves(x$tree), sequence = FALSE, ...)
Arguments
x |
An |
leaves |
Number of leaves of the desired tree. This can be used to plot subtrees. |
sequence |
If |
... |
Further arguments from |
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.
Value
Plots an aggTrees
object.
Author(s)
Riccardo Di Francesco
References
R Di Francesco (2022). Aggregation Trees. CEIS Research Paper, 546. doi:10.2139/ssrn.4304256.
See Also
build_aggtree
, inference_aggtree
Examples
## 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)