R package for implementing hierarchically regularized entropy balancing proposed by Xu and Yang (2022). It is suitable for estimating average treatment effect on the treated with binary treatments under strong ignorability. hbal is an extension of entropy balancing: it automatically expands the feature space by including higher-order terms (such as squared and cubic terms and interactions) of covariates and then achieves approximate balance on the expanded features using ridge penalties with a hierarchical structure.
Examples: R code used in the tutorial can be downloaded from here.
Reference: Eddie Yang & Yiqing Xu (2021). Hierarchically Regularized Entropy Balancing. Political Analysis, published online.
Installation
You can install the hbal package from CRAN:
install.packages("hbal")
You can also install the up-to-date development version from Github:
install.packages("devtools") # if not already installed
devtools::install_github("xuyiqing/hbal")
hbal depends on the following packages, which will be installed automatically when hbal is being installed; you can also install them manually:
install_all <- function(packages) {
installed_pkgs <- installed.packages()[, "Package"]
for (pkg in packages) {
if (!pkg %in% installed_pkgs) {
install.packages(pkg)
}
}
}
packages <- c("estimatr", "glmnet", "ggplot2", "gridExtra", "gtable",
"nloptr", "Rcpp", "RcppEigen", "stringr", "generics")
install_all(packages)
Notes on installation failures
- Intel-Mac users who have updated to MacOS BigSur or higher will likely encounter compilation problems. See here for a potential solution.
- Windows users please consider upgrading R to 4.3.0 or higher and installing the latest Rtools to avoid C++17 complier errors when installing fastplm.
- For Rcpp, RcppArmadillo and MacOS “-lgfortran” and “-lquadmath” error, click here for details.
- Installation failure related to OpenMP on MacOS, click here for a solution.
- To fix these issues, try installing gfortran from here.