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
- 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.
- 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
interflexkernel. Useinterflex::interflex()withestimator = "kernel",Yset to the change,Dset to the group indicator,Xset to the moderator, andX.evalset to the supported grid. Usevartype = "bootstrap"for the uniform band andclfor block resampling when it matches assignment. Verify band columns inest.kernel, record bandwidth and bootstrap settings, and check stability to reasonable bandwidth choices and smoothing bias. Useestimator = "binning"as an optional diagnostic andestimator = "linear"as an optional functional-form benchmark. [L28]- GAM Johnson–Neyman (JN2). In
statuser::interprobe(x = "treated", z = "moderator", y = "delta_y", data = changes, draw = "jn"), use a two-level factor for treatment and verify which level is subtracted. The plotted effect is the fitted difference between the two treatment predictions at each (z). For covariate-adjusted or nonlinear-link fits, use the intended prediction scale and the treated covariate distribution if the target calls for averaging. Treat the built-in Johnson–Neyman intervals as pointwise. For a simultaneous claim, use a joint band for the treatment contrast from a procedure that supports the design’s dependence and accounts for the fitted smooths and any first-stage estimation. Check the smooth specification and its sensitivity to basis size or smoothing. [L29]
Locate and interpret regions of significance
- Fix the family over which the claim is made, such as the supported moderator grid at one prespecified horizon or jointly across selected horizons. Use a design-valid simultaneous (1-\alpha) band. For a grid-based band, report the evaluated grid and the contiguous runs of supported points where the lower limit is above zero (positive) or the upper limit is below zero (negative). Report any interpolated boundaries as approximate. Use pointwise intervals for prespecified moderator values or label a pointwise scan exploratory. Account separately for any search across moderators, outcomes, or specifications. [L28–L30]
- Test moderation directly. Use a prespecified contrast (\tau(z_a)-\tau(z_b)) or a joint test of a constant curve. Use the joint covariance from the fit or resampling procedure. [L19, L28–L30]
- Report the curve and its support. Include the overall ATT benchmark, effect units, horizon, uncertainty type and scope, and which treated and comparison observations support the ranges. Give range endpoints in the moderator’s original units and the treated share in each range when useful. A follow-up DiD for a prespecified or independently confirmed range estimates that range’s average effect. Label same-sample refits on ranges selected from the curve exploratory.
See the literature guide for sources L28–L30.