From a 2-by-2 Table to a Difference-in-Differences Contrast
A two-period difference-in-differences analysis begins with four group-by-time outcome means: one for each combination of group and period. The calculation then compares two changes. First, measure how the outcome mean changes from before to after for the treated group. Then measure the same change for the control group. The difference-in-differences (DiD) contrast is the treated-group change minus the control-group change.
This subtraction is easy to reverse or misread when the four means are presented in a table. The most reliable approach is to name the four cells, calculate each group’s change separately, and only then subtract. At this stage, the result is a descriptive contrast in the outcome means. Calculating it does not, by itself, establish that the contrast is a causal effect.
The notation describes observed group-time means, not individual-level outcomes. For example, \(\bar Y_{T,0}\) is the mean outcome among the treated-group observations in the pre period. The four cell means can be laid out as follows:
| Group | Pre period (0) | Post period (1) | Change, post minus pre |
|---|---|---|---|
| Treated (T) | \(\bar Y_{T,0}\) | \(\bar Y_{T,1}\) | \(\bar Y_{T,1}-\bar Y_{T,0}\) |
| Control (C) | \(\bar Y_{C,0}\) | \(\bar Y_{C,1}\) | \(\bar Y_{C,1}-\bar Y_{C,0}\) |
The period order matters: a change is defined here as post minus pre for both groups. The group order matters too: the control change is subtracted from the treated change. Applying the same order in both comparisons makes the calculation transparent and keeps the sign interpretable.
How to Calculate the Contrast
For a numerical table, calculate in three steps: find the treated-group change, find the control-group change, then subtract the second change from the first. Keep the units throughout. If the outcome is measured in minutes, the two changes and the DiD contrast are also measured in minutes. If the outcome is a proportion, the contrast is in proportion units unless it is converted to percentage points.
Identify which mean belongs to each group and period. Confirm that the same outcome and scale are used in all four cells.
For each group, subtract its pre-period mean from its post-period mean.
Subtract the control-group change from the treated-group change. State the resulting contrast in context and in the outcome’s units.
Worked Example: Mean Waiting Time
Suppose a hypothetical service evaluation reports mean waiting times, in minutes, for a treated group and a control group. The four means are:
| Group | Pre period | Post period |
|---|---|---|
| Treated | 42 min | 34 min |
| Control | 39 min | 36 min |
Treated-group change. The mean waiting time fell from 42 minutes to 34 minutes:
Control-group change. The mean fell from 39 minutes to 36 minutes:
DiD contrast. Subtract the control-group change from the treated-group change:
The treated group’s mean waiting time decreased by 5 minutes more than the control group’s mean waiting time did. This describes the difference between the two observed changes; the calculation alone does not establish why the groups changed differently.
Computing Cell Means Before Computing DiD
Sometimes the table gives cell totals and sample sizes rather than the four means. In that case, first calculate each cell mean as its outcome total divided by its number of observations. Only after obtaining all four means should you calculate the two changes and their difference. This separates the arithmetic of constructing the table from the arithmetic of the DiD contrast.
Worked Example: Starting From Cell Totals and Sample Sizes
Consider a hypothetical program evaluation using a score measured in points. Suppose the treated-group pre-period cell contains 40 observations with a total score of 2,400 points; the treated-group post-period cell contains 40 observations with a total of 2,800 points. The control-group pre-period cell contains 50 observations with a total of 3,250 points; its post-period cell contains 50 observations with a total of 3,500 points.
Find the four cell means. Divide each total by its corresponding sample size:
Find the treated-group change.
Find the control-group change.
Find the DiD contrast.
The treated-group mean score increased by 5 points more than the control-group mean score increased. The cell sizes need not match to perform this calculation: each mean is calculated using the number of observations in its own cell. The result remains a contrast of the four cell means, not a difference of cell totals.
Understanding the Sign and the Components
The sign of the contrast comes from the direction of the two changes and from the order of subtraction. A positive DiD contrast means the treated-group change is numerically greater than the control-group change. A negative contrast means it is numerically smaller. For outcomes where lower values are desirable, a negative contrast might describe a larger decrease in the treated group, but whether that is a beneficial or causal effect depends on the context and assumptions beyond the calculation.
A useful algebraic rearrangement makes the four-cell structure explicit:
The post-period control mean has a minus sign, while the pre-period control mean has a plus sign. These signs follow from subtracting the entire control change, including its parentheses. For instance, if both groups increase by the same amount, their changes subtract to zero. This is an arithmetic property of the contrast; it does not require the groups to have equal outcome means at baseline.
Worked Example: A Binary Outcome Reported as a Proportion
Suppose a hypothetical evaluation reports the proportion of individuals experiencing an outcome in each cell. The treated-group proportions are 0.12 before and 0.18 after; the control-group proportions are 0.10 before and 0.13 after.
Treated-group change.
Control-group change.
DiD contrast.
The contrast is 0.03 in proportion units, or 3 percentage points, because \(0.03\times100=3\). It is not a 3 percent relative increase: that wording would require a specified reference proportion and a relative calculation. Here, the direct result is a difference between changes in proportions.
What the Table Does and Does Not Establish
A 2-by-2 table supplies the four descriptive means needed for the contrast. It does not, by itself, explain the source of the differences or justify a causal interpretation. In a causal analysis, interpreting the DiD contrast as an effect requires additional design and identifying assumptions. Those assumptions are separate from the arithmetic and must be assessed for the study at hand. Thus, it is precise to report that the treated-group mean changed by a certain amount more or less than the control-group mean; a causal claim requires more than that calculation.
The comparison is also specific to the chosen outcome scale. A contrast computed from means in minutes is expressed in minutes; one computed from proportions is expressed in proportion units or percentage points. Changing the scale can change the numerical contrast and its interpretation. The four entries must refer to the same outcome definition and units for the subtraction to be meaningful.
Common Mistakes
- Subtracting post-period means only. The post-period treated-control difference is \(\bar Y_{T,1}-\bar Y_{C,1}\), not the DiD contrast. The DiD also accounts arithmetically for the pre-period difference by comparing changes.
- Reversing the order between groups. Calculate post minus pre for both groups, then treated change minus control change. Mixing pre minus post for one group reverses or corrupts the contrast.
- Dropping parentheses around the control change. Subtracting \((\bar Y_{C,1}-\bar Y_{C,0})\) changes the sign of both control terms when expanded.
- Calling the descriptive contrast a causal effect automatically. The four means determine the contrast, but a causal interpretation also requires identifying assumptions.
- Confusing percentage points with percent. A change from 12% to 18% is an increase of 6 percentage points. A difference-in-differences of 3 percentage points is not automatically a 3% relative change.
Check Your Understanding
Use the post-minus-pre convention for both groups, then subtract the control change from the treated change.
- In a table, the treated-group means are 24 before and 30 after; the control-group means are 20 before and 23 after. What are the two group changes and the DiD contrast?
- Write the four group-by-time means for a setup with treated and control groups and pre and post periods. Which two means form the treated-group change?
- If the treated-group mean falls by 4 units and the control-group mean falls by 1 unit, what is the DiD contrast, and what does its sign say about the relative changes?
- A binary-outcome DiD contrast is 0.025. Express it in percentage points and explain what quantity is being compared.
- Why does computing the four means and their DiD contrast not, by itself, demonstrate a causal effect?