Skip to content

Commit

Permalink
version 0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose R. Zubizarreta authored and cran-robot committed Jan 29, 2016
0 parents commit acb9808
Show file tree
Hide file tree
Showing 35 changed files with 3,759 additions and 0 deletions.
19 changes: 19 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Package: designmatch
Type: Package
Title: Construction of Optimally Matched Samples for Randomized
Experiments and Observational Studies that are Balanced by
Design
Version: 0.1
Date: 2016-01-23
Author: Jose R. Zubizarreta <[email protected]>, Cinar Kilcioglu <[email protected]>
Maintainer: Jose R. Zubizarreta <[email protected]>
Depends: R (>= 3.2), lattice, MASS, slam, Rglpk
Suggests: gurobi, Rcplex, 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 by design. These functions include options for directly balancing means, higher order moments and distributions of the covariates, that can be used in observational studies with treatment and control units, cases and controls, and more generally in settings with instrumental variables and in discontinuity designs. These functions can also be used for the design of randomized experiments, for example for matching before randomization. The performance of these functions 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/6.5/refman/r_api_overview.html; also, we have included direction in the gurobi_installation file in the inst folder.
NeedsCompilation: no
Packaged: 2016-01-28 20:55:24 UTC; jrz
Repository: CRAN
Date/Publication: 2016-01-29 00:36:19
34 changes: 34 additions & 0 deletions MD5
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
be2ec90ebcb8a4a7ff68e81a2f5bda21 *DESCRIPTION
a84e461889448bab6f00dc036a173876 *NAMESPACE
4035589e4087aa8c0dfc97e90db340f8 *R/absstddif.R
7d1a85944bcd2594e3ab13ffdd80bd1e *R/addcalip.r
d2ef5c84a6b512d1a1c960afa7af49ab *R/bmatch.r
1849a38fa6a3b3f2001095c7c992dc5f *R/constraintmatrix.r
ddd36bec26100d3064a1bf106c36740c *R/distmat.R
f562ca6fc19a2951c9fcaaa01cae81dd *R/ecdfplot.R
d41d8cd98f00b204e9800998ecf8427e *R/errorhandling.r
a7c14294e78b350eca6b9b036f9f0817 *R/finetab.R
c98b06b08fd9add6edc0464b9d8d3443 *R/loveplot.R
d3df5386a7329cd2c93dedac69a83db4 *R/meantab.R
63ebfeac5826e4c81031a803919630c0 *R/nmatch.r
98f291ae461a0b1c18ea5d8858b3eb22 *R/pairsplot.R
a600cf95b2d9d66bc6eb3fe049418319 *R/problemparameters.r
88e0b8235fa9bf1f3554d0ce3cd3e4f2 *R/relaxation_b.r
82e83c7ff2c5059f495c54bc65c9a040 *R/relaxation_n.r
8a6974d5a5f551af3ca1e1be7d555be6 *R/smahal.r
0187616874e4a366b4ba006ded775e2d *data/germancities.rda
7c8f4dadefa6fd57a06a23067605dda0 *data/lalonde.rda
433defcdb5377aa4ebb28a0b41f492d7 *inst/gurobi_installation.txt
8b5ab702a3ca62c67934d34220c09ab6 *inst/symphony_installation.txt
a3432aa9ad196973c884751e3a7e0fb4 *man/absstddif.Rd
08570907d577d0641c435620fc8cb433 *man/bmatch.Rd
1199a77a4a4d518c5f6df584b1375562 *man/designmatch-package.Rd
9d510e34095ba20a26ae6ed0e3b7807a *man/distmat.Rd
1d2c644951010bde1258ae99212abd7c *man/ecdfplot.Rd
1c41cd06ff6f18f8fc27099f1ad042cd *man/finetab.Rd
3e98c15e211274459bbe5239f7342766 *man/germancities.Rd
d956e94f68ff0196119800ab2e887d19 *man/lalonde.Rd
6dc7cc1693bdd22f113ab55cb861e05b *man/loveplot.Rd
c8e615017243d912cf0722b811f1d158 *man/meantab.Rd
b308cf9ceba03eba24c4021b96bd4633 *man/nmatch.Rd
6ed7676149750f36a464eaa395912902 *man/pairsplot.Rd
17 changes: 17 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Default NAMESPACE created by R
# Remove the previous line if you edit this file

# Export all names
exportPattern(".")

# Import all packages listed as Imports or Depends
import(
lattice,
MASS,
Rglpk,
slam
)

importFrom("graphics", "abline", "dotchart", "legend", "par", "plot", "points", "segments")

importFrom("stats", "cov", "ecdf", "fisher.test", "mahalanobis", "quantile", "sd", "t.test", "var", "wilcox.test")
14 changes: 14 additions & 0 deletions R/absstddif.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
absstddif <-
function(X_mat, t_ind, std_dif) {
n_vrs = ncol(X_mat)
n_obs = nrow(X_mat)
mom_tols_out = NA
for (j in 1:n_vrs) {
yes_before = unlist(X_mat[t_ind == 1, j])
no_before = unlist(X_mat[t_ind == 0, j])
pooled_sd = sqrt((var(yes_before, na.rm = TRUE) + var(no_before, na.rm = TRUE))/2)
mom_tols_out = c(mom_tols_out, pooled_sd*std_dif)
}
mom_tols_out = mom_tols_out[-1]
mom_tols_out
}
8 changes: 8 additions & 0 deletions R/addcalip.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#! From Paul's Design of Obs. Studies (p. 251): "...adds a penalty to a distance matrix dmat for violations of the calip_size." "The default calip_size width is 0.2*sd(p). The magnitude of the penalty is penalty multiplied by the magnitude of the violation, where penalty is set to 1000 by default."
.addcalip = function (dist_mat, t_ind, calip_cov, calip_size, calip_penalty) {
sdp = sd(calip_cov)
penalty_mat = abs(outer(calip_cov[t_ind == 1], calip_cov[t_ind == 0], "-"))
penalty_mat = (penalty_mat>(calip_size*sdp))*calip_penalty
dist_mat = dist_mat+penalty_mat
dist_mat
}
Loading

0 comments on commit acb9808

Please sign in to comment.