Description Usage Arguments Value Examples
After accounting for propensity, covariate distributions should be balanced between treated and control observations. These functions plot overlaid histograms, one for treated and one for control, of each covariate, using inverse propensity weights.
1 2 3 | plot_covariate_balance_numeric(dat, results, covars = NULL, ...)
plot_covariate_balance_categorical(dat, results, covars = NULL)
|
dat |
A data frame of covariates |
results |
The output from |
covars |
A character vector of covariates to include in the plot. If
omitted, all columns of |
... |
Additional arguments passed to
|
A ggplot2 plot object, or list of plot objects if plot =
FALSE
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## Not run:
require(grf)
n <- 2000; p <- 10
X <- matrix(rnorm(n * p), n, p)
dat <- as.data.frame(X)
dat$a <- sample(letters[1:3], size = n, replace = T)
dat$b <- sample(letters[10:17], size = n, replace = T)
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)
# fit the model and extract results
cf <- causal_forest(X, Y, W)
results <- tidy_cf(cf)
plot_covariate_balance_numeric(dat, results, bins = 20)
plot_covariate_balance_categorical(dat, results, plot = T)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.