avg_characteristics_rpart {aggTrees} | R Documentation |

Computes the average characteristics of units in each leaf of an `rpart`

object.

```
avg_characteristics_rpart(tree, X)
```

`tree` |
An |

`X` |
Covariate matrix (no intercept). |

`avg_characteristics_rpart`

regresses each covariate on a set of dummies denoting leaf membership.
This way, we get the average characteristics of units in each leaf, together with a standard error.

Leaves are ordered in increasing order of their predictions (from most negative to most positive).

Standard errors are estimated via the Eicker-Huber-White estimator.

A list storing each regression as an `lm_robust`

object.

Riccardo Di Francesco

R Di Francesco (2022). Aggregation Trees. CEIS Research Paper, 546. doi:10.2139/ssrn.4304256.

`causal_ols_rpart`

, `estimate_rpart`

```
## 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 a tree.
library(rpart)
tree <- rpart(y ~ ., data = data.frame("y" = y, X), maxdepth = 2)
## Compute average characteristics in each leaf.
results <- avg_characteristics_rpart(tree, X)
results
```

[Package *aggTrees* version 2.0.2 Index]