Skip to content

Latest commit

 

History

History
111 lines (87 loc) · 4.12 KB

README.md

File metadata and controls

111 lines (87 loc) · 4.12 KB

fect

Lifecycle: experimental License: MIT downloads: CRAN downloads: CRAN

R package for implementing counterfactual estimators, also known as imputation estimators, in panel fixed-effect settings. Suitable for causal panel analysis with binary treatments under (hypothetically) baseline randomization. It allows a treatment to switch on and off and limited carryover effects. It supports two-way fixed effects, linear factor models, and the matrix completion method.

Starting from v.2.0.0, all gsynth functionalities have been merged into fect.

Github Repo: GitHub (2.0.0)

User Manual: R code used in the User Manual can be downloaded from here.

Main References:

Xu, Yiqing (2017). Generalized Synthetic Control Method: Causal Inference with Interactive Fixed Effects Models. Political Analysis 25 (1): 57–76.

Licheng Liu, Ye Wang, Yiqing Xu (2024). A Practical Guide to Counterfactual Estimators for Causal Inference with Time-Series Cross-Sectional Data. American Journal of Political Science, 68 (1): 160–76.

Installation

To install fect from CRAN, run the code chunk below:

install.packages("fect")

We recommend users to install the most up-to-date version of fect from Github using:

devtools::install_github("xuyiqing/fect")

After installation, check fect version to make sure the package is up-to-date.

installed.packages()["fect", "Version"]
#> [1] "2.0.0"

fect depends on the following packages, which should be installed automatically when fect 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("abind", "doParallel", "doRNG", "fixest", "foreach", "future", 
              "GGally", "ggplot2", "grid", "gridExtra", "Mass", 
              "panelView", "Rcpp")
install_all(packages)

Notes on installation failures

  1. Intel Mac users may encounter compilation problems. See here for a potential solution.
  2. 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.
  3. For Rcpp, RcppArmadillo and MacOS “-lgfortran” and “-lquadmath” error, click here for details.
  4. Installation failure related to OpenMP on MacOS, click here for a solution.
  5. To fix these issues, try installing gfortran from here.

Report bugs

Please report any bugs to me (yiqingxu [at] stanford.edu) or submit an issue on GitHub. Please include your minimally replicable code & data file and a panelView treatment status plot. Your feedback is highly valued!