# reconstructing matched data set from R's matching package

I am using Mebane and Sekhon's Matching package for R, and my goal is to make casual inferences about a proportion and a mean. The proportion is straight forward, but the mean has missing values, which Match does not accept. My approach is trying to get access to the matched records through the row indexes, but the results are not quite right.

Example code:

require(Matching)
demo(DehejiaWahba)
# mean before matching
by(lalonde$u75, lalonde$treat, mean)
# mean after matching
matched <- rbind(lalonde[rr$index.treated,], lalonde[rr$index.control,])
by(matched$u75, matched$treat, mean)


The output of the demo shows the matched means for u75 are 0.6 and 0.62072:

***** (V14) u75 *****
Before Matching           After Matching
mean treatment........        0.6                       0.6
mean control..........    0.68462                   0.62072


However, the reconstructed data set has different means:

    matched$treat: 0 [1] 0.7861272 --------------------------------------------------------------------------------- matched$treat: 1
[1] 0.7543353


See that matched has 692 observations. Now take a look at summary(rr). You'll see that there are 346 unweighted matched pairs--that is, several of the treated observations were matched to several control observations. You can see using summary(rr$weights) that there is at least one treatment observation that is matched to 12 controls. Without using the weights in your last line, you're getting the wrong answer. As Charlie suggested, using the weights does give means that "match Match." weighted.mean(lalonde[rr$index.control,]$u75, rr$weights)
weighted.mean(lalonde[rr$index.treated,]$u75, rr\$weights)