Skip to content

Commit

Permalink
version 0.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose R. Zubizarreta authored and cran-robot committed Jun 18, 2018
1 parent 75f738e commit 1a7690b
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 62 deletions.
14 changes: 7 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
Package: designmatch
Type: Package
Title: Matched Samples that are Balanced and Representative by Design
Version: 0.3.0
Date: 2017-05-17
Author: Jose R. Zubizarreta <zubizarreta@columbia.edu>, Cinar Kilcioglu <[email protected]>, Juan P. Vielma <[email protected]>
Maintainer: Jose R. Zubizarreta <zubizarreta@columbia.edu>
Version: 0.3.1
Date: 2018-06-18
Author: Jose R. Zubizarreta <zubizarreta@hcp.med.harvard.edu>, Cinar Kilcioglu <[email protected]>, Juan P. Vielma <[email protected]>
Maintainer: Jose R. Zubizarreta <zubizarreta@hcp.med.harvard.edu>
Depends: R (>= 3.2), lattice, MASS, slam, Rglpk
Suggests: gurobi, Rcplex, Rsymphony
Enhances: gurobi, Rcplex, Rmosek, Rsymphony
SystemRequirements: GLPK library package (e.g., libglpk-dev on
Debian/Ubuntu)
License: GPL-2 | GPL-3
Description: Includes functions for the construction of matched samples that are balanced and representative by design. Among others, these functions can be used for matching in observational studies with treated and control units, with cases and controls, in related settings with instrumental variables, and in discontinuity designs. Also, they can be used for the design of randomized experiments, for example, for matching before randomization. By default, 'designmatch' uses the 'GLPK' optimization solver, but its performance is greatly enhanced by the 'Gurobi' optimization solver and its associated R interface. For their installation, please follow the instructions at <http://user.gurobi.com/download/gurobi-optimizer> and <http://www.gurobi.com/documentation/7.0/refman/r_api_overview.html>. We have also included directions in the gurobi_installation file in the inst folder.
NeedsCompilation: no
Packaged: 2017-05-18 01:39:38 UTC; jrz
Packaged: 2018-06-18 14:12:15 UTC; jrz
Repository: CRAN
Date/Publication: 2017-05-18 03:48:36 UTC
Date/Publication: 2018-06-18 18:24:05 UTC
26 changes: 13 additions & 13 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
e6ccf902847f31ee3b7a20750bbc8815 *DESCRIPTION
bd3c4c85871ceff1cc5f2f0f9cdb44a5 *DESCRIPTION
a84e461889448bab6f00dc036a173876 *NAMESPACE
4035589e4087aa8c0dfc97e90db340f8 *R/absstddif.r
7d1a85944bcd2594e3ab13ffdd80bd1e *R/addcalip.r
06d2cede573309b27980bbb8869ad01e *R/bmatch.r
932c4f0f192b4f4901220dcb169c4d50 *R/cardmatch.r
53910a26ffdd46067f0ff93d9694b58d *R/cardmatch.r
1ccbbc3d8e654fcd4366a8c93350178b *R/constraintmatrix.r
ddd36bec26100d3064a1bf106c36740c *R/distmat.r
692b745a194a270376faf4842b958a02 *R/distmatch.r
Expand All @@ -15,25 +15,25 @@ d3df5386a7329cd2c93dedac69a83db4 *R/meantab.r
4a4e30c24c6373c9118b32245b3f29fc *R/nmatch.r
98f291ae461a0b1c18ea5d8858b3eb22 *R/pairsplot.r
36d380e4bd2fb8bbd551af173cc12056 *R/problemparameters.r
3fc3b874e31fb6965591687cfc0481c9 *R/problemparameters_cardmatch.r
6c4827264e52d44760c865663f2e6c2d *R/problemparameters_cardmatch.r
faaeb63e221a183bf338d8005151bb03 *R/relaxation_b.r
1ee8331d65f0dab43a41bd5a4740fcdf *R/relaxation_n.r
8a6974d5a5f551af3ca1e1be7d555be6 *R/smahal.r
0187616874e4a366b4ba006ded775e2d *data/germancities.rda
7c8f4dadefa6fd57a06a23067605dda0 *data/lalonde.rda
fca1c5c2ab15ec2207f7f77919cca494 *inst/gurobi_installation.txt
8b5ab702a3ca62c67934d34220c09ab6 *inst/symphony_installation.txt
a3432aa9ad196973c884751e3a7e0fb4 *man/absstddif.Rd
e19dd3ffc9a2b389b9ad4c0a7a082600 *man/bmatch.Rd
2f242dd6c23bbb2cf7b56ab900a74572 *man/cardmatch.Rd
70d7c69f620facbd7955281a7d6bbf1b *man/designmatch-package.Rd
a8685672a86c1c9e7c630b430a193f5f *man/absstddif.Rd
6ec4ccf8e22c37bac38e74e20aedfa84 *man/bmatch.Rd
d26a6354e52f7b5a8d74a5fec2f4c4df *man/cardmatch.Rd
f57efa7f8b3a56947c842360a6be4c4b *man/designmatch-package.Rd
9d510e34095ba20a26ae6ed0e3b7807a *man/distmat.Rd
90779867557e9b66310864ca76f825f5 *man/distmatch.Rd
60560ddae0cc24fb6cedc7785379fd3d *man/ecdfplot.Rd
093455696515de415adc6c394e839715 *man/finetab.Rd
3562e9d06db45009486c574740e620a4 *man/distmatch.Rd
1d59c6df9d58dd6a7d6d7e94a0a535b8 *man/ecdfplot.Rd
e7f0f69f8b70ba4d92f21b1d93d60bec *man/finetab.Rd
3e98c15e211274459bbe5239f7342766 *man/germancities.Rd
d956e94f68ff0196119800ab2e887d19 *man/lalonde.Rd
178925f2ba0ec6cb0cf7c88bd5f936c2 *man/loveplot.Rd
e6792c32417b2ef50459d550ed90b83f *man/loveplot.Rd
1616542174f147bf821c0ca73161fb10 *man/meantab.Rd
50a270039e2ddaa4d21bd7dcbc668c9a *man/nmatch.Rd
3a8a8aafd46dc6a04a0f186139fe43f9 *man/pairsplot.Rd
294e9c9f7e988b764df5ea51f1d36ddd *man/nmatch.Rd
54aa121631d4cc210c88409123f0cbec *man/pairsplot.Rd
9 changes: 7 additions & 2 deletions R/cardmatch.r
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ cardmatch = function(t_ind, mom = NULL, fine = NULL, solver = NULL) {
} else {
mom_covs = mom$covs
mom_tols = mom$tols
mom_targets = mom$targets
}
if (is.null(mom$targets)) {
mom_targets = NULL
}
if (!is.null(mom$targets)) {
mom_targets = mom$targets
}
}
if (is.null(fine)) {
fine_covs = NULL
} else {
Expand Down
60 changes: 40 additions & 20 deletions R/problemparameters_cardmatch.r
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,39 @@
vals_mom = NULL
n_mom_covs = ncol(mom_covs)
k = 1
for (i in 1:n_mom_covs) {
#! Treated
rows_mom_plus = rep(row_ind_cur+k, n_t)
rows_mom_minus = rep(row_ind_cur+k+1, n_t)
rows_mom = c(rows_mom, rows_mom_plus, rows_mom_minus)
cols_mom = c(cols_mom, rep(1:n_t, 2))
vals_plus = c(mom_covs[t_ind==1, i]-mom_targets[i]-mom_tols[i])
vals_minus = c(mom_covs[t_ind==1, i]-mom_targets[i]+mom_tols[i])
vals_mom = c(vals_mom, c(vals_plus, vals_minus))
#! Controls
rows_mom_plus = rep(row_ind_cur+k+2, n_c)
rows_mom_minus = rep(row_ind_cur+k+3, n_c)
rows_mom = c(rows_mom, rows_mom_plus, rows_mom_minus)
cols_mom = c(cols_mom, rep(n_t+(1:n_c), 2))
vals_plus = c(mom_covs[t_ind==0, i]-mom_targets[i]-mom_tols[i])
vals_minus = c(mom_covs[t_ind==0, i]-mom_targets[i]+mom_tols[i])
vals_mom = c(vals_mom, c(vals_plus, vals_minus))
k = k+4
if (!is.null(mom_targets)) {
for (i in 1:n_mom_covs) {
#! Treated
rows_mom_plus = rep(row_ind_cur+k, n_t)
rows_mom_minus = rep(row_ind_cur+k+1, n_t)
rows_mom = c(rows_mom, rows_mom_plus, rows_mom_minus)
cols_mom = c(cols_mom, rep(1:n_t, 2))
vals_plus = c(mom_covs[t_ind==1, i]-mom_targets[i]-mom_tols[i])
vals_minus = c(mom_covs[t_ind==1, i]-mom_targets[i]+mom_tols[i])
vals_mom = c(vals_mom, c(vals_plus, vals_minus))
#! Controls
rows_mom_plus = rep(row_ind_cur+k+2, n_c)
rows_mom_minus = rep(row_ind_cur+k+3, n_c)
rows_mom = c(rows_mom, rows_mom_plus, rows_mom_minus)
cols_mom = c(cols_mom, rep(n_t+(1:n_c), 2))
vals_plus = c(mom_covs[t_ind==0, i]-mom_targets[i]-mom_tols[i])
vals_minus = c(mom_covs[t_ind==0, i]-mom_targets[i]+mom_tols[i])
vals_mom = c(vals_mom, c(vals_plus, vals_minus))
k = k+4
}
}
if (is.null(mom_targets)) {
for (i in 1:n_mom_covs) {
rows_mom_plus = rep(row_ind_cur+k, n_t+n_c)
rows_mom_minus = rep(row_ind_cur+k+1, n_t+n_c)
rows_mom = c(rows_mom, rows_mom_plus, rows_mom_minus)
cols_mom = c(cols_mom, rep(1:(n_t+n_c), 2))
vals_plus = c(mom_covs[t_ind==1, i]-mom_tols[i], -mom_covs[t_ind==0, i])
vals_minus = c(mom_covs[t_ind==1, i]+mom_tols[i], -mom_covs[t_ind==0, i])
vals_mom = c(vals_mom, c(vals_plus, vals_minus))
k = k+2
}
}
row_ind_cur = max(rows_mom)
}
#! Fine balance
Expand Down Expand Up @@ -113,8 +127,14 @@
sense = NULL
#! Mom balance
if (!is.null(mom_covs)) {
sense_covs = rep(c("L", "G", "L", "G"), length(unique(rows_mom))/4)
sense = c(sense, sense_covs)
if (!is.null(mom_targets)) {
sense_covs = rep(c("L", "G", "L", "G"), length(unique(rows_mom))/4)
sense = c(sense, sense_covs)
}
if (is.null(mom_targets)) {
sense_covs = rep(c("L", "G"), length(unique(rows_mom))/2)
sense = c(sense, sense_covs)
}
}
#! Fine balance
if (!is.null(fine_covs)) {
Expand Down
2 changes: 1 addition & 1 deletion man/absstddif.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}

\author{
Jose R. Zubizarreta <zubizarreta@columbia.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
Jose R. Zubizarreta <zubizarreta@hcp.med.harvard.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
}

\examples{
Expand Down
11 changes: 7 additions & 4 deletions man/bmatch.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

\arguments{

\item{t_ind}{treatment indicator: a vector of zeros and ones indicating treatment (1 = treated; 0 = control).}
\item{t_ind}{treatment indicator: a vector of zeros and ones indicating treatment (1 = treated; 0 = control). Please note that the data needs to be sorted in decreasing order according to this treatment indicator.}

\item{dist_mat}{distance matrix: a matrix of positive distances between treated units (rows) and controls (columns). If \code{dist_mat = NULL} and \code{subset_weight = 1}, then bmatch will solve the cardinality matching problem in Zubizarreta et al. (2014).}

Expand Down Expand Up @@ -134,7 +134,7 @@ tional studies," \emph{Journal of Computational and Graphical Statistics}, 21, 5
}

\author{
Jose R. Zubizarreta <zubizarreta@columbia.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
Jose R. Zubizarreta <zubizarreta@hcp.med.harvard.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
}

\seealso{
Expand All @@ -143,8 +143,9 @@ tional studies," \emph{Journal of Computational and Graphical Statistics}, 21, 5

\examples{

# Load and attach data
# Load, sort, and attach data
data(lalonde)
lalonde = lalonde[order(lalonde$treatment, decreasing = TRUE), ]
attach(lalonde)

#################################
Expand All @@ -156,8 +157,10 @@ attach(lalonde)
# exact matching for different covariates. The solver used is glpk with the
# approximate option.

# Treatment indicator
# Treatment indicator; note that the data needs to be sorted in decreasing order
# according to this treatment indicator
t_ind = treatment
t_ind

# Distance matrix
dist_mat = NULL
Expand Down
11 changes: 7 additions & 4 deletions man/cardmatch.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

\arguments{

\item{t_ind}{treatment indicator: a vector of zeros and ones indicating treatment (1 = treated; 0 = control).}
\item{t_ind}{treatment indicator: a vector of zeros and ones indicating treatment (1 = treated; 0 = control). Please note that the data needs to be sorted in decreasing order according to this treatment indicator.}

\item{mom}{moment balance parameters: a list with three arguments,

Expand Down Expand Up @@ -73,7 +73,7 @@ Optimization solver parameters: a list with four objects,
}

\author{
Jose R. Zubizarreta <zubizarreta@columbia.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>, Juan P. Vielma <jvielma@mit.edu>.
Jose R. Zubizarreta <zubizarreta@hcp.med.harvard.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>, Juan P. Vielma <jvielma@mit.edu>.
}

\seealso{
Expand All @@ -82,8 +82,9 @@ Optimization solver parameters: a list with four objects,

\examples{

# Load and attach data
# Load, sort, and attach data
data(lalonde)
lalonde = lalonde[order(lalonde$treatment, decreasing = TRUE), ]
attach(lalonde)

#################################
Expand All @@ -107,8 +108,10 @@ education_5 = quantiles(education, 5)
re74_5 = quantiles(re74, 5)
re75_5 = quantiles(re75, 5)

# Treatment indicator
# Treatment indicator; note that the data needs to be sorted in decreasing order
# according to this treatment indicator
t_ind = treatment
t_ind

# Fine balance
fine_covs = cbind(black, hispanic, married, nodegree, age_5, education_5, re74_5, re75_5)
Expand Down
4 changes: 2 additions & 2 deletions man/designmatch-package.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ License: \tab GPL-2 | GPL-3\cr
}
}
\author{
Jose R. Zubizarreta <zubizarreta@columbia.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
Jose R. Zubizarreta <zubizarreta@hcp.med.harvard.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.

Maintainer: Jose R. Zubizarreta <zubizarreta@columbia.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
Maintainer: Jose R. Zubizarreta <zubizarreta@hcp.med.harvard.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
}
\references{
Greevy, R., Lu, B., Silber, J. H., and Rosenbaum, P. R. (2004), "Optimal Multivariate
Expand Down
11 changes: 7 additions & 4 deletions man/distmatch.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

\arguments{

\item{t_ind}{treatment indicator: a vector of zeros and ones indicating treatment (1 = treated; 0 = control).}
\item{t_ind}{treatment indicator: a vector of zeros and ones indicating treatment (1 = treated; 0 = control). Please note that the data needs to be sorted in decreasing order according to this treatment indicator.}

\item{dist_mat}{distance matrix: a matrix of positive distances between treated units (rows) and controls (columns). If \code{dist_mat = NULL} and \code{subset_weight = 1}, then bmatch will solve the cardinality matching problem in Zubizarreta et al. (2014).}

Expand Down Expand Up @@ -58,7 +58,7 @@ Optimization solver parameters: a list with four objects,
}

\author{
Jose R. Zubizarreta <zubizarreta@columbia.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
Jose R. Zubizarreta <zubizarreta@hcp.med.harvard.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
}

\seealso{
Expand All @@ -67,8 +67,9 @@ Optimization solver parameters: a list with four objects,

\examples{

# Load and attach data
# Load, sort, and attach data
data(lalonde)
lalonde = lalonde[order(lalonde$treatment, decreasing = TRUE), ]
attach(lalonde)

#################################
Expand All @@ -92,8 +93,10 @@ education_5 = quantiles(education, 5)
re74_5 = quantiles(re74, 5)
re75_5 = quantiles(re75, 5)

# Treatment indicator
# Treatment indicator; note that the data needs to be sorted in decreasing order
# according to this treatment indicator
t_ind = treatment
t_ind

# Fine balance
fine_covs = cbind(black, hispanic, married, nodegree, age_5, education_5, re74_5, re75_5)
Expand Down
2 changes: 1 addition & 1 deletion man/ecdfplot.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
}

\author{
Jose R. Zubizarreta <zubizarreta@columbia.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
Jose R. Zubizarreta <zubizarreta@hcp.med.harvard.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
}

\examples{
Expand Down
2 changes: 1 addition & 1 deletion man/finetab.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}

\author{
Jose R. Zubizarreta <zubizarreta@columbia.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
Jose R. Zubizarreta <zubizarreta@hcp.med.harvard.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
}

\examples{
Expand Down
2 changes: 1 addition & 1 deletion man/loveplot.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}

\author{
Jose R. Zubizarreta <zubizarreta@columbia.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
Jose R. Zubizarreta <zubizarreta@hcp.med.harvard.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
}

\examples{
Expand Down
2 changes: 1 addition & 1 deletion man/nmatch.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ tional studies," \emph{Journal of Computational and Graphical Statistics}, 21, 5
}

\author{
Jose R. Zubizarreta <zubizarreta@columbia.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
Jose R. Zubizarreta <zubizarreta@hcp.med.harvard.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
}

%\seealso{
Expand Down
2 changes: 1 addition & 1 deletion man/pairsplot.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
}

\author{
Jose R. Zubizarreta <zubizarreta@columbia.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
Jose R. Zubizarreta <zubizarreta@hcp.med.harvard.edu>, Cinar Kilcioglu <ckilcioglu16@gsb.columbia.edu>.
}

\examples{
Expand Down

0 comments on commit 1a7690b

Please sign in to comment.