diff --git a/DESCRIPTION b/DESCRIPTION index 3a9c907e..17606cf5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: MatchIt -Version: 4.5.5 +Version: 4.5.5.9000 Title: Nonparametric Preprocessing for Parametric Causal Inference Description: Selects matched samples of the original treated and control groups with similar covariate distributions -- can be diff --git a/MatchIt.Rproj b/MatchIt.Rproj index 6291372e..f30c4eca 100644 --- a/MatchIt.Rproj +++ b/MatchIt.Rproj @@ -18,3 +18,4 @@ BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source PackageCheckArgs: --as-cran +PackageRoxygenize: rd,collate,namespace diff --git a/NEWS.md b/NEWS.md index e47a1717..f6817261 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,10 @@ output: `MatchIt` News and Updates ====== +# MatchIt (development version) + +* Fixed a bug when using `method = "optimal"` or `method = "full"` with `discard` specified and `data` given as a tibble (`tbl_df` object). (#185) + # MatchIt 4.5.5 * When using `method = "cardinality"`, a new solver, HiGHS, can be requested by setting `solver = "highs"`, which relies on the `highs` package. This is much faster and more reliable than GLPK and is free and easy to install as a regular R package with no additional requirements. diff --git a/R/matchit2full.R b/R/matchit2full.R index 4bc10f02..8da98e25 100644 --- a/R/matchit2full.R +++ b/R/matchit2full.R @@ -303,7 +303,7 @@ matchit2full <- function(treat, formula, data, distance, discarded, mo <- mo[!discarded[treat == focal], !discarded[treat != focal], drop = FALSE] dimnames(mo) <- list(names(treat_)[treat_ == 1], names(treat_)[treat_ == 0]) - mo <- optmatch::match_on(mo, data = data[!discarded,, drop = FALSE]) + mo <- optmatch::match_on(mo, data = as.data.frame(data)[!discarded,, drop = FALSE]) mo <- optmatch::as.InfinitySparseMatrix(mo) #Process antiexact diff --git a/R/matchit2optimal.R b/R/matchit2optimal.R index 415e5857..89c63b7a 100644 --- a/R/matchit2optimal.R +++ b/R/matchit2optimal.R @@ -244,7 +244,7 @@ matchit2optimal <- function(treat, formula, data, distance, discarded, ratio = 1, s.weights = NULL, caliper = NULL, mahvars = NULL, exact = NULL, estimand = "ATT", verbose = FALSE, - is.full.mahalanobis, antiexact = NULL, ...) { + is.full.mahalanobis, antiexact = NULL, ...) { rlang::check_installed("optmatch") @@ -360,7 +360,7 @@ matchit2optimal <- function(treat, formula, data, distance, discarded, mo <- mo[!discarded[treat == focal], !discarded[treat != focal], drop = FALSE] dimnames(mo) <- list(names(treat_)[treat_ == 1], names(treat_)[treat_ == 0]) - mo <- optmatch::match_on(mo, data = data[!discarded,, drop = FALSE]) + mo <- optmatch::match_on(mo, data = as.data.frame(data)[!discarded,, drop = FALSE]) mo <- optmatch::as.InfinitySparseMatrix(mo) #Process antiexact diff --git a/R/plot.matchit.R b/R/plot.matchit.R index 84cd5437..464c8deb 100644 --- a/R/plot.matchit.R +++ b/R/plot.matchit.R @@ -900,10 +900,10 @@ jitter.pscore <- function(x, interactive, pch = 1, ...){ pch = pch, cex = cwt[treat==0 & matched], ...) #Unmatched treated points(pscore[treat==1 & !matched], jitp[treat==1 & !matched], - pch = pch, cex = cswt[treat==1 & matched],...) + pch = pch, cex = cswt[treat==1 & !matched],...) #Unmatched control points(pscore[treat==0 & !matched], jitp[treat==0 & !matched], - pch = pch, cex = cswt[treat==0 & matched], ...) + pch = pch, cex = cswt[treat==0 & !matched], ...) axis(1) diff --git a/README.Rmd b/README.Rmd index dd8aaed6..f19f5818 100644 --- a/README.Rmd +++ b/README.Rmd @@ -65,3 +65,21 @@ Please cite `MatchIt` when using it for analysis presented in publications, whic Ho, D. E., Imai, K., King, G., & Stuart, E. A. (2011). MatchIt: Nonparametric Preprocessing for Parametric Causal Inference. *Journal of Statistical Software*, 42(8). [doi:10.18637/jss.v042.i08](https://doi.org/10.18637/jss.v042.i08) This citation can also be accessed using `citation("MatchIt")` in R. For reproducibility purposes, it is also important to include the version number for the version used. + +### Installation + +To download and install the latest stable version of `MatchIt` from CRAN, run the following: + +```{r, eval=F} +install.packages("MatchIt") +``` + +To install a development version, which may have a bug fixed or a new feature, run the following: + +```{r, eval=F} +install.packages("remotes") #If not yet installed + +remotes::install_github("ngreifer/MatchIt") +``` + +This will require R to compile C++ code, which might require additional software be installed on your computer. If you need the development version but can't compile the package, ask the maintainer for a binary version of the package. \ No newline at end of file diff --git a/README.md b/README.md index 7214e2f9..4d65126e 100644 --- a/README.md +++ b/README.md @@ -133,3 +133,26 @@ Statistical Software*, 42(8). This citation can also be accessed using `citation("MatchIt")` in R. For reproducibility purposes, it is also important to include the version number for the version used. + +### Installation + +To download and install the latest stable version of `MatchIt` from +CRAN, run the following: + +``` r +install.packages("MatchIt") +``` + +To install a development version, which may have a bug fixed or a new +feature, run the following: + +``` r +install.packages("remotes") #If not yet installed + +remotes::install_github("ngreifer/MatchIt") +``` + +This will require R to compile C++ code, which might require additional +software be installed on your computer. If you need the development +version but can’t compile the package, ask the maintainer for a binary +version of the package.