plot_predictions_vs_covariate: Plot estimated CATEs versus a covariate

Description Usage Arguments Value Examples

View source: R/viz_output.R

Description

Plot estimated CATEs versus a covariate

Usage

1
plot_predictions_vs_covariate(dat, res, covariate, level = NULL)

Arguments

dat

The original training data

res

The output from tidy_cf

covariate

The covariate to plot on the horizontal axis

level

The desired confidence level. If NULL, no confidence levels are plotted.

Value

A ggplot2 plot object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## 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)
 dat <- dplyr::bind_cols(as.data.frame(X), results)
 dat$a <- sample(letters[1:3], size = n, replace = T)

 plot_predictions_vs_covariate(dat, 'V1', level = 0.9)
 plot_predictions_vs_covariate(dat, 'a', level = 0.9)

## End(Not run)

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