markmfredrickson/optmatch — Issue #9: Bug: in master branch, Ops.optmatch.dlist dies unnecessarily for unstratified problems
Author: benthestatistician
Created: 2012-03-01 23:06:08+00:00
State: open

Applied to matching problems without subclassification prior to matching, mdist.glm and mdist.function create optmatch.dlist objects with different names, "m" for the mdist.glm object and "m1" for the mdist.function object. This in turn causes Ops.optmatch.dlist to bomb when I try to combine distances created in the two ways, e.g. using one as the basis for a caliper to be added on to the other. So I get errors like the following:

> ps.nnm$tx.fm <- fullmatch( nnstuff$ppty.dist/(nnstuff$ppty.dist<=nnstuff$tx.psnndist) )
Error in Ops.optmatch.dlist(nnstuff$ppty.dist, nnstuff$tx.psnndist) :
dlist names don't match
> names(nnstuff$tx.psnndist)
[1] "m1"
> names(nnstuff$ppty.dist)
[1] "m"

There are various ways this might be avoided: tweak mdist.function so that it gives a result with name "m" rather than "m1"; make Ops.optmatch.dlist try a little harder to reconcile the apparent incompatibility before giving up, etc.

Of course we're planning to leave all this architecture behind soon with the update to s4 classes, but I think it would be useful to have a new release first based on the hard-limits branch and incorporating this small fix.

I'd be willing to take on the Ops.optmatch.dlist tweak, but my sense is that the first step should be to look into modifying mdist.function? If you agree, Mark, I'll let you have the first stab at this.

Here's an example mdist.function call:

mdist(function(treatments, controls) matrix(treatments$nn,nrow(treatments), nrow(controls)),
structure.fmla= treat ~1,
data=mydata)