0
$\begingroup$

you have helped me tremendously over the past years and so far, I could find an answer to any the question I had! Thanks to anyone active in this community, I don't know what I would have done without you! But over the past days, I have been unable to find a solution for the following problem at hand:

Situation

  1. I have a panel data set and hence a fixed number of observations for many ids over several years from 1980-2017 called data1.
  2. In addition, I have several treatment events (1990, 1999, 2009, 2010 and 2011) e.g. state legislations that result in treated and untreated (possible controls) companies.

Goal

Out of the possible controls, I want to match two controls to each treated company given pre-defined criteria and thus, reduce the group of controls to have a better matched/balanced sample. I do this to analyse the effect on a variable of interest over a long time frame of t-7 and t+7 given the time t of legislation i with a DiD analysis.

My insufficient take

I did the matching for one legislation/point in time in 2009 with the package library(matchit). This means, I did the matching on cross-sectional data data2 (a subsample of data1) and generated the following code:

m.out1 <- matchit(treatment ~ covariate1 + covariate2 + covariate3, data=data2,
                  method="nearest",distance="mahalanobis",
                  exact = ~covariate4,
                  ratio = 2) 

The outcome is exactly what I want it to be and after assessing the balance of the matched sample I am more than happy with the outcome. For my DiD analysis I transformed the cross-sectional data data2 back to panel data (merging with default data1).

Problem

If I follow the above procedure for each legislation/point in time (e.g. 1990, 1999, 2009, 2010 and 2011) I end up with 5 different data sets. If I would then combine them again for my DiD analysis, I could have overlapping controls for different post legislation periods. In numbers: Instead of having e.g. 100 controls for my 50 treated companies across the 5 legislations (10 treated per event) I would end up with maybe 90 unique controls. Furthermore, I would only match correctly the controls for each subsample but not for the full sample I want to analyse in the first place (all legislations) This is especially the case for the later legislations that have overlapping time frames post legislation/event. What I think would be the solution is the following:

Transform all legislations into one cross-sectional data set data3 and then, include a line of code that would only allow a control to be used once. Hence, the data set could include duplicates of an id for different events. The data would somehow look like this:

ID year    treated 
1  2009    1 
2  2009    0
3  2009    0
4  2011    1
2  2011    0
5  2011    0

In this example, id 2 could be a control in 2009 and 2011. I want it to be a control (given my specifications from above) for either 2009 or 2011, whatever is the best for the full sample! Hence, the id 2 would be "removed" and thus cannot be matched again in 2011. I rephrase it again: it is similar to matching without replacement but over several points in time. I want that each control is only "assigned" to one legislation/event and the given treated companies.

Would anyone of you know how to implement this? Do you think this makes no sense and rather match the controls for each legislation-subsample and then potentially run into controls being used for multiple events?

$\endgroup$
5
  • $\begingroup$ There is no good way to do this currently except to loop through each treated unit, find its closest match, and then remove all rows that correspond to the matched control unit. I added a feature in MatchIt to implement this form of matching but it's not ready for prime time. I will let you know when it is. You are not the first to ask for this feature. $\endgroup$
    – Noah
    Commented Mar 29, 2022 at 6:44
  • $\begingroup$ Thank you Noah! I will try go with this clear answer. Is there a way to upvote this comment? Best Leo $\endgroup$
    – Leo I.
    Commented Mar 29, 2022 at 7:38
  • $\begingroup$ Do the events switch 'on' and 'off' at the same time for all treated units? In other words, do the events only last for one year? If I understand you correctly, this means that in the exact year of each event, you want a unique group of controls. But what about the periods after the event? Once a treated unit goes back into the control condition, does that mean those company-year observations will be excluded? $\endgroup$ Commented Apr 8, 2022 at 22:58
  • $\begingroup$ A treated unit stays treated and is never part of a subsequent control group. Furthermore the event happens in one year, but I am interested in the long-term effect of an event, the "post" period. E.g.: I have two events, one in 1999 and one in 2009. For each event I have a control and and treatment group (firms) that I observe for 7 years but I don't want the controls I chose for the 1999 event to be controls for the 2009 event (some firms from 1999 still exist in 2009). The ultimate goal is optimising the matching across both events e.g. across potentially two observations for controls. $\endgroup$
    – Leo I.
    Commented Apr 9, 2022 at 15:35
  • $\begingroup$ I'm in the exact same situation here. Did you find any solution? $\endgroup$ Commented Jul 29, 2023 at 2:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.