Propensity Score Matching for Diff-in-diff with panel data

739 views Asked by At

I am trying to use MatchIt to perform Propensity Score Matching (PSM) for my panel data which contains following a group of participants (participant_uuid) from 12 months before treatment to 12 months after treatment, i.e. we have complete 24 observations per participant. I am performing the matching to prepare a dataset for later calculating Diff-in-diff models. As with diff-in-diff I want to find how the reaction to treatment might vary between groups I am matching based on the 12 months prior treatment. My code currently looks like this:

match.nearestneighbour <- matchit(grouping_variable ~ characteristic1 + characterictic2 + charcteristic3, data = dataset_12months_pre_treatment, distance = "glm", method = "nearest", m.order = "largest", replace = TRUE, exact = c("month_relative_to_treatment"))

I realized this code matches on individual unit level (i.e. selects the best participant_uuid for each month_relative_to_treatment matchig to each of the observations treatment group months). How to change the rstudio code to find the nearest neighbor not per month/observation but the participant_uuid in control group with nearest distance to participant_uuid in treatment group, aggregated across the 12 months considered? Any hints are much appreciated.

1

There are 1 answers

2
Noah On

You need to transform your dataset so that it is wide, i.e., so there is a single for each observation, and each column contains the value of its variables for the given month. Then you include all the month-specific variables in the matching formula to estimate the propensity score. This will attempt to create pairs of units that are similar across all 12 months.