R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("Matching-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('Matching') Loading required package: MASS Loading required package: rgenoud > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "GenMatch" > > ### * GenMatch > > flush(stderr()); flush(stdout()) > > ### Name: GenMatch > ### Title: Genetic Matching > ### Aliases: GenMatch > ### Keywords: nonparametric > > ### ** Examples > > set.seed(38913) > > data(lalonde) > attach(lalonde) > > #The covariates we want to match on > X = cbind(age, educ, black, hisp, married, nodegr, u74, u75, re75, re74); > > #The covariates we want to obtain balance on > BalanceMat <- cbind(age, educ, black, hisp, married, nodegr, u74, u75, re75, re74, + I(re74*re75)); > > #Let's call GenMatch() to find the optimal weight to give each > #covariate in 'X' so as we have achieved balance on the covariates in > #'BalanceMat'. This is only an example so we want GenMatch to be quick > #to the population size has been set to be only 15 via the 'pop.size' > #option. > genout <- GenMatch(Tr=treat, X=X, BalanceMatrix=BalanceMat, estimand="ATE", M=1, + pop.size=16, max.generations=10, wait.generations=1) Wed Jul 13 10:36:56 2005 Domains: 0 <= X1 <= 1000 0 <= X2 <= 1000 0 <= X3 <= 1000 0 <= X4 <= 1000 0 <= X5 <= 1000 0 <= X6 <= 1000 0 <= X7 <= 1000 0 <= X8 <= 1000 0 <= X9 <= 1000 0 <= X10 <= 1000 Data Type: Integer Operators (code number, name, population) (1) Cloning........................... 1 (2) Uniform Mutation.................. 2 (3) Boundary Mutation................. 2 (4) Non-Uniform Mutation.............. 2 (5) Polytope Crossover................ 2 (6) Multiple Point Simple Crossover... 2 (7) Whole Non-Uniform Mutation........ 2 (8) Heuristic Crossover............... 2 (9) Local-Minimum Crossover........... 0 SOFT Maximum Number of Generations: 10 Maximum Nonchanging Generations: 1 Population size : 16 Convergence Tolerance: 1.000000e-03 Not Using the BFGS Derivative Based Optimizer on the Best Individual Each Generation. Not Checking Gradients before Stopping Not Using Out of Bounds Individuals and Not Allowing Trespassing. Maximization Problem. The 2 best initial individuals are 206.00 302.00 838.00 510.00 893.00 632.00 818.00 526.00 6.00 698.00 fitness = 2.567638e-01 344.00 739.00 22.00 32.00 571.00 991.00 859.00 455.00 283.00 607.00 fitness = 1.172522e-01 The worst fit of the population is: 2.581610e-03 GENERATION: 0 (initializing the population) Fitness Value... 2.567638e-01 mean............ 7.625476e-02 var............. 3.279574e-03 skewness........ 1.664415e+00 kurtosis........ 6.574057e+00 #null........... 0 #unique......... 16, #Total UniqueCount: 16 var 1: best............ 2.060000e+02 mean............ 6.268125e+02 var............. 9.503290e+04 skewness........ -5.511707e-01 kurtosis........ 1.843472e+00 #null........... 0 var 2: best............ 3.020000e+02 mean............ 4.162500e+02 var............. 6.192194e+04 skewness........ 4.670942e-01 kurtosis........ 2.281076e+00 #null........... 0 var 3: best............ 8.380000e+02 mean............ 4.396250e+02 var............. 1.155416e+05 skewness........ 1.528582e-01 kurtosis........ 1.578137e+00 #null........... 0 var 4: best............ 5.100000e+02 mean............ 4.579375e+02 var............. 8.154181e+04 skewness........ -1.351110e-01 kurtosis........ 1.979543e+00 #null........... 0 var 5: best............ 8.930000e+02 mean............ 4.424375e+02 var............. 9.120700e+04 skewness........ 1.535581e-01 kurtosis........ 1.508704e+00 #null........... 0 var 6: best............ 6.320000e+02 mean............ 3.925625e+02 var............. 1.102524e+05 skewness........ 6.661808e-01 kurtosis........ 2.079611e+00 #null........... 0 var 7: best............ 8.180000e+02 mean............ 6.386250e+02 var............. 6.750986e+04 skewness........ -8.509431e-01 kurtosis........ 3.308351e+00 #null........... 0 var 8: best............ 5.260000e+02 mean............ 4.979375e+02 var............. 7.433056e+04 skewness........ -1.371364e-01 kurtosis........ 2.208029e+00 #null........... 0 var 9: best............ 6.000000e+00 mean............ 3.910625e+02 var............. 1.095801e+05 skewness........ 4.451317e-01 kurtosis........ 1.735663e+00 #null........... 0 var 10: best............ 6.980000e+02 mean............ 5.430625e+02 var............. 8.478406e+04 skewness........ -3.631209e-01 kurtosis........ 2.042624e+00 #null........... 0 GENERATION: 1 Fitness Value... 2.881902e-01 mean............ 1.315739e-01 var............. 6.186879e-03 skewness........ 5.098290e-01 kurtosis........ 2.492379e+00 #null........... 0 #unique......... 10, #Total UniqueCount: 26 var 1: best............ 3.750000e+02 mean............ 5.080625e+02 var............. 7.300818e+04 skewness........ 3.272636e-01 kurtosis........ 1.381320e+00 #null........... 0 var 2: best............ 3.020000e+02 mean............ 3.787500e+02 var............. 2.280919e+04 skewness........ -7.572099e-02 kurtosis........ 4.652586e+00 #null........... 0 var 3: best............ 7.430000e+02 mean............ 3.952500e+02 var............. 8.961369e+04 skewness........ 1.572897e-01 kurtosis........ 1.707594e+00 #null........... 0 var 4: best............ 5.100000e+02 mean............ 4.084375e+02 var............. 6.476850e+04 skewness........ -1.229315e-01 kurtosis........ 2.497112e+00 #null........... 0 var 5: best............ 8.930000e+02 mean............ 4.613125e+02 var............. 1.051966e+05 skewness........ 1.033365e-01 kurtosis........ 1.486083e+00 #null........... 0 var 6: best............ 6.320000e+02 mean............ 6.962500e+02 var............. 7.391744e+04 skewness........ -8.796351e-01 kurtosis........ 3.365509e+00 #null........... 0 var 7: best............ 8.180000e+02 mean............ 6.847500e+02 var............. 4.621069e+04 skewness........ -1.798135e+00 kurtosis........ 6.717848e+00 #null........... 0 var 8: best............ 5.260000e+02 mean............ 4.196875e+02 var............. 2.758184e+04 skewness........ -5.164574e-01 kurtosis........ 3.654564e+00 #null........... 0 var 9: best............ 2.010000e+02 mean............ 3.097500e+02 var............. 5.534906e+04 skewness........ 1.438928e-01 kurtosis........ 1.672004e+00 #null........... 0 var 10: best............ 6.980000e+02 mean............ 5.901250e+02 var............. 4.596798e+04 skewness........ -9.886956e-01 kurtosis........ 4.862972e+00 #null........... 0 GENERATION: 2 Fitness Value... 2.881902e-01 mean............ 1.669575e-01 var............. 1.038422e-02 skewness........ -1.791158e-01 kurtosis........ 1.315084e+00 #null........... 0 #unique......... 11, #Total UniqueCount: 37 var 1: best............ 3.750000e+02 mean............ 3.443750e+02 var............. 5.343036e+04 skewness........ 1.861404e+00 kurtosis........ 5.062459e+00 #null........... 0 var 2: best............ 3.020000e+02 mean............ 2.867500e+02 var............. 6.040562e+03 skewness........ -3.048513e+00 kurtosis........ 1.167369e+01 #null........... 0 var 3: best............ 7.430000e+02 mean............ 6.508125e+02 var............. 6.078078e+04 skewness........ -1.350751e+00 kurtosis........ 3.761032e+00 #null........... 0 var 4: best............ 5.100000e+02 mean............ 5.076250e+02 var............. 3.738023e+04 skewness........ -6.100315e-01 kurtosis........ 5.140662e+00 #null........... 0 var 5: best............ 8.930000e+02 mean............ 6.955625e+02 var............. 1.236759e+05 skewness........ -1.241848e+00 kurtosis........ 2.644744e+00 #null........... 0 var 6: best............ 6.320000e+02 mean............ 6.158750e+02 var............. 4.343036e+04 skewness........ -1.145561e+00 kurtosis........ 5.884059e+00 #null........... 0 var 7: best............ 8.180000e+02 mean............ 6.874375e+02 var............. 6.164525e+04 skewness........ -1.822472e+00 kurtosis........ 4.979053e+00 #null........... 0 var 8: best............ 5.260000e+02 mean............ 4.731250e+02 var............. 3.700523e+04 skewness........ -1.712998e-01 kurtosis........ 4.773374e+00 #null........... 0 var 9: best............ 2.010000e+02 mean............ 2.010625e+02 var............. 5.814031e+04 skewness........ 9.898370e-01 kurtosis........ 2.460948e+00 #null........... 0 var 10: best............ 6.980000e+02 mean............ 6.119375e+02 var............. 4.035631e+04 skewness........ -1.535656e+00 kurtosis........ 6.243561e+00 #null........... 0 Soft Generation Wait Limit Hit. No Improvement in 1 Generations Best Fit Found at Generation 1 Fit Value = 2.881902e-01 Parameters at the Solution (value, gradient): Not Obtaining Gradient Information X[ 1] : 3.750000e+02 G[ 1] : -1.000000e+00 X[ 2] : 3.020000e+02 G[ 2] : -1.000000e+00 X[ 3] : 7.430000e+02 G[ 3] : -1.000000e+00 X[ 4] : 5.100000e+02 G[ 4] : -1.000000e+00 X[ 5] : 8.930000e+02 G[ 5] : -1.000000e+00 X[ 6] : 6.320000e+02 G[ 6] : -1.000000e+00 X[ 7] : 8.180000e+02 G[ 7] : -1.000000e+00 X[ 8] : 5.260000e+02 G[ 8] : -1.000000e+00 X[ 9] : 2.010000e+02 G[ 9] : -1.000000e+00 X[10] : 6.980000e+02 G[10] : -1.000000e+00 Solution Found Generation 1 Number of Generations Run 2 Wed Jul 13 10:37:47 2005 Total run time : 0 hours 0 minutes and 51 seconds > > #The outcome variable > Y=re78/1000; > > # Now that GenMatch() has found the optimal weights, let's estimate > # our causal effect of interest using those weights > mout <- Match(Y=Y, Tr=treat, X=X, estimand="ATE", Weight.matrix=genout) > summary(mout) Estimate... 2.0050 SE......... 0.78048 T-stat..... 2.5689 p.val...... 0.010203 Original number of observations.............. 445 Original number of treated obs............... 185 Matched number of observations............... 445 Matched number of observations (unweighted). 600 > > # > #Let's determine if balance has actually been obtained on the variables of interest > # > mb <- MatchBalance(treat~age +educ+black+ hisp+ married+ nodegr+ u74+ u75+ + re75+ re74+ I(re74*re75), + match.out=mout, nboots=500, ks=TRUE, mv=FALSE) ***** (V1) age ***** before matching: mean treatment........ 25.816 mean control.......... 25.054 var ratio (Tr/Co)..... 1.0278 T-test p-value........ 0.26594 KS Bootstrap p-value.. 0.5 KS Naive p-value...... 0.7481 KS Statistic.......... 0.065177 after matching: mean treatment........ 25.094 mean control.......... 25.071 var ratio (Tr/Co)..... 0.9573 T-test p-value........ 0.89764 KS Bootstrap p-value.. 0.86 KS Naive p-value...... 0.96956 KS Statistic.......... 0.028333 ***** (V2) educ ***** before matching: mean treatment........ 10.346 mean control.......... 10.088 var ratio (Tr/Co)..... 1.5513 T-test p-value........ 0.15017 KS Bootstrap p-value.. 0.008 KS Naive p-value...... 0.062873 KS Statistic.......... 0.12651 after matching: mean treatment........ 10.193 mean control.......... 10.218 var ratio (Tr/Co)..... 1.0539 T-test p-value........ 0.53424 KS Bootstrap p-value.. 0.562 KS Naive p-value...... 0.92433 KS Statistic.......... 0.031667 ***** (V3) black ***** before matching: mean treatment........ 0.84324 mean control.......... 0.82692 var ratio (Tr/Co)..... 0.92503 T-test p-value........ 0.64736 after matching: mean treatment........ 0.8382 mean control.......... 0.84045 var ratio (Tr/Co)..... 1.0114 T-test p-value........ 0.65487 ***** (V4) hisp ***** before matching: mean treatment........ 0.05946 mean control.......... 0.10769 var ratio (Tr/Co)..... 0.58288 T-test p-value........ 0.064043 after matching: mean treatment........ 0.085393 mean control.......... 0.08764 var ratio (Tr/Co)..... 0.97676 T-test p-value........ 0.31731 ***** (V5) married ***** before matching: mean treatment........ 0.18919 mean control.......... 0.15385 var ratio (Tr/Co)..... 1.1802 T-test p-value........ 0.33425 after matching: mean treatment........ 0.16854 mean control.......... 0.16629 var ratio (Tr/Co)..... 1.0108 T-test p-value........ 0.31731 ***** (V6) nodegr ***** before matching: mean treatment........ 0.70811 mean control.......... 0.83462 var ratio (Tr/Co)..... 1.4998 T-test p-value........ 0.0020368 after matching: mean treatment........ 0.78202 mean control.......... 0.78202 var ratio (Tr/Co)..... 1 T-test p-value........ 1 ***** (V7) u74 ***** before matching: mean treatment........ 0.70811 mean control.......... 0.75 var ratio (Tr/Co)..... 1.1041 T-test p-value........ 0.33033 after matching: mean treatment........ 0.73258 mean control.......... 0.73258 var ratio (Tr/Co)..... 1 T-test p-value........ 1 ***** (V8) u75 ***** before matching: mean treatment........ 0.6 mean control.......... 0.68462 var ratio (Tr/Co)..... 1.1133 T-test p-value........ 0.06803 after matching: mean treatment........ 0.64719 mean control.......... 0.65169 var ratio (Tr/Co)..... 1.0059 T-test p-value........ 0.41430 ***** (V9) re75 ***** before matching: mean treatment........ 1532.1 mean control.......... 1266.9 var ratio (Tr/Co)..... 1.0763 T-test p-value........ 0.38527 KS Bootstrap p-value.. 0.034 KS Naive p-value...... 0.16449 KS Statistic.......... 0.10748 after matching: mean treatment........ 1260.3 mean control.......... 1296.9 var ratio (Tr/Co)..... 0.99928 T-test p-value........ 0.6774 KS Bootstrap p-value.. 0.756 KS Naive p-value...... 0.99675 KS Statistic.......... 0.023333 ***** (V10) re74 ***** before matching: mean treatment........ 2095.6 mean control.......... 2107.0 var ratio (Tr/Co)..... 0.7381 T-test p-value........ 0.98186 KS Bootstrap p-value.. 0.56 KS Naive p-value...... 0.97023 KS Statistic.......... 0.047089 after matching: mean treatment........ 2012.3 mean control.......... 2044.6 var ratio (Tr/Co)..... 0.87235 T-test p-value........ 0.72847 KS Bootstrap p-value.. 0.64 KS Naive p-value...... 0.99675 KS Statistic.......... 0.023333 ***** (V11) I(re74 * re75) ***** before matching: mean treatment........ 13118591 mean control.......... 14530303 var ratio (Tr/Co)..... 0.69439 T-test p-value........ 0.79058 KS Bootstrap p-value.. 0.278 KS Naive p-value...... 0.81575 KS Statistic.......... 0.061019 after matching: mean treatment........ 11898875 mean control.......... 13391539 var ratio (Tr/Co)..... 0.66972 T-test p-value........ 0.28819 KS Bootstrap p-value.. 0.988 KS Naive p-value...... 1 KS Statistic.......... 0.011667 > > > > > cleanEx(); ..nameEx <- "Match" > > ### * Match > > flush(stderr()); flush(stdout()) > > ### Name: Match > ### Title: Multivariate and Propensity Score Matching Estimator for Causal > ### Inference > ### Aliases: Match > ### Keywords: nonparametric > > ### ** Examples > > # > # Replication of Dehejia and Wahba psid3 model > # > # Dehejia, Rajeev and Sadek Wahba. 1999.``Causal Effects in Non-Experimental Studies: Re-Evaluating the > # Evaluation of Training Programs.''Journal of the American Statistical Association 94 (448): 1053-1062. > # > data(lalonde) > > # > # Estimate the propensity model > # > glm1 <- glm(treat~age + I(age^2) + educ + I(educ^2) + black + + hisp + married + nodegr + re74 + I(re74^2) + re75 + I(re75^2) + + u74 + u75, family=binomial, data=lalonde) > > # > #save data objects > # > X <- glm1$fitted > Y <- lalonde$re78 > Tr <- lalonde$treat > > # > # one-to-one matching with replacement (the "M=1" option). > # Estimating the treatment effect on the treated (the "estimand" option which defaults to 0). > # > rr <- Match(Y=Y,Tr=Tr,X=X,M=1); > summary(rr) Estimate... 2153.3 SE......... 825.4 T-stat..... 2.6088 p.val...... 0.0090858 Original number of observations.............. 445 Original number of treated obs............... 185 Matched number of observations............... 185 Matched number of observations (unweighted). 346 > > # > # Let's check for balance > # 'nboots' and 'nmc' are set to small values in the interest of speed. > # Please increase to at least 500 each for publication quality p-values. > mb <- MatchBalance(treat~age + I(age^2) + educ + I(educ^2) + black + + hisp + married + nodegr + re74 + I(re74^2) + re75 + I(re75^2) + + u74 + u75, data=lalonde, match.out=rr, nboots=10, nmc=10) ***** (V1) age ***** before matching: mean treatment........ 25.816 mean control.......... 25.054 var ratio (Tr/Co)..... 1.0278 T-test p-value........ 0.26594 KS Bootstrap p-value.. 0.7 KS Naive p-value...... 0.7481 KS Statistic.......... 0.065177 after matching: mean treatment........ 25.816 mean control.......... 25.006 var ratio (Tr/Co)..... 1.0662 T-test p-value........ 0.23472 KS Bootstrap p-value.. 0.7 KS Naive p-value...... 0.7978 KS Statistic.......... 0.049133 ***** (V2) I(age^2) ***** before matching: mean treatment........ 717.4 mean control.......... 677.32 var ratio (Tr/Co)..... 1.0115 T-test p-value........ 0.33337 KS Bootstrap p-value.. 0.7 KS Naive p-value...... 0.7481 KS Statistic.......... 0.065177 after matching: mean treatment........ 717.4 mean control.......... 673.08 var ratio (Tr/Co)..... 0.91516 T-test p-value........ 0.31819 KS Bootstrap p-value.. 0.7 KS Naive p-value...... 0.7978 KS Statistic.......... 0.049133 ***** (V3) educ ***** before matching: mean treatment........ 10.346 mean control.......... 10.088 var ratio (Tr/Co)..... 1.5513 T-test p-value........ 0.15017 KS Bootstrap p-value.. < 2.22e-16 KS Naive p-value...... 0.062873 KS Statistic.......... 0.12651 after matching: mean treatment........ 10.346 mean control.......... 10.480 var ratio (Tr/Co)..... 1.1917 T-test p-value........ 0.45021 KS Bootstrap p-value.. 0.3 KS Naive p-value...... 0.73726 KS Statistic.......... 0.052023 ***** (V4) I(educ^2) ***** before matching: mean treatment........ 111.06 mean control.......... 104.37 var ratio (Tr/Co)..... 1.6625 T-test p-value........ 0.053676 KS Bootstrap p-value.. < 2.22e-16 KS Naive p-value...... 0.062873 KS Statistic.......... 0.12651 after matching: mean treatment........ 111.06 mean control.......... 113.21 var ratio (Tr/Co)..... 1.2716 T-test p-value........ 0.51046 KS Bootstrap p-value.. 0.3 KS Naive p-value...... 0.73726 KS Statistic.......... 0.052023 ***** (V5) black ***** before matching: mean treatment........ 0.84324 mean control.......... 0.82692 var ratio (Tr/Co)..... 0.92503 T-test p-value........ 0.64736 after matching: mean treatment........ 0.84324 mean control.......... 0.85946 var ratio (Tr/Co)..... 1.0943 T-test p-value........ 0.57783 ***** (V6) hisp ***** before matching: mean treatment........ 0.05946 mean control.......... 0.10769 var ratio (Tr/Co)..... 0.58288 T-test p-value........ 0.064043 after matching: mean treatment........ 0.05946 mean control.......... 0.048649 var ratio (Tr/Co)..... 1.2083 T-test p-value........ 0.41443 ***** (V7) married ***** before matching: mean treatment........ 0.18919 mean control.......... 0.15385 var ratio (Tr/Co)..... 1.1802 T-test p-value........ 0.33425 after matching: mean treatment........ 0.18919 mean control.......... 0.16667 var ratio (Tr/Co)..... 1.1045 T-test p-value........ 0.46741 ***** (V8) nodegr ***** before matching: mean treatment........ 0.70811 mean control.......... 0.83462 var ratio (Tr/Co)..... 1.4998 T-test p-value........ 0.0020368 after matching: mean treatment........ 0.70811 mean control.......... 0.69189 var ratio (Tr/Co)..... 0.96957 T-test p-value........ 0.49161 ***** (V9) re74 ***** before matching: mean treatment........ 2095.6 mean control.......... 2107.0 var ratio (Tr/Co)..... 0.7381 T-test p-value........ 0.98186 KS Bootstrap p-value.. 0.6 KS Naive p-value...... 0.97023 KS Statistic.......... 0.047089 after matching: mean treatment........ 2095.6 mean control.......... 1624.3 var ratio (Tr/Co)..... 2.2663 T-test p-value........ 0.22745 KS Bootstrap p-value.. 0.3 KS Naive p-value...... 0.8532 KS Statistic.......... 0.046243 ***** (V10) I(re74^2) ***** before matching: mean treatment........ 28141434 mean control.......... 36667413 var ratio (Tr/Co)..... 0.50382 T-test p-value........ 0.51322 KS Bootstrap p-value.. 0.6 KS Naive p-value...... 0.97023 KS Statistic.......... 0.047089 after matching: mean treatment........ 28141434 mean control.......... 13117852 var ratio (Tr/Co)..... 7.9006 T-test p-value........ 0.08604 KS Bootstrap p-value.. 0.3 KS Naive p-value...... 0.8532 KS Statistic.......... 0.046243 ***** (V11) re75 ***** before matching: mean treatment........ 1532.1 mean control.......... 1266.9 var ratio (Tr/Co)..... 1.0763 T-test p-value........ 0.38527 KS Bootstrap p-value.. < 2.22e-16 KS Naive p-value...... 0.16449 KS Statistic.......... 0.10748 after matching: mean treatment........ 1532.1 mean control.......... 1297.6 var ratio (Tr/Co)..... 1.4291 T-test p-value........ 0.33324 KS Bootstrap p-value.. < 2.22e-16 KS Naive p-value...... 0.60988 KS Statistic.......... 0.057803 ***** (V12) I(re75^2) ***** before matching: mean treatment........ 12654753 mean control.......... 11196530 var ratio (Tr/Co)..... 1.4609 T-test p-value........ 0.77178 KS Bootstrap p-value.. < 2.22e-16 KS Naive p-value...... 0.16449 KS Statistic.......... 0.10748 after matching: mean treatment........ 12654753 mean control.......... 8896263 var ratio (Tr/Co)..... 3.559 T-test p-value........ 0.37741 KS Bootstrap p-value.. < 2.22e-16 KS Naive p-value...... 0.60988 KS Statistic.......... 0.057803 ***** (V13) u74 ***** before matching: mean treatment........ 0.70811 mean control.......... 0.75 var ratio (Tr/Co)..... 1.1041 T-test p-value........ 0.33033 after matching: mean treatment........ 0.70811 mean control.......... 0.68458 var ratio (Tr/Co)..... 0.95721 T-test p-value........ 0.52298 ***** (V14) u75 ***** before matching: mean treatment........ 0.6 mean control.......... 0.68462 var ratio (Tr/Co)..... 1.1133 T-test p-value........ 0.06803 after matching: mean treatment........ 0.6 mean control.......... 0.62072 var ratio (Tr/Co)..... 1.0194 T-test p-value........ 0.46507 > > > > cleanEx(); ..nameEx <- "MatchBalance" > > ### * MatchBalance > > flush(stderr()); flush(stdout()) > > ### Name: MatchBalance > ### Title: Tests for Univariate and Multivariate Balance > ### Aliases: MatchBalance > ### Keywords: nonparametric htest > > ### ** Examples > > # > # Replication of Dehejia and Wahba psid3 model > # > # Dehejia, Rajeev and Sadek Wahba. 1999.``Causal Effects in Non-Experimental Studies: Re-Evaluating the > # Evaluation of Training Programs.''Journal of the American Statistical Association 94 (448): 1053-1062. > # > data(lalonde) > > # > # Estimate the propensity model > # > glm1 <- glm(treat~age + I(age^2) + educ + I(educ^2) + black + + hisp + married + nodegr + re74 + I(re74^2) + re75 + I(re75^2) + + u74 + u75, family=binomial, data=lalonde) > > # > #save data objects > # > X <- glm1$fitted > Y <- lalonde$re78 > Tr <- lalonde$treat > > # > # one-to-one matching with replacement (the "M=1" option). > # Estimating the treatment effect on the treated (the "estimand" option which defaults to 0). > # > rr <- Match(Y=Y,Tr=Tr,X=X,M=1); > > #Let's summarize the output > summary(rr) Estimate... 2153.3 SE......... 825.4 T-stat..... 2.6088 p.val...... 0.0090858 Original number of observations.............. 445 Original number of treated obs............... 185 Matched number of observations............... 185 Matched number of observations (unweighted). 346 > > # > # Let's check for balance > # 'nboots' and 'nmc' are set to small values in the interest of speed. > # Please increase to at least 500 each for publication quality p-values. > mb <- MatchBalance(treat~age + I(age^2) + educ + I(educ^2) + black + + hisp + married + nodegr + re74 + I(re74^2) + re75 + I(re75^2) + + u74 + u75, data=lalonde, match.out=rr, nboots=10, nmc=10) ***** (V1) age ***** before matching: mean treatment........ 25.816 mean control.......... 25.054 var ratio (Tr/Co)..... 1.0278 T-test p-value........ 0.26594 KS Bootstrap p-value.. 0.7 KS Naive p-value...... 0.7481 KS Statistic.......... 0.065177 after matching: mean treatment........ 25.816 mean control.......... 25.006 var ratio (Tr/Co)..... 1.0662 T-test p-value........ 0.23472 KS Bootstrap p-value.. 0.7 KS Naive p-value...... 0.7978 KS Statistic.......... 0.049133 ***** (V2) I(age^2) ***** before matching: mean treatment........ 717.4 mean control.......... 677.32 var ratio (Tr/Co)..... 1.0115 T-test p-value........ 0.33337 KS Bootstrap p-value.. 0.7 KS Naive p-value...... 0.7481 KS Statistic.......... 0.065177 after matching: mean treatment........ 717.4 mean control.......... 673.08 var ratio (Tr/Co)..... 0.91516 T-test p-value........ 0.31819 KS Bootstrap p-value.. 0.7 KS Naive p-value...... 0.7978 KS Statistic.......... 0.049133 ***** (V3) educ ***** before matching: mean treatment........ 10.346 mean control.......... 10.088 var ratio (Tr/Co)..... 1.5513 T-test p-value........ 0.15017 KS Bootstrap p-value.. < 2.22e-16 KS Naive p-value...... 0.062873 KS Statistic.......... 0.12651 after matching: mean treatment........ 10.346 mean control.......... 10.480 var ratio (Tr/Co)..... 1.1917 T-test p-value........ 0.45021 KS Bootstrap p-value.. 0.3 KS Naive p-value...... 0.73726 KS Statistic.......... 0.052023 ***** (V4) I(educ^2) ***** before matching: mean treatment........ 111.06 mean control.......... 104.37 var ratio (Tr/Co)..... 1.6625 T-test p-value........ 0.053676 KS Bootstrap p-value.. < 2.22e-16 KS Naive p-value...... 0.062873 KS Statistic.......... 0.12651 after matching: mean treatment........ 111.06 mean control.......... 113.21 var ratio (Tr/Co)..... 1.2716 T-test p-value........ 0.51046 KS Bootstrap p-value.. 0.3 KS Naive p-value...... 0.73726 KS Statistic.......... 0.052023 ***** (V5) black ***** before matching: mean treatment........ 0.84324 mean control.......... 0.82692 var ratio (Tr/Co)..... 0.92503 T-test p-value........ 0.64736 after matching: mean treatment........ 0.84324 mean control.......... 0.85946 var ratio (Tr/Co)..... 1.0943 T-test p-value........ 0.57783 ***** (V6) hisp ***** before matching: mean treatment........ 0.05946 mean control.......... 0.10769 var ratio (Tr/Co)..... 0.58288 T-test p-value........ 0.064043 after matching: mean treatment........ 0.05946 mean control.......... 0.048649 var ratio (Tr/Co)..... 1.2083 T-test p-value........ 0.41443 ***** (V7) married ***** before matching: mean treatment........ 0.18919 mean control.......... 0.15385 var ratio (Tr/Co)..... 1.1802 T-test p-value........ 0.33425 after matching: mean treatment........ 0.18919 mean control.......... 0.16667 var ratio (Tr/Co)..... 1.1045 T-test p-value........ 0.46741 ***** (V8) nodegr ***** before matching: mean treatment........ 0.70811 mean control.......... 0.83462 var ratio (Tr/Co)..... 1.4998 T-test p-value........ 0.0020368 after matching: mean treatment........ 0.70811 mean control.......... 0.69189 var ratio (Tr/Co)..... 0.96957 T-test p-value........ 0.49161 ***** (V9) re74 ***** before matching: mean treatment........ 2095.6 mean control.......... 2107.0 var ratio (Tr/Co)..... 0.7381 T-test p-value........ 0.98186 KS Bootstrap p-value.. 0.6 KS Naive p-value...... 0.97023 KS Statistic.......... 0.047089 after matching: mean treatment........ 2095.6 mean control.......... 1624.3 var ratio (Tr/Co)..... 2.2663 T-test p-value........ 0.22745 KS Bootstrap p-value.. 0.3 KS Naive p-value...... 0.8532 KS Statistic.......... 0.046243 ***** (V10) I(re74^2) ***** before matching: mean treatment........ 28141434 mean control.......... 36667413 var ratio (Tr/Co)..... 0.50382 T-test p-value........ 0.51322 KS Bootstrap p-value.. 0.6 KS Naive p-value...... 0.97023 KS Statistic.......... 0.047089 after matching: mean treatment........ 28141434 mean control.......... 13117852 var ratio (Tr/Co)..... 7.9006 T-test p-value........ 0.08604 KS Bootstrap p-value.. 0.3 KS Naive p-value...... 0.8532 KS Statistic.......... 0.046243 ***** (V11) re75 ***** before matching: mean treatment........ 1532.1 mean control.......... 1266.9 var ratio (Tr/Co)..... 1.0763 T-test p-value........ 0.38527 KS Bootstrap p-value.. < 2.22e-16 KS Naive p-value...... 0.16449 KS Statistic.......... 0.10748 after matching: mean treatment........ 1532.1 mean control.......... 1297.6 var ratio (Tr/Co)..... 1.4291 T-test p-value........ 0.33324 KS Bootstrap p-value.. < 2.22e-16 KS Naive p-value...... 0.60988 KS Statistic.......... 0.057803 ***** (V12) I(re75^2) ***** before matching: mean treatment........ 12654753 mean control.......... 11196530 var ratio (Tr/Co)..... 1.4609 T-test p-value........ 0.77178 KS Bootstrap p-value.. < 2.22e-16 KS Naive p-value...... 0.16449 KS Statistic.......... 0.10748 after matching: mean treatment........ 12654753 mean control.......... 8896263 var ratio (Tr/Co)..... 3.559 T-test p-value........ 0.37741 KS Bootstrap p-value.. < 2.22e-16 KS Naive p-value...... 0.60988 KS Statistic.......... 0.057803 ***** (V13) u74 ***** before matching: mean treatment........ 0.70811 mean control.......... 0.75 var ratio (Tr/Co)..... 1.1041 T-test p-value........ 0.33033 after matching: mean treatment........ 0.70811 mean control.......... 0.68458 var ratio (Tr/Co)..... 0.95721 T-test p-value........ 0.52298 ***** (V14) u75 ***** before matching: mean treatment........ 0.6 mean control.......... 0.68462 var ratio (Tr/Co)..... 1.1133 T-test p-value........ 0.06803 after matching: mean treatment........ 0.6 mean control.......... 0.62072 var ratio (Tr/Co)..... 1.0194 T-test p-value........ 0.46507 > > > > cleanEx(); ..nameEx <- "balanceMV" > > ### * balanceMV > > flush(stderr()); flush(stdout()) > > ### Name: balanceMV > ### Title: Multivariate Tests for Balance > ### Aliases: balanceMV > ### Keywords: htest > > ### ** Examples > > data(lalonde) > > # > #direct matching on some variable > # > X <- cbind(lalonde$re74,lalonde$re75,lalonde$age,lalonde$hisp,lalonde$black) > Y <- lalonde$re78 > Tr <- lalonde$treat > > rr <- Match(Y=Y,Tr=Tr,X=X,M=1) > > #multivariate test for balance > # 'nboots' and 'nmc' are set to small values in the interest of speed. > # Please increase to at least 500 each for publication quality p-values. > ks <- balanceMV(treat~ age + I(age^2) + educ + I(educ^2) + black + + hisp + married + nodegr + re74 + I(re74^2) + re75 + I(re75^2) + + u74 + u75, data=lalonde, match.out=rr, nboots=10, nmc=10) > summary(ks) Before Matching: Mean Probability of Treatment for Treated Observations: 0.44676 Mean Probability of Treatment for Control Observations: 0.39365 After Matching: Mean Probability of Treatment for Treated Observations: 0.51537 Mean Probability of Treatment for Control Observations: 0.48463 Kolmogorov-Smirnov Test for Balance Before Matching: statistic: 0.22443 p-val: 3.7341e-05 bootstrap p-value: < 2.22e-16 Kolmogorov-Smirnov Test for Balance After Matching: statistic: 0.18331 p-val: 7.6128e-13 bootstrap p-value: < 2.22e-16 Chi-Square Deviance Test for Balance Before Matching: statistic: 24.184 p-val: 0.043533 df: 14 Chi-Square Deviance Test for Balance After Matching: statistic: 11.856 p-val: 0.7902 df: 14 > > > > cleanEx(); ..nameEx <- "balanceUV" > > ### * balanceUV > > flush(stderr()); flush(stdout()) > > ### Name: balanceUV > ### Title: Univariate Balance Tests > ### Aliases: balanceUV > ### Keywords: univar > > ### ** Examples > > data(lalonde) > attach(lalonde) > > foo <- balanceUV(re75[treat==1],re75[treat!=1]) > summary(foo) mean treatment........ 1532.1 mean control.......... 1266.9 var ratio (Tr/Co)..... 1.0763 T-test p-value........ 0.38527 > > > > > cleanEx(); ..nameEx <- "ks.boot" > > ### * ks.boot > > flush(stderr()); flush(stdout()) > > ### Name: ks.boot > ### Title: Bootstrap Kolmogorov-Smirnov > ### Aliases: ks.boot > ### Keywords: htest > > ### ** Examples > > # > # Replication of Dehejia and Wahba psid3 model > # > # Dehejia, Rajeev and Sadek Wahba. 1999.``Causal Effects in Non-Experimental Studies: Re-Evaluating the > # Evaluation of Training Programs.''Journal of the American Statistical Association 94 (448): 1053-1062. > # > data(lalonde) > > # > # Estimate the propensity model > # > glm1 <- glm(treat~age + I(age^2) + educ + I(educ^2) + black + + hisp + married + nodegr + re74 + I(re74^2) + re75 + I(re75^2) + + u74 + u75, family=binomial, data=lalonde) > > # > #save data objects > # > X <- glm1$fitted > Y <- lalonde$re78 > Tr <- lalonde$treat > > # > # one-to-one matching with replacement (the "M=1" option). > # Estimating the treatment effect on the treated (the "estimand" option which defaults to 0). > # > rr <- Match(Y=Y,Tr=Tr,X=X,M=1); > summary(rr) Estimate... 2153.3 SE......... 825.4 T-stat..... 2.6088 p.val...... 0.0090858 Original number of observations.............. 445 Original number of treated obs............... 185 Matched number of observations............... 185 Matched number of observations (unweighted). 346 > > # > # Do we have balance on 1975 income after matching? > # > ks <- ks.boot(lalonde$re75[rr$index.treated], lalonde$re75[rr$index.control], nboots=500) > summary(ks) Bootstrap p-value: 0.124 Naive p-value: 0.60988 Full Sample Statistic: 0.057803 > > > > ### *