Iematch

Revision as of 11:46, 5 April 2018 by Admin (talk | contribs)
Jump to: navigation, search

iematch is used to match observations in one group to observations in another group based on a single variable. This single variable could be a p-score but could be any continuous variable.

This article is means to describe use cases, work flow and the reasoning used when developing the commands. For instructions on how to use the command specifically in Stata and for a complete list of the options available, see the help files by typing help iematch in Stata. This command is a part of the package ietoolkit, to install all the commands in this package including this command, type ssc install ietoolkit in Stata.

Intended use cases

Important Disclaimer: There is no test in iematch that confirms the validity of a match from an economic theory aspect. This command only performs the computational task of matching one set of observations to observations in another set based on the difference in the matching variable. You must perform the tests to the results of iematch that you find appropriate in your specific case. Our understanding is that there is no consensus on a general test for this, but if you have suggestions for tests that we should implement and return statistics on, please let us know. Contact information on our GitHub page

A very common use case for matching in impact evaluations is propensity score matching (PSM). There are several user written commands developed specifically for propensity score matching that includes all steps required and in most cases you want to use one of those commands for PSM analysis. However, sometimes your PSM analysis might require a special step that none of the off-the-shelf PSM commands offer, and you will have to set up each step of the PSM analysis yourself. In such a case iematch can do the matching step for you.

iematch can also be used to sample controls to treatment observations using baseline data. This is sometimes done when the controls to the treatment observation was not selected at the time of random treatment assignment and needs to be identified in a larger population. There are many factors that can make this type of pairing invalid despite the matching result provided by iematch being mathematically correct. You always need to use econometrical reasoning for the validity of this technique in your case given the data you have available.

Instructions

These instructions are meant to help you understand how to use the command. For technical instructions on how to implement the command in Stata see the help files by typing help iematch in Stata.

Replicable results

If all values in the variable used for the matching are unique, then the results will always be the same no matter sort order of the data set as long as the values does not change. However, it is not as straightforward if several observations have the same value in the matching variable. The matching algorithm used by iematch must have a unique sort order so a random variable is generated to guarantee this. This random variable has no effect on observations with unique values in the matching variable, so if all values are unique there is no need to take this into consideration.

However, if there are duplicates in the matching varaible then the random variable will decide which observation that will be matched first. For balance purposes it should make no difference which observation with identical that is matched first, but for replicablility this matters. Therefore, iematch throws and error if it detects duplicates in the matching variable, unless the solution described in next paragraph is used.

The solution to getting this duplicate values is to set a seed before you run iematch and then use the option seedok. After setting a seed the random values assigned will be the same each time which will generate the same result each time iematch is used, even if some observations have duplicate values. The option seedok can be used to suppress the error matching without setting the seed if replicable results does not matter or if you want a new random selection each time you use iematch, but in most cases in impact evaluations, this is probably not the best way to do it.

One-to-One and Many-to-One

iematch can do both a one-to-one match and a many-to-one match. iematch call one group base observations and the other group target observations. The required option grpdummy() indicates which type of observation each observations is. 1 indicates base observation and 0 indicates target observation. A missing value excludes an observation from the matching.

In a one-to-one match the result will be matched pairs of exactly one base observation and one target observation in each pair. In a many-to-one match the results will be matched groups that will have exactly one target observation but can have one or more base observations.

You need to have more target observations than base observations in a one-to-one match. If you have more base observations and want to do one-to-one match you need to switch which group of observations that has value 1 and which has value 0 in the group dummy and then you can run your match.

You can only match many base observations to a single target observation, but you can solve this by switching which group of observations that has value 1 and which has value 0 in the group dummy and then you can run your match. You can restrict how many base observations that is allowed to match with a single target observation using the option maxmatch().

Maximum difference in a match

One method to improve the validity of a matched result is to only allow matches where the difference between the matched observation is no more than a value specified in maxdiff(). You could of course drop those values manually after running iematch, but using maxdiff() often helps the algorithm to finish faster if you have very large data sets.

Reasoning used during development

iematch does not identify globally optimal matching results as it uses greedy matching. In optimal matching the sum of all absolute differences between matched pairs is minimized using optimization. In greedy matching the sum of differences is not regarded, the matching starts by matching the best pair, then the second best pair etc. until all valid pairs are found. An optimal match might split up a very good match and a decent match to create two medium good matches. Optimal matches are much more complex and require more computational power, and it often the results are only marginally better and does not seem to make a difference to overall balance (Gu and Rosenbaum 1993).

Back to Parent

This article is part of the topic ietoolkit

References

  • Gu S, Rosenbaum PR. Comparison of multivariate matching methods: structure, distances, and algorithms. J Comput Graph Stat 1993;2:405–20.