gsynth implements the generalized synthetic control method, which imputes counterfactuals for each treated unit using control group information based on a linear interactive fixed effects model. This version supports unbalanced panels and implements the matrix completion method.
Authors: Yiqing Xu (Stanford), Licheng Liu (MIT)
Date: Feb 22, 2022
Repos: Github (1.2.1) CRAN (1.2.1)
Example: R code used in the tutorial can be downloaded from here.
You can install gsynth directly from CRAN by typing the following command in the R console:
install.packages('gsynth', type = 'source')
You can also install the development version of the package from Github by typing:
install.packages('devtools', repos = 'http://cran.us.r-project.org') # if not already installed
devtools::install_github('xuyiqing/gsynth')
gsynth depends on the following packages, which will be installed automatically when gsynth is being installed; you can also install them manually:
## for processing C++ code
require(Rcpp)
## for plotting
require(ggplot2)
require(GGally)
## for parallel computing
require(foreach)
require(future)
require(doParallel)
require(abind)
require(lfe)
- Quick solution: download a binary build (v.1.2.1), which does not require compilation, and install it from file in RStudio.
- Windows users please consider upgrading R to 4.0.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 6.1 from here.
- Mac users who have updated to MacOS Big Sur will likely encounter compilation problems. See here for a potential solution.
Please report bugs to yiqingxu [at] stanford.edu with your sample code, data file, and a treatment status plot generated by panelview. Much appreciated!