Differences-in-differences regression can be used to test the impact of a treatment on a metric of interest. It works by comparing the metric before and after, both for a treatment group and for a control group. For example, I might want to measure whether an educational intervention improves students' grades. To do this, I would measure grades before and after the intervention, both for the participating group and for a control group (who didn't participate).
The input data might have the following form:
Student | Treated/Control | Before grade (%) | After grade (%) |
---|---|---|---|
Student A | Treated | 40 | 60 |
Student B | Treated | 45 | 55 |
Student C | Control | 30 | 50 |
Student D | Treated | 75 | 80 |
$\vdots$ | $\vdots$ | $\vdots$ | $\vdots$ |
If I understand correctly, the linear model underlying the differences-in differences-method is as follows:
$Y_i=\alpha+\beta T_i+\gamma A_i+\delta T_i A_i+\epsilon_i$,
where $Y_i$ is the $i^\textrm{th}$ grade, $T_i$ is a dummy variable which takes the value 1 if the $i^\textrm{th}$ data point was from the treated group, $A_i$ is a dummy variable which takes the value 1 if the $i^\textrm{th}$ data point was taken after the intervention, and $\epsilon_i$ is a normal random variable with mean 0. The Greek letters are parameters to be estimated. If we want to test whether the treatment has an effect, we will test the null hypothesis $\delta=0$ (because $\delta$ tells us how much extra the treatment group gained from before to after vs the control group).
The above data doesn't match the form of this model. To use the linear model, we need to have only one grade measurement per row, and to introduce variable telling us whether each data point was before or after.
Student | Treated? ($T_i$) | After? ($A_i$) | Grade ($Y_i$) |
---|---|---|---|
Student A | 1 | 0 | 40 |
Student A | 1 | 1 | 60 |
Student B | 1 | 0 | 45 |
Student B | 1 | 1 | 55 |
Student C | 0 | 0 | 30 |
Student C | 0 | 1 | 50 |
$\vdots$ | $\vdots$ | $\vdots$ | $\vdots$ |
I understand how to run the linear regression on data in this form.
The question
My question is whether reformatting this data was the right thing to do. In particular, by running the analysis on this data, we have lost the information that the first two data points belonged to Student A. The data below would give equivalent results - the after grades of Student A and Student B have been swapped.
Student | Treated? ($T_i$) | After? ($A_i$) | Grade ($Y_i$) |
---|---|---|---|
Student A | 1 | 0 | 40 |
Student A | 1 | 1 | 55$\leftarrow$ |
Student B | 1 | 0 | 45 |
Student B | 1 | 1 | 60$\leftarrow$ |
Student C | 0 | 0 | 30 |
Student C | 0 | 1 | 50 |
$\vdots$ | $\vdots$ | $\vdots$ | $\vdots$ |
Intuitively, it seems that this information was important. On the other hand, perhaps it is not: by using a linear model (and holding all the information about the model in the four Greek variables), we have produced a set up where four means (before/after for treatment/control) are a set of sufficient statistics for the model. Switching the final grades of Student A and Student B doesn't change these means, so perhaps the two situations should be regarded as equivalent.