Functions & Formulae

Each applied formula has its own function page, with a signature, implementations, and tests.

Difference-in-differences estimate of a policy effect from treated and comparison groups

tau = (E[Y_1 | D = 1] - E[Y_0 | D = 1]) - (E[Y_1 | D = 0] - E[Y_0 | D = 0])

Maps outcomes observed before and after a policy in a group exposed to it and a group that is not to an estimate of the policy's average effect on the exposed: the change in the exposed group minus the change in the comparison group. Fixed differences between the groups and shocks common to both cancel. The estimate is causal only under parallel trends and no anticipation. The notation follows the Difference-in-Differences article.

  • Two-group two-period difference-in-differences estimate from group means

    tau = (Y_T1 - Y_T0) - (Y_C1 - Y_C0)

    Subtracts the comparison group's change in mean outcome from the treated group's change between one period before and one period after the policy. The first change removes what is fixed about the treated group, such as case mix; subtracting the second removes changes common to both groups, such as a national trend. Under parallel trends and no anticipation it estimates the average treatment effect on the treated.

  • Difference-in-differences regression with group, period and interaction terms

    Y = alpha + gamma_D * D + lambda_P * P + tau * D * P

    Writes each group-period mean as a constant, a fixed group gap, a common period change and an interaction that is non-zero only for the treated group after the policy. Fitted by ordinary least squares to unit-level data, the interaction coefficient equals the two-by-two estimate, and the regression also gives its standard error. gamma_D and lambda_P are the article's gamma and lambda, written with subscripts naming the indicator each one multiplies.

  • Difference-in-differences estimate adjusted for a linearly extrapolated pre-policy differential trend

    tau_adj = tau - delta_pre * s_post / s_pre

    Removes from the estimate the gap that the pre-policy difference in trends would produce if it continued in a straight line over the post-policy interval. The pre-policy difference comes from a placebo estimate between two pre-policy periods (HE-FM-DID-001 applied before the policy). Linear extrapolation is one assumption among several; bounded sensitivity analysis reports how conclusions change under a range of departures.

  • Group-time average treatment effect for one adoption cohort against never-treated units

    ATT_gt = (Y_g_t - Y_g_base) - (Y_n_t - Y_n_base)

    Compares the change in mean outcome for units first treated in period g, from the last period before adoption (g minus 1) to period t, with the same change for units never treated. Estimating one effect per cohort and period avoids the comparisons with already-treated units that bias the two-way fixed effects coefficient under staggered adoption; the effects are then combined with weights the analyst states.

  • Annual net cost of a policy from a difference-in-differences event rate estimate

    C_net = C_prog + tau * N / 1000 * c_event

    Turns an estimated change in an event rate per 1,000 people into events per year for the population covered and values them, then adds the policy's running cost. A negative result is a net saving. Health effects are valued separately in a cost-effectiveness analysis, and the estimate's standard error should be carried into probabilistic analysis.

Difference-in-Differences — Functions & Formulae | HealthEconomics.wiki