# Propensity score matching with panel data

I have a longitudinal data set of individuals and some of them were subject to a treatment and others were not. All individuals are in the sample from birth until age 18 and the treatment happens at some age in between that range. The age of the treatment may differ across cases. Using propensity score matching I would like to match treated and control units in pairs with exact matching on the year of birth such that I can track each pair from their birthyear until age 18. All in all there are about 150 treated and 4000 untreated individuals. After the matching the idea is to use a difference-in-differences strategy to estimate the effect of the treatment.

The problem I face at the moment is to do the matching with panel data. I am using Stata's psmatch2 command and I match on household and individual characteristics using propensity score matching. In general with panel data there will be different optimal matches at each age. As an example: if A is treated, B and C are controls, and all of them were born in 1980, then A and B may be matched in 1980 at age 0 whilst A and C are matched in 1981 at age 1 and so on. Also A may be matched with its own pre-treatment values from previous years.

To get around this issue, I took the average of all time-varying variables such that the matching can identify individuals who are on average the most similar over the duration of the sample and I do the matching separately for each age group 0 to 18. Unfortunately this still matches a different control unit to each treated unit per age group.

If someone could direct me towards a method to do pairwise matching with panel data in Stata this would be very much appreciated.

You basically have to create a wide format dataset with the all the characteristics that are relevant for the matching procedure, perform the matching on this cross-sectional dataset, and then use the ID to identify the matched pair in the panel dataset. Here are some more details:

1. Use reshape to create a wide format dataset. Format the pre-treatment variables in the way you want to use them in the matching procedure. You can just take the average of your variables if you have multiple observations for one individual but you can also come up with other ways (you can also keep multiple observations of the same variables such as health1, health2 and use all of them in the matching). The goal is to have a dataset with one observation per individual.

2. Using this dataset, perform the matching procedure with psmatch2.

3. Merge the information about the matched cases with the original dataset. Drop cases that are not matched etc. I am not sure about the details here because I don't really know stata and psmatch2 but I think you get the idea.

Using these steps, you can match cases based on all pre-treatment information and you only have one match per treatment unit.

• I really don't know why this post was down-voted because this answer actually helps. I will vote it up again. Thanks greg! – Andy Jun 12 '13 at 9:57

There's no way to do that in Stata or any other software that I am aware of.

If you're trying to patch up a biased matching estimator with panel data techniques, here's one approach that may work. If you can assume that matching takes care of some, but not all of the selection bias, but that the bias largely remains constant over time, you can remove the time-invariant portion of the bias by constructing separate matching estimates in each period and taking the difference.

Let $t$ be the pre-treatment period and $t'$ be the post. If the untreated state outcome $Y_0$ satisfies

$$E[Y_{0t} \vert X, D=1]-E[Y_{0t} \vert X, D=0]=E[Y_{0t'} \vert X, D=1]-E[Y_{0t'} \vert X, D=0]=Bias,$$ then if $\Delta^{M}_{t'}=\Delta^{TT}+Bias$ and $\Delta^{M}_{t}=Bias$, you can get $\Delta^{M}_{t'}-\Delta^{M}_{t}=\Delta^{TT}$

Heckman, Ichimura, Smith and Todd 1998 Econometrica and Eichler and Lechner 2002 Labour Economics papers are examples of this approach. On the other hand, 150 treated observations may not be enough for this approach to work.

• It should be possible to match individuals in pairs for panel data because these two papers (paper1, paper2) do it as well. Unfortunately the authors don't exactly state how they did it. The idea you are describing with Heckman et al (1998) is exactly the reason for using Diff-in-Diff after the pairwise matching. – Andy Jun 11 '13 at 5:36
• It's not clear to me that they're doing panel matching, but you're right that the procedures are vague. The authors did write pscore, which signals a certain willingness to help others. Perhaps an email to them will clarify things. Do report what they say. It's an important question. – Dimitriy V. Masterov Jun 11 '13 at 14:54

Steps:

1. As it has been mentioned in detail by Greg, you can use a cross-sectional dataset, either on pre-treatment means or on a sepecific pre-treatment period to generate the matching.

2. Using the whole panel you assign indicator variables for
a. treatedIndividual
b. treatedPeriod, the latter is equal to zero as soon as the treatment occurs for the treatedIndividual.

Since the point in time where treatedPeriod changes from 0 to 1 varies across individuals and never turns to 1 for untreated you must assign the same starting point from the treated match to the untreated match. This is intuitive but I would still like to see a good reference that justifies this approach which I have not found so far.

The regression set-up would be:

depvar = treatedIndvidual + treatedPeriod  + treatedIndvidual*treatedPeriod + controls


where the interaction term gives you the treatment effect.

Did you consider to use the nnmatch command?

I use this command and it is a pretty comprehensive one. It does take into account different matching algorithms and also cases, in which the propensity score is the same for some control group individuals. Of course, the treatment of this case depends on the matching algorithm, if you take k-nearest-neighbour or kernel or whatever.

• In the article you referenced, I see no mention of panel data. Have you used that for panel data?If so, please be specific and provide some code to answer OP's question. – Metrics Jun 10 '13 at 13:37
• The exact matching is easier but overall nnmatch is more complicated since it does not store matching IDs inside the current data set but in a separate one. I will end up with one data set for each age group which need to be merged to the original data. Merging in this case doesn't work because the matching characteristics do not uniquely identify individuals in the original data. So unfortunately this doesn't provide a solution. – Andy Jun 10 '13 at 17:14