plot_subgroup_ates: Plot ATE differences by one or more subgroups

Description Usage Arguments Details Value Examples

View source: R/diagnose_fit.R

Description

Visualize the heterogeneity heuristic described in estimate_subgroup_ate. If more than one subgroup is given, they are all displayed in the plot.

Usage

1
plot_subgroup_ates(fit, subgroups, level = 0.9)

Arguments

fit

A trained causal forest object from causal_forest

subgroups

A logical vector indicating whether an observation belongs to the subgrouping, or a list/data frame of such vectors.

level

The width of the reported confidence intervals

Details

If subgroups is a data.frame, the columns are assumed to be the subgroups. They should all be logical, otherwise unexpected behavior may occur.

Value

A ggplot2 plot object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
 require(grf)

 n <- 2000; p <- 10

 X <- matrix(rnorm(n * p), n, p)
 W <- rbinom(n, 1, 0.4 + 0.2 * (X[, 1] > 0))
 Y <- pmax(X[, 1], 0) * W + X[, 2] + pmin(X[, 3], 0) + rnorm(n)

 cf <- causal_forest(X, Y, W)
 results <- tidy_cf(cf)

 grps <- data.frame(
   high_cate = results$cate > median(results$cate),
   high_X3 = X[, 3] > median(X[, 3])
 )
 plot_subgroup_ates(cf, grps)

## End(Not run)

ensley-nexant/cfeval documentation built on May 20, 2020, 12:34 a.m.