diff --git a/DESCRIPTION b/DESCRIPTION index ecfd8b8..4ea94fa 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,15 +1,15 @@ Package: gsynth Type: Package Title: Generalized Synthetic Control Method -Version: 1.1.9 -Date: 2021-02-21 +Version: 1.2.0 +Date: 2021-08-05 Author: Yiqing Xu, Licheng Liu -Maintainer: Yiqing Xu +Maintainer: Yiqing Xu Description: Provides causal inference with interactive fixed-effect models. It imputes counterfactuals for each treated unit using control group information based on a linear interactive fixed effects model that incorporates unit-specific intercepts interacted with time-varying coefficients. This method generalizes the synthetic control method to the case of multiple treated units and variable treatment periods, and improves efficiency and interpretability. This version supports unbalanced panels and implements the matrix completion method. Main reference: Yiqing Xu (2017) . -URL: http://yiqingxu.org/software/gsynth/gsynth_examples.html +URL: https://yiqingxu.org/packages/gsynth/gsynth_examples.html NeedsCompilation: yes License: GPL-2 -Imports: Rcpp (>= 0.12.3), ggplot2 (>= 2.1.0), GGally (>= 1.0.1), +Imports: Rcpp (>= 0.12.3), ggplot2 (>= 2.1.0), GGally (>= 1.0.1), future (>= 1.21.0), doRNG (>= 1.8.2), doParallel (>= 1.0.10), foreach (>= 1.4.3), abind (>= 1.4-0), mvtnorm (>= 1.0-6), MASS (>= 7.3.47), lfe (>= 1.0-0) SystemRequirements: A C++11 compiler. Depends: R (>= 2.10) diff --git a/R/default.R b/R/default.R index a837359..5b95200 100644 --- a/R/default.R +++ b/R/default.R @@ -275,8 +275,8 @@ gsynth.default <- function(formula = NULL,data, # a data frame (long-form) # Do not attempt to use the parametric bootstrap if the number of treated units is fewer than 40 n_treated = length(unique(data[data[,D] == 1, index[1]])) - if (inference == "nonparametric" && n_treated < 40 && se) { - stop("Nonparametric bootstrap is inappropriate when there are fewer than 40 treated units") + if (inference == "nonparametric" && n_treated < 40 && se && estimator != "mc") { + warning("Nonparametric bootstrap may be inappropriate when there are too few 40 treated units; consider using parametric bootstrap or jackknife.") } ## nboots diff --git a/R/plot.R b/R/plot.R index d007c7f..cb969e8 100644 --- a/R/plot.R +++ b/R/plot.R @@ -11,21 +11,22 @@ # main: whether to show the title; # nfactors: whose loadings to be plotted # id: individual plot -plot.gsynth <- function(x, - type = "gap", - xlim = NULL, - ylim = NULL, - xlab = NULL, - ylab = NULL, - legendOff = FALSE, - raw = "none", - main = NULL, - nfactors = NULL, - id = NULL, - axis.adjust = FALSE, - theme.bw = FALSE, - shade.post = NULL, - ...){ +plot.gsynth <- function( + x, + type = "gap", + xlim = NULL, + ylim = NULL, + xlab = NULL, + ylab = NULL, + legendOff = FALSE, + raw = "none", + main = NULL, + nfactors = NULL, + id = NULL, + axis.adjust = FALSE, + theme.bw = TRUE, + shade.post = FALSE, + ...){ ##-------------------------------## diff --git a/R/zzz.r b/R/zzz.r new file mode 100644 index 0000000..c421a38 --- /dev/null +++ b/R/zzz.r @@ -0,0 +1,6 @@ +.onAttach <- +function (libname, pkgname){ + # echo output to screen + packageStartupMessage("## Syntax has been updated since v.1.2.0.\n") + packageStartupMessage("## Comments and suggestions -> yiqingxu@stanford.edu.\n") +} diff --git a/man/cumuEff.rd b/man/cumuEff.rd index 6cce5d1..1ba0a9b 100644 --- a/man/cumuEff.rd +++ b/man/cumuEff.rd @@ -17,7 +17,9 @@ } \author{ - Yiqing Xu and Licheng Liu + Yiqing Xu , Stanford University + + Licheng Liu , M.I.T. } \references{ Jushan Bai. 2009. "Panel Data Models with Interactive Fixed @@ -25,7 +27,7 @@ Yiqing Xu. 2017. "Generalized Synthetic Control Method: Causal Inference with Interactive Fixed Effects Models." Political Analysis, Vol. 25, - Iss. 1, January 2017, pp. 57-76. Available at: \url{https://doi.org/10.1017/pan.2016.2}. + Iss. 1, January 2017, pp. 57-76. } \seealso{ \code{\link{gsynth}} diff --git a/man/gsynth-package.Rd b/man/gsynth-package.Rd index 7d5b318..cc0da8f 100644 --- a/man/gsynth-package.Rd +++ b/man/gsynth-package.Rd @@ -13,13 +13,13 @@ See \code{\link{gsynth}} for details. } \author{ - Yiqing Xu , University of California, San Diego + Yiqing Xu , Stanford University - Licheng Liu , Tsinghua University + Licheng Liu , M.I.T. } \references{ Yiqing Xu. 2017. "Generalized Synthetic Control Method: Causal Inference - with Interactive Fixed Effects Models." Political Analysis, Vol. 25, Iss. 1, January 2017, pp. 57-76. Available at: \url{https://doi.org/10.1017/pan.2016.2}. + with Interactive Fixed Effects Models." Political Analysis, Vol. 25, Iss. 1, January 2017, pp. 57-76. - For more details, see \url{http://yiqingxu.org/software/gsynth/gsynth_examples.html}. + For more details, see \url{https://yiqingxu.org/packages/gsynth/gsynth_examples.html}. } diff --git a/man/gsynth.Rd b/man/gsynth.Rd index ef46002..1d87725 100644 --- a/man/gsynth.Rd +++ b/man/gsynth.Rd @@ -180,9 +180,9 @@ on interactive fixed effect models.} \item{beta.boot}{bootstrap results for \code{beta}.} } \author{ - Yiqing Xu - - Licheng Liu + Yiqing Xu , Stanford University + + Licheng Liu , M.I.T. } \references{ Laurent Gobillon and Thierry Magnac, 2016. @@ -192,11 +192,11 @@ on interactive fixed effect models.} Yiqing Xu. 2017. "Generalized Synthetic Control Method: Causal Inference with Interactive Fixed Effects Models." Political Analysis, Vol. 25, - Iss. 1, January 2017, pp. 57-76. Available at: \url{https://doi.org/10.1017/pan.2016.2}. + Iss. 1, January 2017, pp. 57-76. Athey S, Bayati M, Doudchenko N, et al. Matrix completion methods for causal panel data models[J]. arXiv preprint arXiv:1710.10251, 2017. - For more details, see \url{http://yiqingxu.org/software/gsynth/gsynth_examples.html}. + For more details, see \url{https://yiqingxu.org/packages/gsynth/gsynth_examples.html}. For more details about the matrix completion method, see \url{https://github.com/susanathey/MCPanel}. } diff --git a/man/interFE.Rd b/man/interFE.Rd index 7fc3816..e722d1c 100644 --- a/man/interFE.Rd +++ b/man/interFE.Rd @@ -53,9 +53,9 @@ \item{est.boot}{a matrix storing results from bootstraps.} } \author{ - Yiqing Xu - - Licheng Liu + Yiqing Xu , Stanford University + + Licheng Liu , M.I.T. } \references{Jushan Bai. 2009. "Panel Data Models with Interactive Fixed Effects." Econometrica 77:1229--1279.} diff --git a/man/plot.gsynth.Rd b/man/plot.gsynth.Rd index 599b01d..90a89e6 100644 --- a/man/plot.gsynth.Rd +++ b/man/plot.gsynth.Rd @@ -49,15 +49,15 @@ results obtained from, the generalized synthetic control method. } \author{ - Yiqing Xu + Yiqing Xu , Stanford University - Licheng Liu + Licheng Liu , M.I.T. } \references{Yiqing Xu. 2017. "Generalized Synthetic Control Method: Causal Inference with Interactive Fixed Effects Models." Political Analysis, Vol. 25, - Iss. 1, January 2017, pp. 57-76. Available at: \url{https://doi.org/10.1017/pan.2016.2}. + Iss. 1, January 2017, pp. 57-76. - See \url{http://yiqingxu.org/software/gsynth/gsynth_examples.html} for + See \url{https://yiqingxu.org/packages/gsynth/gsynth_examples.html} for more detailed information. } \seealso{ diff --git a/man/print.gsynth.Rd b/man/print.gsynth.Rd index 127e905..46cbba9 100644 --- a/man/print.gsynth.Rd +++ b/man/print.gsynth.Rd @@ -8,15 +8,15 @@ \item{\dots}{other argv.} } \author{ - Yiqing Xu - - Licheng Liu + Yiqing Xu , Stanford University + + Licheng Liu , M.I.T. } \references{Yiqing Xu. 2017. "Generalized Synthetic Control Method: Causal Inference with Interactive Fixed Effects Models." Political Analysis, Vol. 25, - Iss. 1, January 2017, pp. 57-76. Available at: \url{https://doi.org/10.1017/pan.2016.2}. + Iss. 1, January 2017, pp. 57-76. - For more details, see \url{http://yiqingxu.org/software/gsynth/gsynth_examples.html}. + For more details, see \url{https://yiqingxu.org/packages/gsynth/gsynth_examples.html}. } \seealso{ \code{\link{gsynth}} and \code{\link{plot.gsynth}} diff --git a/man/print.interFE.Rd b/man/print.interFE.Rd index 6295e8e..3c1016d 100644 --- a/man/print.interFE.Rd +++ b/man/print.interFE.Rd @@ -8,9 +8,9 @@ \item{\dots}{other argv.} } \author{ - Yiqing Xu + Yiqing Xu , Stanford University - Licheng Liu + Licheng Liu , M.I.T. } \references{Jushan Bai. 2009. "Panel Data Models with Interactive Fixed Effects." Econometrica 77:1229--1279.} diff --git a/man/simdata.Rd b/man/simdata.Rd index f5daa8f..e00466b 100644 --- a/man/simdata.Rd +++ b/man/simdata.Rd @@ -1,14 +1,14 @@ -\name{simdata} -\docType{data} -\alias{simdata} -\title{simdata} -\description{A simulated dataset.} -\format{dataframe} -\keyword{datasets} -\references{ - Yiqing Xu. 2017. "Generalized Synthetic Control Method: Causal Inference - with Interactive Fixed Effects Models." Political Analysis, Vol. 25, - Iss. 1, January 2017, pp. 57-76. Available at: \url{https://doi.org/10.1017/pan.2016.2}. - - For more details, see \url{http://yiqingxu.org/software/gsynth/gsynth_examples.html}. -} +\name{simdata} +\docType{data} +\alias{simdata} +\title{simdata} +\description{A simulated dataset.} +\format{dataframe} +\keyword{datasets} +\references{ + Yiqing Xu. 2017. "Generalized Synthetic Control Method: Causal Inference + with Interactive Fixed Effects Models." Political Analysis, Vol. 25, + Iss. 1, January 2017, pp. 57-76. + + For more details, see \url{https://yiqingxu.org/packages/gsynth/gsynth_examples.html}. +} diff --git a/man/turnout.Rd b/man/turnout.Rd index cc1ad8b..05e5c9a 100644 --- a/man/turnout.Rd +++ b/man/turnout.Rd @@ -1,19 +1,19 @@ -\name{turnout} -\docType{data} -\alias{turnout} -\title{turnout} -\description{State-level voter turnout data.} -\format{dataframe} -\keyword{datasets} -\references{ - Melanie Jean Springer. 2014. How the States Shaped the - Nation: American Electoral Institutions and Voter Turnout, - 1920-2000. University of Chicago Press. - - Yiqing Xu. 2017. "Generalized Synthetic Control Method: Causal Inference - with Interactive Fixed Effects Models." Political Analysis, Vol. 25, - Iss. 1, January 2017, pp. 57-76. Available at: \url{https://doi.org/10.1017/pan.2016.2}. - - For more details, see \url{http://yiqingxu.org/software/gsynth/gsynth_examples.html}. -} - +\name{turnout} +\docType{data} +\alias{turnout} +\title{turnout} +\description{State-level voter turnout data.} +\format{dataframe} +\keyword{datasets} +\references{ + Melanie Jean Springer. 2014. How the States Shaped the + Nation: American Electoral Institutions and Voter Turnout, + 1920-2000. University of Chicago Press. + + Yiqing Xu. 2017. "Generalized Synthetic Control Method: Causal Inference + with Interactive Fixed Effects Models." Political Analysis, Vol. 25, + Iss. 1, January 2017, pp. 57-76. + + For more details, see \url{https://yiqingxu.org/packages/gsynth/gsynth_examples.html}. +} +