liveBook · Manning

Direct formula

As explained in Causal Inference for Data Science

A direct formula is an explicit mathematical procedure for calculating a causal effect from observed group-time averages.

A direct formula calculates a difference-in-differences treatment effect by subtracting the control group’s change from the treated group’s change. Applied to observed group-time averages, it estimates the ATET directly. section 11.4.5

Apply the method in three steps:

  • Compute the treated group’s post-treatment mean minus its pre-treatment mean. section 11.4.5
  • Compute the corresponding change for the untreated control group. section 11.4.5
  • Subtract the control change from the treated change to obtain the estimated effect. section 11.4.5

Estimating uncertainty

Bootstrap confidence intervals by resampling with replacement, recalculating the ATET many times—typically 1,000 to 10,000—and taking the 2.5th and 97.5th percentiles for a 95% interval. section 11.4.5

Listing 11.22 (R) DiD ATE estimation with the direct method
diff_1 <- mean(df_observed[
  df_observed$time_points == 1 & df_observed$D == 1, 'Y'
]) - mean(df_observed[
  df_observed$time_points == 0 & df_observed$D == 1, 'Y'
])
diff_0 <- mean(df_observed[
  df_observed$time_points == 1 & df_observed$D == 0, 'Y'
]) -mean(df_observed[
  df_observed$time_points == 0 & df_observed$D == 0, 'Y'
])
diff_1 - diff_0

R implements the direct estimator by calculating within-group changes and subtracting them. section 11.4.5

How Causal Inference for Data Science covers it

How deep it goes
Defines the calculation and bootstrap procedure, but defers more sophisticated covariate adjustment to linear models.
Examples
Uses R and Python implementations that subtract control-group change from treated-group change.
What it assumes
Assumes observed treated and control outcomes at pre-treatment and post-treatment time points.
What you can do after
Apply the formula via R or Python and estimate uncertainty through bootstrap resampling.
How it connects
Connects difference-in-differences with ATET, bootstrapping, confidence intervals, and linear models.

This explainer was generated by Manning's knowledge graph from the text of Causal Inference for Data Science. The section links point to the parts of the book it draws on.