So following the example from the Matching package and in particular the GenMatch example
Link to package here
Following the example in GenMatch
library(Matching)
data(lalonde)
attach(lalonde)
X = cbind(age, educ, black, hisp, married, nodegr, u74, u75, re75, re74)
BalanceMat <- cbind(age, educ, black, hisp, married, nodegr, u74, u75, re75, re74,
I(re74*re75))
genout <- GenMatch(Tr=treat, X=X, BalanceMatrix=BalanceMat, estimand="ATE", M=1,
pop.size=16, max.generations=10, wait.generations=1)
genout$matches
genout$ecaliper
Y=re78/1000
mout <- Match(Y=Y, Tr=treat, X=X, Weight.matrix=genout)
summary(mout)
We see 185 treated observation are paired with 270 non-treatment observation. Now we want to relax this to allow for more flexible pairing on the age criteria.
We can generate a table with the teatment cases and their age on the left and the control case and age on the right by:
pairs <- data.frame(mout$index.treated, lalonde$age[mout$index.treated], mout$index.control, lalonde$age[mout$index.control])
Now using the caliper
function of the Match()
we should be able to generate a more relaxed match.
We see that sd(lalonde$age)
gives us a SD of 7 years for our table, so lets try and match for this limit. Would one simply
mout2 <- Match(Y=Y, Tr=treat, X=X, Weight.matrix=genout, caliper=c(1,0,0,0,0,0,0,0,0,0))
summary(mout2)
it appear not because less Matched number of observations
have occured in mout2
than mout1
.
So where have I gone wrong? The values of zero must be included in caliper or else an error is returned if they are blank