← All resources

Agent skill

Continuous moderators in DiD


Continuous moderators in DiD

Estimate a smooth curve to see how the effect of binary treatment (D) varies with a pre-treatment moderator (Z). Use bins to check functional form, display support, or estimate averages for groups defined by a threshold of substantive interest. [L28–L30]

Define the effect and its support

  1. Specify the target. In an absorbing-adoption panel, define (\tau_{g,t}(z)=E[Y_t(g)-Y_t(0)\mid G=g,Z=z]) for the treated cohort (g) at time (t). Record the baseline measurement window, outcome scale, comparison group, reference period, and horizon. For an aggregate curve, state the cohort and horizon weights. If weights vary with (z), differences along the curve can reflect changing cohort composition. Use fixed weights on common support if the question calls for holding composition constant and the estimator supports that target. Average over the corresponding treated moderator distribution to reconcile the curve with an overall ATT.
  2. Establish the comparison at each value. Assess no anticipation, conditional parallel trends, and overlap with eligible controls at the moderator values used in the claim. Check conditional preperiod contrasts when available. Use treated and eligible comparison densities or local counts and effective sample sizes by cohort and horizon, including the number of independent clusters. Choose the reporting domain from overlap and precision support before inspecting post-treatment signs. Break the reported curve across unsupported gaps and record any change in the target population from trimming.

Estimate the curve

Design Method
Staggered adoption with a balanced panel of independent units Use didhetero::catt_gt_continuous() for doubly robust conditional ATT estimates. Include the moderator in zname and xformla, supply the evaluation grid in zeval, and specify eligible controls in control_group. Use didhetero::aggte_continuous() for summaries. Set uniformall = TRUE for joint coverage across moderator values and the selected cohort-time pairs or summary indices. Assess attrition and selection if balancing changes the sample. [L30]
Two-group, two-period panel Take one outcome change (\Delta Y=Y_{\mathrm{post}}-Y_{\mathrm{pre}}) per unit and use the treated-group indicator as (D). With no anticipation, overlap, and conditional parallel trends given (Z), the treated-minus-comparison contrast in changes at (z) identifies the conditional ATT. When parallel trends also conditions on other covariates, estimate the contrast conditional on those covariates and average over their distribution among treated units at (z). Fit the curve using the R options below. [L28–L30]
Other designs Match the estimator and inference to the observation structure, treatment path, and assignment dependence. In repeated cross-sections, estimate the group-by-time contrast under defensible composition assumptions. In staggered designs, use cohort-specific risk sets and carry shared-control covariance through aggregation. [L1, L3, L24]

R options for an outcome-change comparison

Locate and interpret regions of significance

See the literature guide for sources L28–L30.