I've got a dataset where a treatment $W$ has been applied to units $i$ within clusters $c$. $W$ is constant within each cluster. As a component of an algoritm that I'm implementing (which was developed for non-clustered data), I need to match each unit $i$ with it's match $m_i$.
For example, think of schools that receive new books versus those that don't. I want to match students from treated schools with their nearest neighbor in schools that were in the control group.
I've got a solution in mind, but I'm looking for a canonical solution/standard practice/state of the art. Ideally something that has already been programmed in R.
I was first thinking of matching schools with each other based on minimizing a Mahalanobis distance between them, based on mathods from this thread. This would only be on cluster-level covariates (including averages of individual-level data). Then, cluster matches in hand, I'd match individuals within a treatment cluster with their counterparts in a control cluster, based on individually-varying data.
The above strikes me as logical, but I'd rather not re-invent the wheel, and I haven't done much matching before. Is there a standard practice for problems of this sort? Note I need the (nearest neighbor) matches themselves, not just an estimate of an average treatment effect.