<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>cdid user guide | David Benatia</title><link>https://www.davidbenatia.com/tools/cdid/guide/</link><atom:link href="https://www.davidbenatia.com/tools/cdid/guide/index.xml" rel="self" type="application/rss+xml"/><description>cdid user guide</description><generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><lastBuildDate>Mon, 16 Nov 2026 00:00:00 +0000</lastBuildDate><image><url>https://www.davidbenatia.com/media/icon_huf51d053dcee75059daeadc3a21b01f3b_32112_512x512_fill_lanczos_center_3.png</url><title>cdid user guide</title><link>https://www.davidbenatia.com/tools/cdid/guide/</link></image><item><title>Add PT-all restrictions</title><link>https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/</guid><description>&lt;p>Results below were produced on October 29, 2026 with &lt;code>cdid&lt;/code> 1.1.0.0, &lt;code>did&lt;/code> 2.5.1 and &lt;code>DRDID&lt;/code> 1.3.0 under R 4.5.2, using the displayed seeds where applicable. These are individual examples; they do not establish repeated-sample coverage. OR/DR calls shown here explicitly retain the historical pooled specification; the current default uses separate comparison regressions.&lt;/p>
&lt;p>In chained difference in differences (&lt;code>cdid&lt;/code>, extending Bellégo, Benatia and Dortet-Bernadet 2025 and Callaway and Sant&amp;rsquo;Anna 2021), &lt;code>pt_assumption&lt;/code> selects the parallel trends restrictions imposed in generalized method of moments (GMM) estimation (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>). The default &lt;code>pt_assumption = &amp;quot;post&amp;quot;&lt;/code> (&lt;code>PT-post&lt;/code>) assumes conditional parallel trends from each cohort&amp;rsquo;s reference period onward. Setting &lt;code>pt_assumption = &amp;quot;all&amp;quot;&lt;/code> (&lt;code>PT-all&lt;/code>) with an explicit common calendar start date &lt;code>pt_start&lt;/code> keeps every &lt;code>PT-post&lt;/code> condition and each cohort&amp;rsquo;s original reference period, and adds zero differential restrictions on represented untreated preperiod steps between &lt;code>pt_start&lt;/code> and each cohort&amp;rsquo;s reference period.&lt;/p>
&lt;p>This worked example reuses the exact unit table (&lt;code>units&lt;/code>), incomplete panel (&lt;code>panel&lt;/code>), complete latent outcome vector (&lt;code>y_complete&lt;/code>), and observation mask (&lt;code>observed&lt;/code>) created in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>. Start a fresh R session, run that script, then run this example immediately: other pages of this guide use the names &lt;code>units&lt;/code>, &lt;code>panel&lt;/code> and &lt;code>observed&lt;/code> for different objects.&lt;/p>
&lt;h2 id="question">Question&lt;/h2>
&lt;p>Holding &lt;code>panel&lt;/code>, &lt;code>units&lt;/code>, &lt;code>xformla = ~ x&lt;/code>, &lt;code>control_group = &amp;quot;nevertreated&amp;quot;&lt;/code>, &lt;code>est_method = &amp;quot;dr&amp;quot;&lt;/code>, &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>, &lt;code>base_period = &amp;quot;varying&amp;quot;&lt;/code>, and &lt;code>bstrap = FALSE, cband = FALSE&lt;/code> fixed, what changes when we switch from &lt;code>pt_assumption = &amp;quot;post&amp;quot;&lt;/code> to &lt;code>pt_assumption = &amp;quot;all&amp;quot;&lt;/code> with &lt;code>pt_start = 1&lt;/code>? First, how do the two fits compare under the baseline law where conditional parallel trends hold across all dates $1$ to $6$? Second, what happens when we add a cohort specific pre baseline untreated pulse at period $1$ that violates &lt;code>PT-all&lt;/code> from period $1$ while leaving &lt;code>PT-post&lt;/code> and all posttreatment causal effects unchanged?&lt;/p>
&lt;h2 id="data">Data&lt;/h2>
&lt;h3 id="prerequisite-objects-and-pre-baseline-pulse-modification">Prerequisite objects and pre baseline pulse modification&lt;/h3>
&lt;p>Run &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/#code">Choose IPW, OR or DR in an incomplete panel&lt;/a> first to create &lt;code>units&lt;/code> ($N = 2000$ units with &lt;code>id&lt;/code>, &lt;code>first_treat&lt;/code> in ${0, 3, 5}$, and &lt;code>x&lt;/code>), &lt;code>panel&lt;/code> ($N \times T = 12000$ rows across stored calendar dates $t \in {1, \dots, 6}$ with &lt;code>NA&lt;/code> in &lt;code>y&lt;/code> where unobserved), &lt;code>y_complete&lt;/code> (unmasked latent outcomes), and &lt;code>observed&lt;/code> (logical observation mask). We compare &lt;code>PT-post&lt;/code> and &lt;code>PT-all&lt;/code> (&lt;code>pt_start = 1&lt;/code>) on two outcome vectors sharing &lt;code>units&lt;/code>, latent shocks, and &lt;code>observed&lt;/code>:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Baseline panel (&lt;code>panel&lt;/code>):&lt;/strong> Untreated outcomes follow $Y_{i,t}(0) = \alpha_i + 0.1 t + 0.3 X_i t + \varepsilon_{i,t}$ at all dates $t \in {1, \dots, 6}$. With &lt;code>anticipation = 0&lt;/code>, cohort $3$ has reference period $2$ and cohort $5$ has reference period $4$. Conditional parallel trends hold across every date pair, so both &lt;code>PT-post&lt;/code> and &lt;code>PT-all&lt;/code> (&lt;code>pt_start = 1&lt;/code>) hold in the population.&lt;/li>
&lt;li>&lt;strong>Pre baseline pulse panel (&lt;code>pulse_panel&lt;/code>):&lt;/strong> Before applying the original mask &lt;code>observed&lt;/code>, we add $+0.5 \times \mathbf{1}{G_i &amp;gt; 0, t = 1}$ to &lt;code>y_complete&lt;/code>, so $Y_{i,t}^{\text{pulse}}(0) = Y_{i,t}(0) + 0.5 \times \mathbf{1}{G_i &amp;gt; 0, t = 1}$ and $Y_{i,t}^{\text{pulse}} = Y_{i,t} + 0.5 \times \mathbf{1}{G_i &amp;gt; 0, t = 1}$. Applying &lt;code>ifelse(observed, y_pulse_complete, NA_real_)&lt;/code> preserves every &lt;code>NA&lt;/code> entry and the exact observation pattern of &lt;code>panel&lt;/code>.&lt;/li>
&lt;/ol>
&lt;p>This modification is a cohort specific pre baseline untreated pulse, &lt;strong>not&lt;/strong> anticipation of treatment:&lt;/p>
&lt;ul>
&lt;li>At every date $t \in {1, \dots, 6}$, the potential outcome difference $Y_{i,t}^{\text{pulse}}(g) - Y_{i,t}^{\text{pulse}}(0)$ remains $0$ for $t &amp;lt; g$ and $1 + 0.25(t - g)$ for $t \ge g$, so &lt;code>anticipation = 0&lt;/code> holds and the posttreatment target remains $\text{ATT}(g, t) = 1 + 0.25(t - g)$.&lt;/li>
&lt;li>Because the pulse acts only at $t = 1$, untreated changes $Y_{i,t}^{\text{pulse}}(0) - Y_{i,s}^{\text{pulse}}(0)$ for all pairs $2 \le s &amp;lt; t$ equal those of the baseline law. Since cohort reference periods are $2$ and $4$, &lt;code>PT-post&lt;/code> still holds completely.&lt;/li>
&lt;li>From $t = 1$ to $t = 2$, however, the conditional mean untreated change for cohorts $3$ and $5$ differs by $-0.5$ from that of never treated controls ($G_i = 0$). Thus &lt;code>PT-all&lt;/code> with &lt;code>pt_start = 1&lt;/code> fails.&lt;/li>
&lt;/ul>
&lt;h2 id="assumptions">Assumptions&lt;/h2>
&lt;p>The four fits vary only &lt;code>data&lt;/code>, &lt;code>pt_assumption&lt;/code>, and &lt;code>pt_start&lt;/code> (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>).&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Argument&lt;/th>
&lt;th>Setting&lt;/th>
&lt;th>Purpose&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>data&lt;/code>, &lt;code>frame&lt;/code>&lt;/td>
&lt;td>&lt;code>panel&lt;/code> or &lt;code>pulse_panel&lt;/code>, &lt;code>units&lt;/code>&lt;/td>
&lt;td>$N \times T$ panel with &lt;code>NA&lt;/code> outcomes and fixed $N$ row unit table (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#chained-arguments">Options&lt;/a>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>xformla&lt;/code>, &lt;code>control_group&lt;/code>, &lt;code>est_method&lt;/code>, &lt;code>selection&lt;/code>&lt;/td>
&lt;td>&lt;code>~ x&lt;/code>, &lt;code>&amp;quot;nevertreated&amp;quot;&lt;/code>, &lt;code>&amp;quot;dr&amp;quot;&lt;/code>, &lt;code>&amp;quot;none&amp;quot;&lt;/code>&lt;/td>
&lt;td>Doubly robust treatment adjustment and representative observed pair changes (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>pt_assumption&lt;/code>, &lt;code>pt_start&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;post&amp;quot;&lt;/code> (&lt;code>NULL&lt;/code>) or &lt;code>&amp;quot;all&amp;quot;&lt;/code> (&lt;code>1&lt;/code>)&lt;/td>
&lt;td>Switches between &lt;code>PT-post&lt;/code> and &lt;code>PT-all&lt;/code> from common calendar start date $1$ (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>base_period&lt;/code>, &lt;code>bstrap&lt;/code>, &lt;code>cband&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;varying&amp;quot;&lt;/code>, &lt;code>FALSE&lt;/code>, &lt;code>FALSE&lt;/code>&lt;/td>
&lt;td>Consecutive unrestricted preperiod reports and analytical standard errors (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#inference-and-computation">Options&lt;/a>).&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="how-pt-post-and-pt-all-use-the-comparison-catalog">How &lt;code>PT-post&lt;/code> and &lt;code>PT-all&lt;/code> use the comparison catalog&lt;/h3>
&lt;ol>
&lt;li>&lt;strong>Earlier bridges under &lt;code>PT-post&lt;/code> have no artificial endpoint cutoff:&lt;/strong> Under &lt;code>PT-post&lt;/code>, two date comparisons touching dates before a cohort&amp;rsquo;s reference period remain in the catalog whenever their unrestricted pre reference differentials cancel across a bridge (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/#comparisons-through-earlier-dates">Parallel trends&lt;/a>). For cohort $3$ (reference period $2$), combining $(1, 3)$ and $(1, 2)$ cancels the period $1$ to $2$ differential because $E[Y_3 - Y_1] - E[Y_2 - Y_1] = E[Y_3 - Y_2]$ in the fixed cohort and control populations. This is a population identity: each observed pair must represent the same populations, with valid control/model support, and its fitted estimates need not satisfy an exact realized equality.&lt;/li>
&lt;li>&lt;strong>Added restrictions under &lt;code>PT-all&lt;/code> (&lt;code>pt_start = 1&lt;/code>):&lt;/strong> &lt;code>PT-all&lt;/code> retains every &lt;code>PT-post&lt;/code> condition and each cohort&amp;rsquo;s original reference period ($2$ for cohort $3$, $4$ for cohort $5$), and constrains represented operator specific untreated pre reference steps from &lt;code>pt_start = 1&lt;/code> up to each cohort&amp;rsquo;s reference period to zero ($1$ to $2$ for cohort $3$, and steps from $1$ up to $4$ for cohort $5$). &lt;code>pt_start&lt;/code> must be one finite numeric date in the stored calendar common to all cohorts (omitting it or passing &lt;code>NULL&lt;/code> under &lt;code>&amp;quot;all&amp;quot;&lt;/code>, or passing a non &lt;code>NULL&lt;/code> value under &lt;code>&amp;quot;post&amp;quot;&lt;/code>, raises an error).&lt;/li>
&lt;li>&lt;strong>GMM moment restrictions and separate &lt;code>base_period&lt;/code>:&lt;/strong> &lt;code>PT-all&lt;/code> adds restrictions to the existing chained GMM system over the same primitive comparison catalog and control pools. It retains their complete unit influence-function construction, but changes the combination: the final target influence functions, covariance and standard errors can change. It does not switch to a cross sectional estimator or introduce a new weighting rule. Meanwhile, &lt;code>base_period&lt;/code> separately controls how unrestricted preperiod comparisons (&lt;code>role == &amp;quot;pre&amp;quot;&lt;/code>) are reported.&lt;/li>
&lt;/ol>
&lt;h2 id="code">Code&lt;/h2>
&lt;pre>&lt;code class="language-r"># Objects from the treatment-choice example. exists() searches only the current
# environment, so base::units() cannot satisfy the check.
needed &amp;lt;- c(&amp;quot;units&amp;quot;, &amp;quot;panel&amp;quot;, &amp;quot;y_complete&amp;quot;, &amp;quot;observed&amp;quot;)
found &amp;lt;- vapply(needed, exists, logical(1), envir = environment(), inherits = FALSE)
if (!all(found)) {
stop(&amp;quot;Run 'Choose IPW, OR or DR in an incomplete panel' first, in a fresh R session. &amp;quot;,
&amp;quot;Not found: &amp;quot;, paste(needed[!found], collapse = &amp;quot;, &amp;quot;))
}
if (!is.data.frame(units) || !all(c(&amp;quot;id&amp;quot;, &amp;quot;first_treat&amp;quot;, &amp;quot;x&amp;quot;) %in% names(units)) ||
!is.data.frame(panel) ||
!all(c(&amp;quot;id&amp;quot;, &amp;quot;period&amp;quot;, &amp;quot;first_treat&amp;quot;, &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;) %in% names(panel)) ||
!is.numeric(panel$y) || !is.numeric(y_complete) || !is.logical(observed) ||
length(y_complete) != nrow(panel) || !identical(!is.na(panel$y), observed)) {
stop(&amp;quot;units, panel, y_complete and observed do not match 'Choose IPW, OR or DR &amp;quot;,
&amp;quot;in an incomplete panel'. Start a fresh R session, run that example, &amp;quot;,
&amp;quot;then run this one.&amp;quot;)
}
# 1. Baseline panel fits: PT-post vs PT-all with explicit pt_start = 1.
fit_pt_post &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
xformla = ~ x, data = panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;, selection = &amp;quot;none&amp;quot;,
pt_assumption = &amp;quot;post&amp;quot;, base_period = &amp;quot;varying&amp;quot;, bstrap = FALSE, cband = FALSE
)
fit_pt_all &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
xformla = ~ x, data = panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;, selection = &amp;quot;none&amp;quot;,
pt_assumption = &amp;quot;all&amp;quot;, pt_start = 1, base_period = &amp;quot;varying&amp;quot;, bstrap = FALSE, cband = FALSE
)
utils::str(fit_pt_post$chained$pt)
utils::str(fit_pt_all$chained$pt)
fit_pt_all$chained$pt[c(
&amp;quot;pt_assumption&amp;quot;, &amp;quot;pt_start&amp;quot;, &amp;quot;n_extra_calendar_dates&amp;quot;,
&amp;quot;n_restricted_pre_parameters&amp;quot;, &amp;quot;no_extra_restrictions&amp;quot;
)]
fit_pt_all$chained$pt$by_cohort
cols &amp;lt;- c(&amp;quot;target.id&amp;quot;, &amp;quot;group&amp;quot;, &amp;quot;time&amp;quot;, &amp;quot;role&amp;quot;, &amp;quot;available&amp;quot;, &amp;quot;estimate&amp;quot;, &amp;quot;std.error&amp;quot;)
baseline_table &amp;lt;- merge(
cdid::tidy(fit_pt_post)[, cols],
cdid::tidy(fit_pt_all)[, c(&amp;quot;target.id&amp;quot;, &amp;quot;estimate&amp;quot;, &amp;quot;std.error&amp;quot;)],
by = &amp;quot;target.id&amp;quot;, suffixes = c(&amp;quot;_pt_post&amp;quot;, &amp;quot;_pt_all&amp;quot;)
)
baseline_table$population_truth &amp;lt;- ifelse(
baseline_table$role == &amp;quot;post&amp;quot;, 1 + 0.25 * (baseline_table$time - baseline_table$group), 0
)
baseline_table[baseline_table$role == &amp;quot;post&amp;quot;, ]
baseline_table[baseline_table$role == &amp;quot;pre&amp;quot;, ]
list(
pt_post = fit_pt_post$chained$pretest[c(&amp;quot;status&amp;quot;, &amp;quot;reason&amp;quot;, &amp;quot;df&amp;quot;, &amp;quot;W&amp;quot;, &amp;quot;Wpval&amp;quot;)],
pt_all = fit_pt_all$chained$pretest[c(&amp;quot;status&amp;quot;, &amp;quot;reason&amp;quot;, &amp;quot;df&amp;quot;, &amp;quot;W&amp;quot;, &amp;quot;Wpval&amp;quot;)]
)
# 2. Pre baseline untreated pulse: add +0.5 * 1{G &amp;gt; 0, period == 1} to y_complete
# BEFORE applying the original `observed` mask.
y_pulse_complete &amp;lt;- y_complete + ifelse(panel$first_treat &amp;gt; 0L &amp;amp; panel$period == 1L, 0.5, 0)
pulse_panel &amp;lt;- panel
pulse_panel$y &amp;lt;- ifelse(observed, y_pulse_complete, NA_real_)
fit_pulse_post &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
xformla = ~ x, data = pulse_panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;, selection = &amp;quot;none&amp;quot;,
pt_assumption = &amp;quot;post&amp;quot;, base_period = &amp;quot;varying&amp;quot;, bstrap = FALSE, cband = FALSE
)
fit_pulse_all &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
xformla = ~ x, data = pulse_panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;, selection = &amp;quot;none&amp;quot;,
pt_assumption = &amp;quot;all&amp;quot;, pt_start = 1, base_period = &amp;quot;varying&amp;quot;, bstrap = FALSE, cband = FALSE
)
pulse_table &amp;lt;- merge(
cdid::tidy(fit_pulse_post)[, cols],
cdid::tidy(fit_pulse_all)[, c(&amp;quot;target.id&amp;quot;, &amp;quot;estimate&amp;quot;, &amp;quot;std.error&amp;quot;)],
by = &amp;quot;target.id&amp;quot;, suffixes = c(&amp;quot;_pt_post&amp;quot;, &amp;quot;_pt_all&amp;quot;)
)
pulse_table[pulse_table$role == &amp;quot;post&amp;quot;, ]
pulse_table[pulse_table$role == &amp;quot;pre&amp;quot;, ]
list(
pulse_pt_post = fit_pulse_post$chained$pretest[c(&amp;quot;status&amp;quot;, &amp;quot;reason&amp;quot;, &amp;quot;df&amp;quot;, &amp;quot;W&amp;quot;, &amp;quot;Wpval&amp;quot;)],
pulse_pt_all = fit_pulse_all$chained$pretest[c(&amp;quot;status&amp;quot;, &amp;quot;reason&amp;quot;, &amp;quot;df&amp;quot;, &amp;quot;W&amp;quot;, &amp;quot;Wpval&amp;quot;)]
)
&lt;/code>&lt;/pre>
&lt;details>
&lt;summary>Console output&lt;/summary>
&lt;pre>&lt;code class="language-text">List of 2
$ pt_assumption: chr &amp;quot;post&amp;quot;
$ pt_start : NULL
List of 14
$ pt_assumption : chr &amp;quot;all&amp;quot;
$ pt_start : num 1
$ start_selection : chr &amp;quot;fixed exogenously&amp;quot;
$ by_cohort :'data.frame': 2 obs. of 10 variables:
..$ g : num [1:2] 3 5
..$ ref : num [1:2] 2 4
..$ pt_start : num [1:2] 1 1
..$ baseline_status : chr [1:2] &amp;quot;stored_reference&amp;quot; &amp;quot;stored_reference&amp;quot;
..$ n_extra_calendar_dates : int [1:2] 1 3
..$ n_extra_represented_dates : int [1:2] 1 3
..$ n_restricted_pre_parameters: int [1:2] 1 3
..$ n_zero_loading_links : int [1:2] 1 6
..$ no_extra_calendar_window : logi [1:2] FALSE FALSE
..$ no_extra_restrictions : logi [1:2] FALSE FALSE
$ n_extra_calendar_dates : int 4
$ n_restricted_pre_parameters : int 4
$ n_zero_loading_links : int 7
$ no_extra_calendar_window : logi FALSE
$ no_extra_restrictions : logi FALSE
$ restriction_is_identity : logi FALSE
$ free_post_param_indices : int [1:6] 2 3 4 5 9 10
$ restricted_post_param_indices: int [1:4] 1 6 7 8
$ assumptions : chr &amp;quot;Common start fixed exogenously. Baseline PT-post assumptions are retained at every qualified causal date, inclu&amp;quot;| __truncated__
$ pretest_interpretation : chr &amp;quot;Unrestricted direct pre-comparisons retain the full requested nonreference pretrend null. Pre-start contrasts c&amp;quot;| __truncated__
$pt_assumption
[1] &amp;quot;all&amp;quot;
$pt_start
[1] 1
$n_extra_calendar_dates
[1] 4
$n_restricted_pre_parameters
[1] 4
$no_extra_restrictions
[1] FALSE
g ref pt_start baseline_status n_extra_calendar_dates n_extra_represented_dates
1 3 2 1 stored_reference 1 1
2 5 4 1 stored_reference 3 3
n_restricted_pre_parameters n_zero_loading_links no_extra_calendar_window no_extra_restrictions
1 1 1 FALSE FALSE
2 3 6 FALSE FALSE
target.id group time role available estimate_pt_post std.error_pt_post estimate_pt_all
1 ATT(g=3,t=3) 3 3 post TRUE 1.007945 0.05946479 0.9608242
2 ATT(g=3,t=4) 3 4 post TRUE 1.298627 0.06084339 1.2861154
3 ATT(g=3,t=5) 3 5 post TRUE 1.528495 0.05908227 1.5149354
4 ATT(g=3,t=6) 3 6 post TRUE 1.728774 0.06184471 1.7112627
5 ATT(g=5,t=5) 5 5 post TRUE 1.053470 0.06544368 1.0475218
6 ATT(g=5,t=6) 5 6 post TRUE 1.143902 0.06712190 1.1287508
std.error_pt_all population_truth
1 0.04654280 1.00
2 0.04694743 1.25
3 0.04989078 1.50
4 0.05269931 1.75
5 0.05129701 1.00
6 0.05333004 1.25
target.id group time role available estimate_pt_post std.error_pt_post estimate_pt_all
7 pre(g=3,t=2) 3 2 pre TRUE 0.0733146863 0.07110089 0.0733146863
8 pre(g=5,t=2) 5 2 pre TRUE -0.0003672074 0.07605146 -0.0003672074
9 pre(g=5,t=3) 5 3 pre TRUE 0.1281262590 0.07029130 0.1281262590
10 pre(g=5,t=4) 5 4 pre TRUE -0.0634728529 0.08537601 -0.0634728529
std.error_pt_all population_truth
7 0.07110089 0
8 0.07605146 0
9 0.07029130 0
10 0.08537601 0
$pt_post
$pt_post$status
[1] &amp;quot;computed&amp;quot;
$pt_post$&amp;lt;NA&amp;gt;
NULL
$pt_post$df
[1] 4
$pt_post$W
[1] 4.768994
$pt_post$Wpval
[1] 0.3118316
$pt_all
$pt_all$status
[1] &amp;quot;computed&amp;quot;
$pt_all$&amp;lt;NA&amp;gt;
NULL
$pt_all$df
[1] 4
$pt_all$W
[1] 4.768994
$pt_all$Wpval
[1] 0.3118316
target.id group time role available estimate_pt_post std.error_pt_post estimate_pt_all
1 ATT(g=3,t=3) 3 3 post TRUE 1.007945 0.05946479 0.8167734
2 ATT(g=3,t=4) 3 4 post TRUE 1.298627 0.06084339 1.1234910
3 ATT(g=3,t=5) 3 5 post TRUE 1.528495 0.05908227 1.3036359
4 ATT(g=3,t=6) 3 6 post TRUE 1.728774 0.06184471 1.5002007
5 ATT(g=5,t=5) 5 5 post TRUE 1.053470 0.06544368 0.9324565
6 ATT(g=5,t=6) 5 6 post TRUE 1.143902 0.06712190 1.0072939
std.error_pt_all
1 0.04654280
2 0.04694743
3 0.04989078
4 0.05269931
5 0.05129701
6 0.05333004
target.id group time role available estimate_pt_post std.error_pt_post estimate_pt_all
7 pre(g=3,t=2) 3 2 pre TRUE -0.42668531 0.07110089 -0.42668531
8 pre(g=5,t=2) 5 2 pre TRUE -0.50036721 0.07605146 -0.50036721
9 pre(g=5,t=3) 5 3 pre TRUE 0.12812626 0.07029130 0.12812626
10 pre(g=5,t=4) 5 4 pre TRUE -0.06347285 0.08537601 -0.06347285
std.error_pt_all
7 0.07110089
8 0.07605146
9 0.07029130
10 0.08537601
$pulse_pt_post
$pulse_pt_post$status
[1] &amp;quot;computed&amp;quot;
$pulse_pt_post$&amp;lt;NA&amp;gt;
NULL
$pulse_pt_post$df
[1] 4
$pulse_pt_post$W
[1] 57.4808
$pulse_pt_post$Wpval
[1] 9.807315e-12
$pulse_pt_all
$pulse_pt_all$status
[1] &amp;quot;computed&amp;quot;
$pulse_pt_all$&amp;lt;NA&amp;gt;
NULL
$pulse_pt_all$df
[1] 4
$pulse_pt_all$W
[1] 57.4808
$pulse_pt_all$Wpval
[1] 9.807315e-12
&lt;/code>&lt;/pre>
&lt;/details>
&lt;h2 id="result">Result&lt;/h2>
&lt;p>As documented in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/#where-the-result-records-the-choice">Parallel trends&lt;/a>, &lt;code>fit$chained$pt&lt;/code> records the parallel trends configuration:&lt;/p>
&lt;ul>
&lt;li>&lt;code>fit_pt_post$chained$pt&lt;/code> records &lt;code>pt_assumption = &amp;quot;post&amp;quot;&lt;/code> and &lt;code>pt_start = NULL&lt;/code>.&lt;/li>
&lt;li>&lt;code>fit_pt_all$chained$pt&lt;/code> records &lt;code>pt_assumption = &amp;quot;all&amp;quot;&lt;/code>, &lt;code>pt_start = 1&lt;/code>, &lt;code>n_extra_calendar_dates&lt;/code>, &lt;code>n_restricted_pre_parameters&lt;/code>, &lt;code>no_extra_restrictions&lt;/code>, the assumption text, and &lt;code>by_cohort&lt;/code> (with columns &lt;code>g&lt;/code>, &lt;code>ref&lt;/code>, &lt;code>pt_start&lt;/code>, &lt;code>n_extra_calendar_dates&lt;/code>, &lt;code>n_extra_represented_dates&lt;/code>, &lt;code>n_restricted_pre_parameters&lt;/code>, &lt;code>no_extra_calendar_window&lt;/code>, and &lt;code>no_extra_restrictions&lt;/code> for &lt;code>g = 3, ref = 2&lt;/code> and &lt;code>g = 5, ref = 4&lt;/code>).&lt;/li>
&lt;li>In &lt;code>baseline_table&lt;/code> and &lt;code>pulse_table&lt;/code>, rows with &lt;code>role == &amp;quot;post&amp;quot;&lt;/code> report the six posttreatment effects $(g, t) \in {(3, 3), (3, 4), (3, 5), (3, 6), (5, 5), (5, 6)}$ with population truth $1 + 0.25(t - g)$, while rows with &lt;code>role == &amp;quot;pre&amp;quot;&lt;/code> report the consecutive unrestricted preperiod comparisons $(3, 2), (5, 2), (5, 3), (5, 4)$.&lt;/li>
&lt;/ul>
&lt;h2 id="interpretation">Interpretation&lt;/h2>
&lt;h3 id="baseline-law-versus-pre-baseline-pulse-law">Baseline law versus pre baseline pulse law&lt;/h3>
&lt;p>On &lt;code>panel&lt;/code>, both &lt;code>fit_pt_post&lt;/code> and &lt;code>fit_pt_all&lt;/code> impose true population restrictions and, under the usual identification and large sample regularity conditions, are consistent for $\text{ATT}(g, t) = 1 + 0.25(t - g)$. Their finite sample point estimates and standard errors can differ because &lt;code>fit_pt_all&lt;/code> imposes pre reference zero differential restrictions from period $1$ up to each cohort&amp;rsquo;s reference period in the two step GMM solve. A difference can reflect those restrictions and is not by itself evidence of a coding error; an unexplained difference still merits investigation. A smaller standard error is not guaranteed in every cell or finite draw (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/#restrictions-can-change-information-and-robustness">How to compare precision&lt;/a>).&lt;/p>
&lt;p>On &lt;code>pulse_panel&lt;/code>, the $+0.5$ untreated pulse at period $1$ leaves all untreated changes from period $2$ onward unchanged. Because cohort reference periods are $2$ and $4$ and any bridge through period $1$ under &lt;code>PT-post&lt;/code> cancels the unrestricted period $1$ to $2$ differential, &lt;code>fit_pulse_post&lt;/code> remains consistent for $\text{ATT}(g, t) = 1 + 0.25(t - g)$. By contrast, &lt;code>fit_pulse_all&lt;/code> (&lt;code>pt_start = 1&lt;/code>) constrains the period $1$ to $2$ untreated differential to zero when its population value is $-0.5$. Those false restrictions can bias the posttreatment estimates through the joint GMM combination, although neither bias in every cell nor a pretrend test rejection is guaranteed in a particular finite draw.&lt;/p>
&lt;h3 id="unrestricted-preperiod-reports-pretrend-availability-and-choosing-pt_start">Unrestricted preperiod reports, pretrend availability, and choosing &lt;code>pt_start&lt;/code>&lt;/h3>
&lt;ol>
&lt;li>&lt;strong>Preperiod cells (&lt;code>role == &amp;quot;pre&amp;quot;&lt;/code>) are never zeroed out by &lt;code>PT-all&lt;/code>:&lt;/strong> Under both &lt;code>PT-post&lt;/code> and &lt;code>PT-all&lt;/code>, reported preperiod cells are direct, unrestricted comparisons, and restricted zero pre parameters never supply the unconditional Wald test (&lt;code>W&lt;/code>, &lt;code>Wpval&lt;/code>).&lt;/li>
&lt;li>&lt;strong>Full pretrend test availability can be &lt;code>&amp;quot;unavailable&amp;quot;&lt;/code>:&lt;/strong> &lt;code>att_gt()&lt;/code> computes &lt;code>W&lt;/code> and &lt;code>Wpval&lt;/code> only when every declared nonreference &lt;code>&amp;quot;pre&amp;quot;&lt;/code> cell is available and the joint covariance passes its Cholesky and conditioning check; with failed support or covariance checks, &lt;code>W&lt;/code> and &lt;code>Wpval&lt;/code> are &lt;code>NULL&lt;/code> and &lt;code>fit$chained$pretest$status&lt;/code> is &lt;code>&amp;quot;unavailable&amp;quot;&lt;/code> with its reason. In other settings, no declared preperiod comparison gives &lt;code>&amp;quot;not_applicable&amp;quot;&lt;/code>, while &lt;code>compute_inffunc = FALSE&lt;/code> gives &lt;code>&amp;quot;not_computed&amp;quot;&lt;/code> (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#pretrend-tests">Results&lt;/a>).&lt;/li>
&lt;li>&lt;strong>Never choose &lt;code>pt_start&lt;/code> to fit a pretest:&lt;/strong> Select &lt;code>pt_start&lt;/code> substantively from domain knowledge before viewing estimates, standard errors, or pretrend tests (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/#choosing-the-start-date">Parallel trends&lt;/a>). A single script or single draw does not establish coverage or efficiency; repeated sample evidence remains pending.&lt;/li>
&lt;/ol>
&lt;h2 id="next-step">Next step&lt;/h2>
&lt;ul>
&lt;li>Read &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>, &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>, &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>, and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>, or return to &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>.&lt;/li>
&lt;/ul>
&lt;h2 id="references">References&lt;/h2>
&lt;ul>
&lt;li>Bellégo, C., Benatia, D. and Dortet-Bernadet, V. (2025). The Chained Difference-in-Differences. &lt;em>Journal of Econometrics&lt;/em>. &lt;a href="https://doi.org/10.1016/j.jeconom.2024.105783" target="_blank" rel="noopener">https://doi.org/10.1016/j.jeconom.2024.105783&lt;/a>&lt;/li>
&lt;li>Callaway, B. and Sant&amp;rsquo;Anna, P. H. C. (2021). Difference-in-Differences with Multiple Time Periods. &lt;em>Journal of Econometrics&lt;/em> 225(2). &lt;a href="https://doi.org/10.1016/j.jeconom.2020.12.001" target="_blank" rel="noopener">https://doi.org/10.1016/j.jeconom.2020.12.001&lt;/a>&lt;/li>
&lt;/ul>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 14 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;strong>Add PT-all restrictions&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>Chained GMM weighting and covariance regularization</title><link>https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/</guid><description>&lt;p>Results below were produced on October 29, 2026 with &lt;code>cdid&lt;/code> 1.1.0.0, &lt;code>did&lt;/code> 2.5.1 and &lt;code>DRDID&lt;/code> 1.3.0 under R 4.5.2, using the displayed seeds where applicable. These are individual examples; they do not establish repeated-sample coverage. OR/DR calls shown here explicitly retain pooled slopes; the current default uses separate comparison regressions.&lt;/p>
&lt;p>Chained estimation combines two-period comparison moments across the retained catalog to recover group-time treatment effects. It separately reports direct, unrestricted pre-period comparisons (&lt;a href="https://doi.org/10.1016/j.jeconom.2024.105783" target="_blank" rel="noopener">Bellego, Benatia, and Dortet-Bernadet 2025&lt;/a>; &lt;a href="https://doi.org/10.1016/j.jeconom.2020.12.001" target="_blank" rel="noopener">Callaway and Sant&amp;rsquo;Anna 2021&lt;/a>). This page explains how the generalized method of moments (GMM) criterion is formed, how exact structural reductions and Tikhonov covariance regularization work under feasible two-step weighting, how moment-covariance singularity differs from parameter identification, and how point-estimate weighting is kept separate from sandwich and multiplier inference.&lt;/p>
&lt;h2 id="moment-conditions-and-the-quadratic-objective">Moment conditions and the quadratic objective&lt;/h2>
&lt;p>Let $\hat{d}$ denote the $M \times 1$ vector of primitive two-period comparison estimates in the retained comparison catalog. Each entry of $\hat{d}$ compares outcome changes between an ordered pair of stored calendar dates for a target cohort against its admissible control pool (never-treated or not-yet-treated units, including any valid fixed-horizon control-pool reuses in the catalog), constructed using the selected treatment adjustment (&lt;code>est_method&lt;/code>) and missing-outcome correction (&lt;code>selection&lt;/code> and &lt;code>selection_est_method&lt;/code>).&lt;/p>
&lt;p>Let $\theta$ denote the GMM model parameters: post-treatment effects and any pre-period trend differentials left free by the chosen parallel-trends model. PT-ctrl equates represented pre-reference trends across clean control cohorts while leaving target pre-reference trajectories free, and PT-all restricts represented pre-reference differentials to zero; these model parameters are distinct from direct, unrestricted pre-period cells reported for the pretrend test. Let $d$ denote the vector of population comparison means and $A$ the known $M \times p$ design mapping $\theta$ to them. Under sufficient parallel-trends, observation-reconstruction, overlap and nuisance-model conditions, with the required regularity,&lt;/p>
&lt;p>$$
d = A\theta, \qquad \hat{d} \xrightarrow{p} d
$$&lt;/p>
&lt;p>This is a population moment restriction and a large-sample statement, not a claim that nuisance-adjusted sample comparisons are unbiased. Given a symmetric positive-semidefinite $M \times M$ weighting matrix $W$, the chained GMM estimator minimizes the quadratic form&lt;/p>
&lt;p>$$
Q_W(\theta) = (\hat{d} - A\theta)' W (\hat{d} - A\theta),
$$&lt;/p>
&lt;p>and recovers each supported post-treatment target $\tau_j = c_j'\theta$ as a linear contrast of the fitted parameter vector $\hat{\theta}$.&lt;/p>
&lt;p>Several properties follow directly from this formulation:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Sufficient conditions for recovery.&lt;/strong> Validity of every retained comparison under the maintained parallel-trends, observation-selection, overlap and nuisance-model conditions, identification of $c_j$ from the row space of $A$, and standard GMM regularity are sufficient for consistency. They are not necessary in every special case: misspecification can cancel in a target contrast. Such cancellation is not a general robustness guarantee.&lt;/li>
&lt;li>&lt;strong>What $W$ changes when moments are valid.&lt;/strong> When the full moment conditions hold and $W$ converges in probability to a positive-definite limit $W_0$ that preserves the rank of $A$, changing $W$ can change the linear combination of overidentifying comparisons used to reconstruct $\tau_j$ and its asymptotic and finite-sample precision. It does not change the population target.&lt;/li>
&lt;li>&lt;strong>No finite-sample unbiasedness or arbitrary-$W$ guarantee.&lt;/strong> Feasible two-step GMM estimates $W$ from the same sample used to form $\hat{d}$. Inserting a data-dependent weighting matrix does not establish exact finite-sample unbiasedness, and asymptotic validity does not hold for arbitrary unstable or data-adaptive choices of $W$.&lt;/li>
&lt;li>&lt;strong>Sensitivity to incompatible moments.&lt;/strong> If the population limits of the retained comparisons cannot all be represented by one $A\theta$ (for example after invalid trend or observation restrictions), the moments are incompatible. Misspecification alone need not imply incompatibility or bias in every contrast. Under the relevant convergence conditions, the limiting criterion defines a weighted pseudo-target that generally depends on the limiting weights.&lt;/li>
&lt;li>&lt;strong>Moment-covariance ridge is not a parameter penalty.&lt;/strong> When the estimated moment covariance is regularized before inversion to form $W$, the positive ridge is added to the &lt;em>moment covariance matrix&lt;/em>, not to $A&amp;rsquo;WA$ and not as an $L_2$ penalty on $\theta$. It imposes no shrinkage target on ATT and supplies no identifying restrictions on $\theta$. A particular estimate can nevertheless move closer to or farther from zero when its comparison weights change.&lt;/li>
&lt;/ul>
&lt;h2 id="public-weighting-and-covariance-options">Public weighting and covariance options&lt;/h2>
&lt;p>Two arguments of &lt;code>cdid::att_gt()&lt;/code> configure the GMM criterion in chained mode, supplemented by two optional tuning entries in &lt;code>control&lt;/code>:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Argument or &lt;code>control&lt;/code> entry&lt;/th>
&lt;th>Default&lt;/th>
&lt;th>Accepted values&lt;/th>
&lt;th>Meaning&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>gmm_weighting&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;optimal&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;optimal&amp;quot;&lt;/code>, &lt;code>&amp;quot;two_step&amp;quot;&lt;/code>, &lt;code>&amp;quot;identity&amp;quot;&lt;/code>, &lt;code>&amp;quot;within&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;optimal&amp;quot;&lt;/code> selects feasible two-step GMM using the unit-level moment covariance; &lt;code>&amp;quot;two_step&amp;quot;&lt;/code> is an explicit alias for &lt;code>&amp;quot;optimal&amp;quot;&lt;/code>; &lt;code>&amp;quot;identity&amp;quot;&lt;/code> selects explicit unweighted GMM in the full catalog metric; &lt;code>&amp;quot;within&amp;quot;&lt;/code> weights moments by the inverse of the analytical covariance of within-unit changes under uncorrelated level shocks. See &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining&lt;/a> for the conditions for matching stacked fixed-effect regression.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>gmm_covariance&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;tikhonov&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;tikhonov&amp;quot;&lt;/code>&lt;/td>
&lt;td>Singular or near-singular moment-covariance handler under feasible two-step weighting. &lt;code>&amp;quot;moore_penrose&amp;quot;&lt;/code> is deferred and refused.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>control$condition_trigger&lt;/code>&lt;/td>
&lt;td>&lt;code>1e-10&lt;/code>&lt;/td>
&lt;td>finite numeric scalar in $(0, 1)$&lt;/td>
&lt;td>Reciprocal spectral condition threshold $\tau_{\mathrm{cond}}$ below which &lt;code>&amp;quot;tikhonov&amp;quot;&lt;/code> covariance regularization is triggered.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>control$ridge_relative&lt;/code>&lt;/td>
&lt;td>&lt;code>1e-4&lt;/code>&lt;/td>
&lt;td>finite positive numeric scalar&lt;/td>
&lt;td>Relative ridge multiplier $\alpha_{\mathrm{ridge}}$ applied to the full-catalog trace scale when regularization is triggered.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Supplying &lt;code>&amp;quot;two_step&amp;quot;&lt;/code> selects the same feasible two-step estimator as &lt;code>&amp;quot;optimal&amp;quot;&lt;/code> and records in &lt;code>fit$chained$covariance_handling&lt;/code> that the alias was used. Passing &lt;code>gmm_covariance = &amp;quot;moore_penrose&amp;quot;&lt;/code> is refused by the request validator with class &lt;code>&amp;quot;cdid_chained_request_input_error&amp;quot;&lt;/code>. Unsupported cutoff entries in &lt;code>control&lt;/code>, such as &lt;code>mp_cutoff&lt;/code>, instead raise &lt;code>&amp;quot;cdid_chained_public_control_error&amp;quot;&lt;/code>. Both inherit &lt;code>&amp;quot;cdid_error&amp;quot;&lt;/code>; Moore-Penrose pseudoinverse weighting is deferred and has no supported interface.&lt;/p>
&lt;h2 id="exact-structural-reductions-and-the-full-comparison-metric">Exact structural reductions and the full comparison metric&lt;/h2>
&lt;p>Before examining the sample moment covariance, &lt;code>cdid&lt;/code> applies proved exact structural reductions when proved linear identities reconstruct the full catalog from retained comparisons (for example, on baseline built-in IPW routes where distinct candidate rows share the exact same cohort, control pool, and observation mask).&lt;/p>
&lt;p>Suppose the full catalog contains $M$ comparisons and proved exact equivalences express the $M \times 1$ residual vector in terms of $L \le M$ retained comparison rows through a sparse $M \times L$ reconstruction matrix $E$:&lt;/p>
&lt;p>$$
\hat{d} - A\theta = E(\hat{d}_r - A_r\theta), \qquad G = E&amp;rsquo;E = C&amp;rsquo;C,
$$&lt;/p>
&lt;p>where $G$ is the symmetric positive-definite $L \times L$ Gram matrix of the reduction and $C$ is its upper-triangular Cholesky factor. When no structural reduction applies, $L = M$ and $G = C = I_M$.&lt;/p>
&lt;p>Preserving $G = E&amp;rsquo;E$ is essential for three reasons:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Exact preservation of the original $M$-comparison objective.&lt;/strong> Any full-catalog weighting matrix becomes $E&amp;rsquo;WE$ on the $L$ retained rows. In particular, under &lt;code>gmm_weighting = &amp;quot;identity&amp;quot;&lt;/code>, the full-catalog unweighted objective is
$$
(\hat{d} - A\theta)' I_M (\hat{d} - A\theta) = (\hat{d}_r - A_r\theta)' E&amp;rsquo;E (\hat{d}_r - A_r\theta) = |C(\hat{d}_r - A_r\theta)|_2^2.
$$
The reduced solver therefore whitens the retained system by $C$ so that &lt;code>&amp;quot;identity&amp;quot;&lt;/code> still minimizes the exact sum of squares over all $M$ original catalog comparisons, rather than replacing $G$ by a naive $I_L$ in reduced coordinates.&lt;/li>
&lt;li>&lt;strong>No arbitrary row dropping or spanning-tree subsetting.&lt;/strong> Correlation alone does not justify removing comparison rows; an exact reduction needs a proved reconstruction identity, which can involve linear combinations rather than identical rows. Discarding correlated rows, deduplicating rows without preserving $G = E&amp;rsquo;E$, or restricting the catalog to a minimal identification forest would alter the estimator and is never performed.&lt;/li>
&lt;li>&lt;strong>Algebraic identity is not extra sample information.&lt;/strong> When two catalog entries evaluate the exact same sample difference on the same units, or when consecutive changes of the same balanced units telescope to a long change, the extra row repeats existing sample variation rather than adding independent information. Exact reduction removes structural duplication without changing the criterion.&lt;/li>
&lt;/ol>
&lt;h2 id="covariance-conditioning-and-tikhonov-regularization">Covariance conditioning and Tikhonov regularization&lt;/h2>
&lt;p>Under &lt;code>gmm_weighting = &amp;quot;optimal&amp;quot;&lt;/code> (or &lt;code>&amp;quot;two_step&amp;quot;&lt;/code>), let $\widehat{V}_r$ denote the $L \times L$ comparison covariance on the solver&amp;rsquo;s weighting scale, formed from complete unit-level link influence functions. This unit-IF/asymptotic normalization need not equal the estimated covariance of $\hat d_r$ itself. A common positive rescaling of $\widehat V_r$ rescales its trace-proportional ridge equally and multiplies the criterion by a constant, leaving its minimizer unchanged. To respect the original $M$-comparison geometry when $L &amp;lt; M$, conditioning and regularization are defined in the $C$-transformed coordinates where the full-catalog identity metric $G = C&amp;rsquo;C$ becomes $I_L$. Define the transformed $L \times L$ symmetric covariance matrix&lt;/p>
&lt;p>$$
B = C \widehat{V}_r C'.
$$&lt;/p>
&lt;p>Adding an isotropic ridge $\lambda I_M$ in the original $M$-comparison coordinates corresponds in the reduced transformed coordinates to replacing $B$ by $B + \lambda I_L = C(\widehat{V}_r + \lambda G^{-1})C'$. The effective reduced weighting matrix is therefore&lt;/p>
&lt;p>$$
W_r(\lambda) = C'(B + \lambda I_L)^{-1} C = \left(\widehat{V}_r + \lambda G^{-1}\right)^{-1},
$$&lt;/p>
&lt;p>which reduces to $(\widehat{V}_r + \lambda I_M)^{-1}$ when $G = I_M$, and otherwise scales the ridge inversely with $G$ so that identical original comparisons receive the same metric weight regardless of how exact reduction grouped them.&lt;/p>
&lt;h3 id="how-the-handler-chooses-a-branch">How the handler chooses a branch&lt;/h3>
&lt;p>After checking that $\widehat{V}&lt;em>r$ is finite and exactly symmetric and forming a symmetric finite $B$, the estimator computes a symmetric eigendecomposition of $B$ with minimum and maximum eigenvalues $d&lt;/em>{\min}(B)$ and $d_{\max}(B)$, checks that the eigendecomposition residual lies within floating-point roundoff bounds, and evaluates the reciprocal spectral condition ratio&lt;/p>
&lt;p>$$
\rho = \frac{\max(d_{\min}(B), 0)}{d_{\max}(B)}
$$&lt;/p>
&lt;p>(with $\rho = 0$ if $B = 0$). Materially negative eigenvalues or diagonal entries abort the fit; small negative eigenvalues consistent with floating-point roundoff are accepted only when $\widehat{V}_r$ carries authenticated unit-IF Gram construction provenance. This authenticates the covariance construction for the roundoff diagnosis; it is not a per-fit numerical error certificate.&lt;/p>
&lt;p>If the initial eigensystem exceeds the reconstruction residual bound, the implementation attempts one QR reorthogonalization with Rayleigh values. It accepts the refined eigensystem only when it meets the same bound, &lt;code>100 * L * .Machine$double.eps * ||B||_F&lt;/code>. The covariance matrix, definiteness checks and ridge policy are unchanged. &lt;code>fit$chained$covariance_handling$conditioning$eigensystem_refinement&lt;/code> records whether this refinement was used and the original residual. A failed refinement still refuses the fit.&lt;/p>
&lt;p>The weighting step then follows one of four branches, recorded in &lt;code>fit$chained$covariance_handling&lt;/code>:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Branch&lt;/th>
&lt;th>Condition&lt;/th>
&lt;th>Effective reduced weight and solve&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;strong>Well-conditioned unregularized solve&lt;/strong>&lt;/td>
&lt;td>$B$ is positive definite, $\rho \ge \tau_{\mathrm{cond}}$, retained dimension $L$ does not exceed the sample rank bound from contributing unit rows, and ordinary Cholesky factorization of $\widehat V_r$ and the subsequent solve pass their checks&lt;/td>
&lt;td>$W_r(0) = C' B^{-1} C = \widehat{V}_r^{-1}$, implemented by Cholesky whitening of $\widehat V_r$ and pivoted QR factorization on the whitened design without invoking the singular-covariance handler&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Tikhonov covariance ridge&lt;/strong>&lt;/td>
&lt;td>$B \ne 0$ and $\rho &amp;lt; \tau_{\mathrm{cond}}$, $d_{\min}(B) = 0$, $d_{\min}(B) &amp;lt; 0$ within authenticated Gram roundoff, $L$ exceeds the sample rank upper bound, or unregularized Cholesky of $\widehat V_r$ fails after valid covariance diagnosis&lt;/td>
&lt;td>$W_r(\lambda) = C'(B + \lambda I_L)^{-1}C$ with $s = \mathrm{tr}(B)/M$ and $\lambda = \alpha_{\mathrm{ridge}} s$, solved by Cholesky factorization of $B + \lambda I_L$ and pivoted QR&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Exact-zero covariance limit&lt;/strong>&lt;/td>
&lt;td>$\widehat{V}_r = 0$ and $B = 0$ identically&lt;/td>
&lt;td>Separate scale-free full-catalog least-squares rule with $\lambda = 0$ and reduced weight $G = C&amp;rsquo;C$ (whitened by $C$), paired with the actual zero sandwich covariance and zero-scale inference diagnostics&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Refusal on invalid covariance or failed solve&lt;/strong>&lt;/td>
&lt;td>$\widehat{V}_r$ or $B$ is nonfinite or materially indefinite, or the Cholesky or whitened-QR factorization fails its conditioning or residual bounds&lt;/td>
&lt;td>Call stops with an error inheriting &lt;code>&amp;quot;cdid_error&amp;quot;&lt;/code>; no estimate is returned&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Note three implementation details of this rule:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Trace scale uses the full catalog dimension $M$.&lt;/strong> In the Tikhonov branch, the scale is $s = \mathrm{tr}(B) / M$, where $M$ is the full catalog comparison count and $\mathrm{tr}(B) = \mathrm{tr}(\widehat{V}_r G)$ equals the trace of the full $M \times M$ moment covariance.&lt;/li>
&lt;li>&lt;strong>Stable factorizations rather than explicit matrix inversion.&lt;/strong> Neither the unregularized branch nor the Tikhonov branch forms an explicit dense inverse $B^{-1}$ or $(B + \lambda I_L)^{-1}$. The unregularized branch whitens with the Cholesky factor of $\widehat V_r$; the ridge branch uses that of $B+\lambda I_L$. Both then apply pivoted QR to the whitened design, and verify factor conditioning and relative residuals before accepting the solution.&lt;/li>
&lt;li>&lt;strong>No silent fallbacks or ad hoc repairs.&lt;/strong> The default values &lt;code>condition_trigger = 1e-10&lt;/code> and &lt;code>ridge_relative = 1e-4&lt;/code> are numerical implementation settings, not universal optimal tuning parameters and not thresholds for parameter identification. If $B + \lambda I_L$ or the whitened QR factor still fails its conditioning guards, &lt;code>cdid&lt;/code> refuses the fit rather than increasing $\lambda$ iteratively, clipping eigenvalues, adding random jitter, dropping comparisons, or switching automatically to &lt;code>gmm_weighting = &amp;quot;identity&amp;quot;&lt;/code>.&lt;/li>
&lt;/ul>
&lt;h2 id="covariance-singularity-versus-parameter-identification">Covariance singularity versus parameter identification&lt;/h2>
&lt;p>Singular or near-singular moment covariance $\Sigma = \mathrm{Cov}(\hat{d})$ and non-identification of a target parameter $\tau = c'\theta$ are distinct mathematical phenomena. Moment covariance is a property of the stochastic errors across comparison rows. Parameter identification is a property of the design matrix $A$ and the maintained population restrictions $d = A\theta$.&lt;/p>
&lt;p>The two analytical examples below illustrate why neither implies the other. Here $\hat d$ denotes noisy comparisons and $d = E[\hat d]$ their population means. These are algebraic examples, not executed R outputs.&lt;/p>
&lt;h3 id="example-1-singular-moment-covariance-with-an-identified-parameter">Example 1: Singular moment covariance with an identified parameter&lt;/h3>
&lt;p>Suppose a scalar treatment effect $\theta$ is measured by two comparison moments that carry the exact same zero-mean shock $u$ with $\mathrm{Var}(u) = \sigma^2 &amp;gt; 0$:&lt;/p>
&lt;p>$$
\hat d_1 = \theta + u, \qquad \hat d_2 = \theta + u, \qquad A = \begin{pmatrix} 1 \ 1 \end{pmatrix}, \qquad \Sigma = \sigma^2 \begin{pmatrix} 1 &amp;amp; 1 \ 1 &amp;amp; 1 \end{pmatrix}.
$$&lt;/p>
&lt;p>Here the design matrix $A$ has column rank $1$, so $\theta = E[\hat d_1] = E[\hat d_2]$ is identified. Yet the $2 \times 2$ covariance matrix $\Sigma$ has rank $1$ and determinant $0$ because $\hat d_1 - \hat d_2 = 0$ with probability one. In chained estimation, a singular or near-singular covariance of this kind can arise when duplicate or telescoping comparison paths span the same dates. If the duplication is an exact structural equivalence, reduction collapses the pair to $L = 1$ with $G = E&amp;rsquo;E = 2$ and positive scalar variance. If this duplicated pair is retained without a structural reduction, Tikhonov regularization replaces $\Sigma$ with $\Sigma + \lambda I_2$, which has eigenvalues $2\sigma^2 + \lambda$ and $\lambda &amp;gt; 0$, allowing the GMM step to form a well-defined convex combination of $\hat d_1$ and $\hat d_2$. Because both moments share the same shock $u$, the second moment adds no independent information, and the estimator variance remains $\sigma^2$.&lt;/p>
&lt;h3 id="example-2-nonsingular-moment-covariance-with-an-unidentified-parameter">Example 2: Nonsingular moment covariance with an unidentified parameter&lt;/h3>
&lt;p>Suppose instead that two parameters $\theta = (\theta_1, \theta_2)'$ (for instance, an unrestricted pre-period trend differential $\theta_1$ and a post-treatment effect $\theta_2$) enter a single available comparison moment with $\mathrm{Var}(u) = \sigma^2 &amp;gt; 0$:&lt;/p>
&lt;p>$$
\hat d_1 = \theta_1 + \theta_2 + u, \qquad A = \begin{pmatrix} 1 &amp;amp; 1 \end{pmatrix}, \qquad \Sigma = \begin{pmatrix} \sigma^2 \end{pmatrix}.
$$&lt;/p>
&lt;p>Here the $1 \times 1$ moment covariance $\Sigma = (\sigma^2)$ is strictly positive definite and well conditioned, but $A$ has rank $1 &amp;lt; 2$. The moment identifies the sum $\theta_1 + \theta_2$, while the individual contrast $\tau = \theta_2 = (0, 1)\theta$ is not in the row space of $A$. Adding a covariance ridge $\lambda &amp;gt; 0$ changes the scalar weight from $1/\sigma^2$ to $1/(\sigma^2 + \lambda)$, so the normal matrix&lt;/p>
&lt;p>$$
A'(\Sigma + \lambda)^{-1}A = \frac{1}{\sigma^2 + \lambda} \begin{pmatrix} 1 &amp;amp; 1 \ 1 &amp;amp; 1 \end{pmatrix}
$$&lt;/p>
&lt;p>still has rank $1$ and cannot be inverted for $\theta_1$ and $\theta_2$ separately. Because covariance regularization acts on $\Sigma$ rather than adding rows to $A$ or penalizing $\theta$, it never turns an unidentified parameter into an estimable one.&lt;/p>
&lt;h3 id="catalog-support-model-refusals-and-precision-rankings">Catalog support, model refusals, and precision rankings&lt;/h3>
&lt;p>In &lt;code>cdid&lt;/code>, post-treatment target availability is determined from the catalog design $A$ before and independently of covariance regularization. Reported pre-period cells retain their separate direct-comparison support rules:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Unsupported catalog cells (&lt;code>NA&lt;/code>).&lt;/strong> When a requested target contrast $c_j'\theta$ does not lie in the row space of $A$ under the retained comparison catalog and the chosen &lt;code>pt_assumption&lt;/code>, the cell is marked unavailable (&lt;code>available = FALSE&lt;/code>), its estimate and standard error are set to &lt;code>NA&lt;/code>, and &lt;code>fit$chained$support_status&lt;/code> and &lt;code>fit$chained$support_reason&lt;/code> record why the catalog cannot recover it. This is a statement about support in the retained comparison catalog, not a claim that the effect is unidentifiable in the population under every possible assumption.&lt;/li>
&lt;li>&lt;strong>Computation and nuisance refusals (errors).&lt;/strong> Separation or unresolved rank/support failure in a required model after its allowed preprocessing, or a covariance or QR factorization that fails the applicable checks, stops the call with an error rather than returning &lt;code>NA&lt;/code> for affected cells or dropping comparisons.&lt;/li>
&lt;li>&lt;strong>No uniform precision dominance.&lt;/strong> With independent units, valid moments, consistent covariance estimation, standard regularity and a nonsingular limiting covariance after exact reductions, the unregularized optimal branch has the usual asymptotic efficiency property within the retained moment set. That statement does not automatically extend to a ridge branch or to dependent units. Covariance ridge changes the weighting to obtain numerical conditioning when $B$ is singular or ill-conditioned, and &lt;code>&amp;quot;identity&amp;quot;&lt;/code> uses fixed full-catalog weights. In finite samples, estimation noise in $\widehat{V}_r$ can offset theoretical efficiency gains, so neither &lt;code>&amp;quot;optimal&amp;quot;&lt;/code>, nor a particular &lt;code>ridge_relative&lt;/code>, nor &lt;code>&amp;quot;identity&amp;quot;&lt;/code> is guaranteed to produce smaller finite-sample variance or mean squared error in every setting.&lt;/li>
&lt;/ul>
&lt;h2 id="sandwich-inference-multiplier-bootstrap-and-clustering">Sandwich inference, multiplier bootstrap, and clustering&lt;/h2>
&lt;p>The regularized weighting matrix $W_r(\lambda)$ is used only to compute the point estimates $\hat{\theta}$ and the resulting linear target loadings. It is &lt;strong>never&lt;/strong> inverted to report parameter variance or standard errors.&lt;/p>
&lt;h3 id="complete-unit-level-influence-functions-and-v_analytical">Complete unit-level influence functions and &lt;code>V_analytical&lt;/code>&lt;/h3>
&lt;p>For a supported post-treatment target, the GMM solver computes the realized loading vector on the retained comparison moments and composes it with their complete influence functions. Separately reported pre-period cells use their direct auxiliary comparisons, not restricted GMM pretrend parameters. The reporting system retains complete original-unit influence functions across all $n$ rows of the unit table (&lt;code>fit$n&lt;/code> and &lt;code>fit$chained$frame&lt;/code>). These rows include frame-only units and units with fewer than two observed outcomes, and carry the uncertainty of every active nuisance channel: cohort and repeat-observation rates, observation-selection logits, actual-change imputation fits, treatment propensity logits, shared counterfactual outcome regressions, and (in &lt;code>cdid::aggte()&lt;/code>) estimated cohort shares.&lt;/p>
&lt;p>From the resulting $n \times J$ influence-function matrix (&lt;code>fit$inffunc&lt;/code>), the package forms the sandwich covariance matrix:&lt;/p>
&lt;ul>
&lt;li>&lt;code>fit$V_analytical&lt;/code> estimates the asymptotic covariance of $\sqrt{n}(\hat{\tau} - \tau)$ and equals &lt;strong>$n$ times&lt;/strong> the estimated covariance matrix of the cell estimates.&lt;/li>
&lt;li>Analytical standard errors are &lt;code>sqrt(diag(fit$V_analytical) / fit$n)&lt;/code>, also stored in &lt;code>fit$chained$analytical_se&lt;/code>.&lt;/li>
&lt;li>When bootstrap inference is actually performed, &lt;code>fit$se&lt;/code> and &lt;code>std.error&lt;/code> in &lt;code>cdid::tidy(fit)&lt;/code> use multiplier interquartile-range standard errors on the estimate scale; otherwise, with inference computed, they use the analytical values. Requested flags alone do not establish what ran: inspect &lt;code>fit$chained$inference&lt;/code> for the effective flags, kind and draws. Empty or exactly zero families may need no draws.&lt;/li>
&lt;li>With &lt;code>compute_inffunc = FALSE&lt;/code>, the covariance work needed for GMM weighting is retained, so &lt;code>fit$att&lt;/code> equals that under &lt;code>TRUE&lt;/code>. Returned &lt;code>inffunc&lt;/code>, &lt;code>V_analytical&lt;/code>, &lt;code>W&lt;/code> and &lt;code>Wpval&lt;/code> are &lt;code>NULL&lt;/code>, &lt;code>se&lt;/code> is a numeric vector of &lt;code>NA&lt;/code>, effective &lt;code>bstrap&lt;/code> and &lt;code>cband&lt;/code> are &lt;code>FALSE&lt;/code>, and the inference kind is &lt;code>&amp;quot;not_computed&amp;quot;&lt;/code>. &lt;code>aggte()&lt;/code> refuses this point-only result.&lt;/li>
&lt;/ul>
&lt;p>For &lt;code>att_gt()&lt;/code> cells, &lt;code>bstrap = FALSE, cband = TRUE&lt;/code> gives analytical standard errors and pointwise normal intervals, with no draws. Group, dynamic and calendar aggregate bins instead retain a multiplier band with analytical standard errors and a warning under those flags. Overall summaries and simple aggregation use pointwise normal intervals. The &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#uncertainty">results reference&lt;/a> specifies each endpoint; separate families do not form one joint band.&lt;/p>
&lt;h3 id="clustering-and-asymptotic-regularity">Clustering and asymptotic regularity&lt;/h3>
&lt;p>When &lt;code>clustervars&lt;/code> supplies a cluster variable (at most one variable in addition to &lt;code>idname&lt;/code>), rows of &lt;code>fit$inffunc&lt;/code> are summed within clusters before computing &lt;code>fit$V_analytical&lt;/code> and drawing cluster-level Rademacher signs in the multiplier bootstrap. Clustering affects inference only: point estimates &lt;code>fit$att&lt;/code> and the GMM weighting matrix $\widehat{V}_r$ remain unit-based. Consequently, &lt;code>&amp;quot;optimal&amp;quot;&lt;/code> weighting is unit-level feasible two-step GMM and is not claimed to be cluster-optimal.&lt;/p>
&lt;p>Treating feasible two-step or regularized GMM weights as fixed in the first-order influence function relies on standard large-sample regularity: valid moment conditions, asymptotically linear complete link estimators, consistent covariance estimation, and a stable limiting loading branch (either a well-conditioned positive-definite limit covariance or a fixed limiting regularization mapping). The package claims no finite-sample cancellation theorem, no uniform inference validity near covariance singularity boundaries or with few clusters, and no per-fit numerical error certificate (passing &lt;code>control = list(relative_accuracy = ...)&lt;/code> is refused with class &lt;code>&amp;quot;cdid_chained_public_accuracy_deferred&amp;quot;&lt;/code>). For the full statistical discussion of standard errors, simultaneous confidence bands, and pretrend tests, see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>, &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>, and the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#uncertainty">results reference&lt;/a>.&lt;/p>
&lt;h2 id="inspecting-gmm-weighting-tuning-and-resource-controls">Inspecting GMM weighting, tuning, and resource controls&lt;/h2>
&lt;p>Changing &lt;code>gmm_weighting&lt;/code> or overriding &lt;code>condition_trigger&lt;/code> and &lt;code>ridge_relative&lt;/code> in &lt;code>control&lt;/code> is an explicit estimator choice recorded in the returned object. It is not an automatic fix for an unidentified effect, a violated parallel-trends restriction, or an invalid missing-outcome or treatment specification.&lt;/p>
&lt;p>The snippet below reuses &lt;code>sim_panel&lt;/code> from &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/#prepare-the-panel">Get started&lt;/a>; run that preparation step first.&lt;/p>
&lt;pre>&lt;code class="language-r"># Helper comparing default feasible two-step GMM, explicit identity weighting,
# and an explicit covariance-regularization / resource control override on the
# same prepared panel (and optional unit frame).
fit_gmm_variants &amp;lt;- function(data, frame = NULL) {
fit_opt &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
data = data, frame = frame,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
gmm_weighting = &amp;quot;optimal&amp;quot;, gmm_covariance = &amp;quot;tikhonov&amp;quot;,
bstrap = FALSE, cband = FALSE
)
# &amp;quot;two_step&amp;quot; is a documented alias for &amp;quot;optimal&amp;quot;
fit_alias &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
data = data, frame = frame,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
gmm_weighting = &amp;quot;two_step&amp;quot;, gmm_covariance = &amp;quot;tikhonov&amp;quot;,
bstrap = FALSE, cband = FALSE
)
# Explicit unweighted GMM in the full catalog metric
fit_id &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
data = data, frame = frame,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
gmm_weighting = &amp;quot;identity&amp;quot;,
bstrap = FALSE, cband = FALSE
)
# Explicit covariance-ridge tuning and optional resource limits
fit_tuned &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
data = data, frame = frame,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
gmm_weighting = &amp;quot;optimal&amp;quot;, gmm_covariance = &amp;quot;tikhonov&amp;quot;,
control = list(
condition_trigger = 1e-8,
ridge_relative = 1e-3,
numeric_workspace_bytes = 1073741824,
counted_work_limit = Inf
),
bstrap = FALSE, cband = FALSE
)
list(optimal = fit_opt, two_step = fit_alias, identity = fit_id, tuned = fit_tuned)
}
fits &amp;lt;- fit_gmm_variants(sim_panel)
# Compare cell estimates and analytical standard errors
cdid::tidy(fits$optimal)[, c(&amp;quot;target.id&amp;quot;, &amp;quot;role&amp;quot;, &amp;quot;available&amp;quot;, &amp;quot;estimate&amp;quot;, &amp;quot;std.error&amp;quot;)]
cdid::tidy(fits$identity)[, c(&amp;quot;target.id&amp;quot;, &amp;quot;role&amp;quot;, &amp;quot;available&amp;quot;, &amp;quot;estimate&amp;quot;, &amp;quot;std.error&amp;quot;)]
cdid::glance(fits$optimal)
&lt;/code>&lt;/pre>
&lt;details>
&lt;summary>Console output&lt;/summary>
&lt;pre>&lt;code class="language-text"> target.id role available estimate std.error
1 pre(g=3,t=2) pre TRUE -0.05831968 0.06369725
2 ATT(g=3,t=3) post TRUE 1.00962257 0.06316956
3 ATT(g=3,t=4) post TRUE 1.32743963 0.06163755
4 ATT(g=3,t=5) post TRUE 1.48374276 0.06297661
5 ATT(g=3,t=6) post TRUE 1.84780436 0.06303371
target.id role available estimate std.error
1 pre(g=3,t=2) pre TRUE -0.05831968 0.06369725
2 ATT(g=3,t=3) post TRUE 1.00962257 0.06316956
3 ATT(g=3,t=4) post TRUE 1.32743963 0.06163755
4 ATT(g=3,t=5) post TRUE 1.48374276 0.06297661
5 ATT(g=3,t=6) post TRUE 1.84780436 0.06303371
nobs ngroup ntime control.group est.method estimator n.requested n.available
1 2000 1 6 nevertreated dr chained doubly robust GMM 5 5
band.family inference clustered
1 pointwise_normal_over_supported_ids analytic FALSE
&lt;/code>&lt;/pre>
&lt;/details>
&lt;h3 id="resource-controls-versus-statistical-and-numerical-limits">Resource controls versus statistical and numerical limits&lt;/h3>
&lt;p>Use the &lt;code>control&lt;/code> list to adjust workspace and bootstrap settings. &lt;code>numeric_workspace_bytes&lt;/code> limits the numerical arrays that &lt;code>cdid&lt;/code> plans to allocate and defaults to one GiB. &lt;code>counted_work_limit&lt;/code> is optional and limits the estimated operations for a calculation. Use &lt;code>chunk_rows&lt;/code> to set the number of units processed at once or &lt;code>workers&lt;/code> to allow additional bootstrap workers.&lt;/p>
&lt;p>These settings describe allocations and estimated work within the fit. Total R process memory and elapsed time depend on the machine and the rest of the R session. See &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#the-control-list">The control list&lt;/a> for accepted values.&lt;/p>
&lt;h2 id="related-pages">Related pages&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#gmm-weighting-and-covariance-regularization">Options reference: GMM weighting and covariance regularization&lt;/a> and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#the-control-list">The control list&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#the-chained-record">Results reference: The chained record&lt;/a> and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#uncertainty">Uncertainty&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends: PT-post and PT-all&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/li>
&lt;/ul>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 15 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;strong>GMM weighting and covariance regularization&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>Choose an observation model for missing outcomes</title><link>https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/</guid><description>&lt;p>Results below were produced on October 29, 2026 with &lt;code>cdid&lt;/code> 1.1.0.0, &lt;code>did&lt;/code> 2.5.1 and &lt;code>DRDID&lt;/code> 1.3.0 under R 4.5.2, using the displayed seeds where applicable. These are individual examples; they do not establish repeated-sample coverage. OR/DR calls shown here explicitly retain pooled slopes; the current default uses separate comparison regressions.&lt;/p>
&lt;p>When outcomes are missing at some dates, chained DiD uses the changes of units observed at both dates of each pair. You decide how those observed changes stand in for the study population: with no observation equation, with a logit for each date, or with a logit for each pair of dates, and with more or fewer shared slopes. This example makes that choice on one small simulated panel in which the right answer is known by construction. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a> defines the assumptions and models.&lt;/p>
&lt;h2 id="the-illustration">The illustration&lt;/h2>
&lt;p>The panel has 2000 units and six dates, &lt;code>time&lt;/code> from 1 to 6. Each unit has a binary covariate &lt;code>x&lt;/code>, equal to 1 with probability 0.5 and fixed over time, and a cohort &lt;code>g&lt;/code> drawn independently of &lt;code>x&lt;/code>, the unit component and outcome noise: 0 (never treated) or 3, with equal probability. With a unit component &lt;code>alpha&lt;/code> from a standard normal distribution and independent normal noise with standard deviation 0.5, the untreated outcome is&lt;/p>
&lt;pre>&lt;code>Y0(t) = alpha + 0.1 * t + 0.3 * x * t + noise
&lt;/code>&lt;/pre>
&lt;p>From date 3 onward, units of cohort 3 add the effect &lt;code>1 + 0.25 * (t - 3) + 0.5 * x&lt;/code>. In both cohorts, each outcome is observed with probability&lt;/p>
&lt;pre>&lt;code>q_t(x) = plogis(-0.3 + 0.1 * (t - 1) + 0.4 * x)
&lt;/code>&lt;/pre>
&lt;p>Given &lt;code>x&lt;/code>, observation is independent across dates and independent of potential outcomes, noise and cohort. This does not assert unconditional independence from outcomes, which also depend on &lt;code>x&lt;/code>. All units have the same sampling weight, so no &lt;code>weightsname&lt;/code> is used.&lt;/p>
&lt;h2 id="generate-the-panel">Generate the panel&lt;/h2>
&lt;pre>&lt;code class="language-r">set.seed(20261031)
n_units &amp;lt;- 2000
n_periods &amp;lt;- 6
x &amp;lt;- rbinom(n_units, size = 1, prob = 0.5)
g &amp;lt;- sample(c(0, 3), size = n_units, replace = TRUE)
alpha &amp;lt;- rnorm(n_units)
sim &amp;lt;- data.frame(
id = rep(seq_len(n_units), each = n_periods),
time = rep(seq_len(n_periods), times = n_units),
g = rep(g, each = n_periods),
x = rep(x, each = n_periods)
)
# Untreated outcome, then the actual outcome with the effect from date 3 on.
y_untreated &amp;lt;- rep(alpha, each = n_periods) +
0.1 * sim$time + 0.3 * sim$x * sim$time +
rnorm(nrow(sim), mean = 0, sd = 0.5)
treated_now &amp;lt;- sim$g == 3 &amp;amp; sim$time &amp;gt;= 3
sim$y_complete &amp;lt;- y_untreated +
treated_now * (1 + 0.25 * (sim$time - 3) + 0.5 * sim$x)
# Given x, the observation mask is independent across dates
# and independent of potential outcomes, noise and cohort.
sim$observed &amp;lt;- runif(nrow(sim)) &amp;lt;
plogis(-0.3 + 0.1 * (sim$time - 1) + 0.4 * sim$x)
# Analysis data: every unit and date row, NA where the outcome is missing.
panel &amp;lt;- sim[c(&amp;quot;id&amp;quot;, &amp;quot;time&amp;quot;, &amp;quot;g&amp;quot;, &amp;quot;x&amp;quot;)]
panel$y &amp;lt;- ifelse(sim$observed, sim$y_complete, NA)
# Unit table: one row per study unit, including units observed once or never.
units &amp;lt;- data.frame(id = seq_len(n_units), g = g, x = x)
# Number of units by number of observed outcomes, 0 to 6.
table(tapply(!is.na(panel$y), panel$id, sum))
&lt;/code>&lt;/pre>
&lt;p>Output:&lt;/p>
&lt;pre>&lt;code class="language-text">0 1 2 3 4 5 6
27 126 411 585 514 283 54
&lt;/code>&lt;/pre>
&lt;p>&lt;code>sim&lt;/code> stores the latent complete outcome &lt;code>y_complete&lt;/code> and the original mask &lt;code>observed&lt;/code> for checks; the fits read only &lt;code>panel&lt;/code> and &lt;code>units&lt;/code>. &lt;code>panel&lt;/code> keeps every unit and date row and codes a missing outcome as &lt;code>NA&lt;/code>, never as a filled value (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>), and &lt;code>units&lt;/code> lists every unit, including units observed once or never.&lt;/p>
&lt;h2 id="the-target">The target&lt;/h2>
&lt;p>The effects are those of cohort 3 in the study population that &lt;code>units&lt;/code> lists:&lt;/p>
&lt;pre>&lt;code>ATT(3, t) = 1 + 0.25 * (t - 3) + 0.5 * E[x | g = 3] for t = 3, 4, 5, 6
&lt;/code>&lt;/pre>
&lt;p>In the population, &lt;code>x&lt;/code> has mean 0.5 in both cohorts, so ATT(3, t) is &lt;code>1.25 + 0.25 * e&lt;/code> at event time &lt;code>e = t - 3&lt;/code>. For the 2000 generated units, &lt;code>E[x | g = 3]&lt;/code> becomes &lt;code>mean(units$x[units$g == 3])&lt;/code>, so their ATT(3, 3) is generally not exactly 1.25. With one treated cohort, the dynamic aggregate at event time &lt;code>e&lt;/code> has the value of ATT(3, 3 + e).&lt;/p>
&lt;h2 id="three-comparable-fits">Three comparable fits&lt;/h2>
&lt;p>The fits share the data, the unit table, &lt;code>xformla = ~ x&lt;/code>, never treated controls, treatment DR, PT-post and &lt;code>base_period = &amp;quot;varying&amp;quot;&lt;/code>. They keep &lt;code>compute_inffunc = TRUE&lt;/code>, the default, so their analytical standard errors come from complete influence functions. Only the handling of missing outcomes changes.&lt;/p>
&lt;pre>&lt;code class="language-r">fit_none &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
xformla = ~ x, data = panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
pt_assumption = &amp;quot;post&amp;quot;, base_period = &amp;quot;varying&amp;quot;,
selection = &amp;quot;none&amp;quot;,
bstrap = FALSE, cband = FALSE
)
fit_date &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
xformla = ~ x, data = panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
pt_assumption = &amp;quot;post&amp;quot;, base_period = &amp;quot;varying&amp;quot;,
selection = &amp;quot;conditional_mtar&amp;quot;,
selection_est_method = &amp;quot;ipw&amp;quot;,
selection_model = &amp;quot;independent_period_logit&amp;quot;,
selection_pooling = &amp;quot;separate&amp;quot;,
selection_universe = &amp;quot;F&amp;quot;,
bstrap = FALSE, cband = FALSE
)
fit_pair &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
xformla = ~ x, data = panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
pt_assumption = &amp;quot;post&amp;quot;, base_period = &amp;quot;varying&amp;quot;,
selection = &amp;quot;conditional_mtar&amp;quot;,
selection_est_method = &amp;quot;ipw&amp;quot;,
selection_model = &amp;quot;pair_logit&amp;quot;,
selection_pooling = &amp;quot;separate&amp;quot;,
selection_universe = &amp;quot;F&amp;quot;,
bstrap = FALSE, cband = FALSE
)
&lt;/code>&lt;/pre>
&lt;p>&lt;code>fit_none&lt;/code> fits no observation model. &lt;code>fit_date&lt;/code> and &lt;code>fit_pair&lt;/code> use the canonical names &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code> and &lt;code>selection_est_method = &amp;quot;ipw&amp;quot;&lt;/code>, and both state &lt;code>selection_pooling = &amp;quot;separate&amp;quot;&lt;/code>, the default for either model.&lt;/p>
&lt;h2 id="what-each-choice-assumes">What each choice assumes&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Choice&lt;/th>
&lt;th>What must hold&lt;/th>
&lt;th>Here&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>&lt;/td>
&lt;td>within each cohort, units observed at both dates of a pair have the cohort&amp;rsquo;s mean change&lt;/td>
&lt;td>fails&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>&lt;/td>
&lt;td>the same equality given &lt;code>x&lt;/code> and cohort, for every cohort and every pair the estimator uses&lt;/td>
&lt;td>holds&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>date logits, in addition&lt;/td>
&lt;td>observation at the two dates is independent given cohort and &lt;code>x&lt;/code>, and each date logit is correct&lt;/td>
&lt;td>holds&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>pair logits, in addition&lt;/td>
&lt;td>the logit of observing both dates is correct in every needed cell&lt;/td>
&lt;td>holds with separate cells&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;strong>Representative means.&lt;/strong> The baseline condition is weaker than independence of observation and changes within a cohort, and it needs no model. Independence given &lt;code>x&lt;/code> does not imply it. Here units with &lt;code>x = 1&lt;/code> are observed more often, so they make up a larger share of the units observed at both dates than of their cohort, and changes depend on &lt;code>x&lt;/code>: through the trend &lt;code>0.3 * x * t&lt;/code> and, for cohort 3, through the effect &lt;code>0.5 * x&lt;/code>. The observed mean changes are therefore not representative, in particular for the treated cohort, and &lt;code>fit_none&lt;/code> is generally biased for the population effects. Treatment adjustment on &lt;code>x&lt;/code> does not correct this (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/#doubly-robust-treatment-estimation-dr">Treatment adjustment&lt;/a>).&lt;/p>
&lt;p>&lt;strong>Conditional mean trends missing at random.&lt;/strong> The corrected fits assume the mean equality given &lt;code>x&lt;/code> and cohort, which covers the actual changes of cohort 3, effects included. It holds here because the design satisfies a stronger condition: given &lt;code>x&lt;/code>, the mask is independent of the cohort and of every potential outcome. Such conditional independence is sufficient, not required. No fitted observation model can establish either condition; in an application it rests on knowledge of how outcomes went missing.&lt;/p>
&lt;p>&lt;strong>Independence across dates.&lt;/strong> A correct logit for each date implies nothing about how observation at one date relates to observation at another. The date model adds independence of the two dates, given cohort and &lt;code>x&lt;/code>, as a separate assumption and divides by &lt;code>q_s(x) * q_t(x)&lt;/code>, which in this design is exactly the probability of observing both dates. The pair model estimates that probability directly, so the two fits estimate their denominators differently. Their population pair probabilities agree under this design, but the fitted probabilities need not agree in a sample. Persistent dropout usually violates the date model, because a unit that leaves does not return.&lt;/p>
&lt;p>&lt;strong>Flexibility.&lt;/strong> Pair logits allow any dependence between the two dates but need more cells and slopes: each cohort has up to fifteen pairs of dates and only six dates. Date logits need fewer parameters and the extra independence assumption. Neither is automatically better; choose from how observation arises in your data, not from which fit looks more precise.&lt;/p>
&lt;h2 id="how-much-the-logits-share">How much the logits share&lt;/h2>
&lt;p>&lt;code>selection_pooling&lt;/code> restricts only the slopes. Each cell, a cohort and date for date logits or a cohort and pair for pair logits, keeps its own intercept whenever &lt;code>selection_xformla&lt;/code> has an intercept, as the inherited &lt;code>~ x&lt;/code> does.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;code>selection_pooling&lt;/code>&lt;/th>
&lt;th>Date logits&lt;/th>
&lt;th>Pair logits&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>&amp;quot;separate&amp;quot;&lt;/code> (default)&lt;/td>
&lt;td>a slope for each cohort and date: correct here&lt;/td>
&lt;td>a slope for each cohort and pair: correct here, saturated on binary &lt;code>x&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;within_cohort&amp;quot;&lt;/code>&lt;/td>
&lt;td>one slope per cohort across its dates: correct here&lt;/td>
&lt;td>one slope per cohort across its pairs: generally misspecified&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;across_cohorts&amp;quot;&lt;/code>&lt;/td>
&lt;td>one slope for all cells: correct here&lt;/td>
&lt;td>one slope for all cells: generally misspecified&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>These entries are algebraic properties of this design, not fit results or guarantees. With binary &lt;code>x&lt;/code>, a logit with an intercept and a slope reproduces any two probabilities, so separate pair cells are saturated; with a covariate taking more values, the logit of a product of two date probabilities is generally not linear in it. Even here the implied pair slope changes from pair to pair, so shared pair slopes are generally misspecified under this date law. The pooled date logits are correct only because this particular law gives every date and both cohorts the slope 0.4. No pooling choice is guaranteed the smaller standard error. Pooling is a restriction you choose: the package never pools automatically and never changes the model after a failure.&lt;/p>
&lt;h2 id="formula-fitting-set-and-unit-table">Formula, fitting set and unit table&lt;/h2>
&lt;ul>
&lt;li>&lt;code>selection_xformla&lt;/code> can be set independently of &lt;code>xformla&lt;/code>; its default &lt;code>NULL&lt;/code> inherits &lt;code>xformla&lt;/code>, here &lt;code>~ x&lt;/code>. Covariates added only to the observation model need their own scientific justification: different predictor lists require restrictions sufficient for each model, and supplying a formula does not establish them (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#two-covariate-formulas">Two covariate formulas&lt;/a>).&lt;/li>
&lt;li>&lt;code>selection_universe = &amp;quot;F&amp;quot;&lt;/code>, the default, fits the observation model on the whole unit table, and date logits require it. The subsets &lt;code>&amp;quot;A&amp;quot;&lt;/code> and &lt;code>&amp;quot;B&amp;quot;&lt;/code> exist only for pair logits under observation weighting, with the transport conditions in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#advanced-fitting-the-observation-model-on-part-of-the-unit-table">Advanced: fitting the observation model on part of the unit table&lt;/a>.&lt;/li>
&lt;li>Every unit of &lt;code>units&lt;/code> stays in the analysis. A unit observed once or never supplies no change, but it enters the date or pair logits fitted on the whole unit table, counts in the response rates and keeps its row in the influence function.&lt;/li>
&lt;/ul>
&lt;h2 id="read-the-results">Read the results&lt;/h2>
&lt;pre>&lt;code class="language-r">fits &amp;lt;- list(none = fit_none, date = fit_date, pair = fit_pair)
simple &amp;lt;- lapply(fits, cdid::aggte, type = &amp;quot;simple&amp;quot;)
data.frame(
fit = names(simple),
estimate = vapply(simple, function(a) a$overall.att, numeric(1)),
std.error = vapply(simple, function(a) a$overall.se, numeric(1))
)
# Known values for these generated units, computed from the design.
# ATT(3, t) for t = 3 to 6, also the dynamic values for e = 0 to 3:
1 + 0.25 * (3:6 - 3) + 0.5 * mean(units$x[units$g == 3])
# The simple aggregate, the average of those four effects:
1.375 + 0.5 * mean(units$x[units$g == 3])
&lt;/code>&lt;/pre>
&lt;details>
&lt;summary>Console output&lt;/summary>
&lt;pre>&lt;code class="language-text">fit estimate std.error
none none 1.675595 0.03914203
date date 1.623850 0.03817623
pair pair 1.628628 0.03800096
[1] 1.251773 1.501773 1.751773 2.001773
[1] 1.626773
&lt;/code>&lt;/pre>
&lt;/details>
&lt;p>The simple aggregate averages ATT(3, 3) to ATT(3, 6); its population value is 1.625. The lines computed from the design are known targets for these units, not estimates, and are kept apart from the fitted aggregates. Under the required identification and large sample regularity conditions, both corrected fits target these effects. Their finite sample estimates and standard errors can differ; neither is guaranteed the smaller standard error. &lt;code>fit_none&lt;/code> is generally biased.&lt;/p>
&lt;p>&lt;code>fit$chained$selection&lt;/code> records the adjustment, the observation model, the pooling choice, the fitting set, the assumptions and the counts of fitted models. For observation weighting its &lt;code>method&lt;/code> entry keeps the legacy record name &lt;code>&amp;quot;corollary1&amp;quot;&lt;/code>, with &lt;code>canonical_assumption = &amp;quot;conditional_mtar&amp;quot;&lt;/code>; the requests above use the canonical names. &lt;code>fit$chained$nuisance_diagnostics&lt;/code> holds the fitted cells, the pooling groups with their ranks and slopes, the counterfactual regression, the treatment logits and the support of each cell; see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#where-the-result-records-the-choice">Where the result records the choice&lt;/a>.&lt;/p>
&lt;h2 id="when-a-fit-stops">When a fit stops&lt;/h2>
&lt;p>Each active logit needs a finite interior fit of full rank. A date or pair cell in which every unit is observed, or none is, cannot fit a logit with its own free intercept, so the fit stops with an error; pooled slopes keep those intercepts and do not avoid it. Separation, boundary solutions and deficient rank are refused in the same way. Version 1.1.0.0 floors finite inverse observation denominators at &lt;code>1e-6&lt;/code>; it does not retry failed fits or replace another model. When clipping binds, original-target robustness and inference need further conditions (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#probability-safeguards">Probability safeguards&lt;/a>). The date probabilities of this design are bounded away from zero and one, but that does not guarantee a successful fit in every draw.&lt;/p>
&lt;h2 id="related-pages">Related pages&lt;/h2>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes for missing outcomes&lt;/a> reuses this panel for change imputation and the augmented correction. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Compare model robustness across treatment and missing outcome adjustments&lt;/a> works through misspecified models in both layers, and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Clustered inference, confidence bands, and pretrend tests&lt;/a> and the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#uncertainty">results reference&lt;/a> explain the reported uncertainty.&lt;/p>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 11 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;strong>Choose an observation model&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>Choose IPW, OR or DR in an incomplete panel</title><link>https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/</guid><description>&lt;p>Results below were produced on October 29, 2026 with &lt;code>cdid&lt;/code> 1.1.0.0, &lt;code>did&lt;/code> 2.5.1 and &lt;code>DRDID&lt;/code> 1.3.0 under R 4.5.2, using the displayed seeds where applicable. These are individual examples; they do not establish repeated-sample coverage. OR/DR calls shown here explicitly retain the historical pooled specification; the current default uses separate comparison regressions.&lt;/p>
&lt;p>In chained difference in differences (&lt;code>cdid&lt;/code>, extending Bellégo, Benatia and Dortet-Bernadet 2025 and Callaway and Sant&amp;rsquo;Anna 2021), &lt;code>est_method&lt;/code> selects the &lt;strong>treatment adjustment&lt;/strong> method: inverse probability weighting (IPW, &lt;code>&amp;quot;ipw&amp;quot;&lt;/code>), outcome regression (OR, &lt;code>&amp;quot;reg&amp;quot;&lt;/code>), or doubly robust estimation (DR, &lt;code>&amp;quot;dr&amp;quot;&lt;/code>). That choice is separate from &lt;strong>handling missing outcomes&lt;/strong> (&lt;code>selection&lt;/code> and &lt;code>selection_est_method&lt;/code>), which governs how observed outcome changes represent the study population in the unit table (&lt;code>frame&lt;/code>).&lt;/p>
&lt;p>This worked example compares IPW, OR, and DR on the same incomplete panel, study population, and target effects, holding &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>, &lt;code>control_group = &amp;quot;nevertreated&amp;quot;&lt;/code>, &lt;code>pt_assumption = &amp;quot;post&amp;quot;&lt;/code>, &lt;code>base_period = &amp;quot;varying&amp;quot;&lt;/code>, and the inference flags fixed. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a> reuses the exact panel and unit table generated here.&lt;/p>
&lt;h2 id="question">Question&lt;/h2>
&lt;p>When an incomplete panel tracks a study population in a unit table (&lt;code>frame&lt;/code>) with a baseline covariate &lt;code>x&lt;/code> that shifts both cohort membership and untreated outcome trends, and missingness is independent of covariates, cohort, and potential outcomes, how do &lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>est_method = &amp;quot;reg&amp;quot;&lt;/code>, and &lt;code>est_method = &amp;quot;dr&amp;quot;&lt;/code> compare on the same data, why does this data generating law satisfy both the treatment propensity model and the shared counterfactual outcome regression, and how should an analyst choose among them in practice?&lt;/p>
&lt;h2 id="data">Data&lt;/h2>
&lt;p>Consider a study population of $N = 2000$ units in &lt;code>units&lt;/code> (&lt;code>frame&lt;/code>) across $T = 6$ stored calendar dates $t \in {1, 2, 3, 4, 5, 6}$. Each unit $i$ has an independent baseline covariate $X_i \sim \text{Uniform}(-1, 1)$. Cohort $G_i \in {0, 3, 5}$ (&lt;code>first_treat&lt;/code>) is assigned by multinomial weights $1$ for never treated controls ($G_i = 0$), $\text{odds}_3(X_i) = \exp(0.2 + 0.6 X_i)$ for cohort $3$, and $\text{odds}_5(X_i) = \exp(-0.2 - 0.4 X_i)$ for cohort $5$. With $\text{total}(X_i) = 1 + \text{odds}_3(X_i) + \text{odds}_5(X_i)$, a uniform draw $U_i \sim \text{Uniform}(0, 1)$ allocates unit $i$ with probabilities $p_3(X_i) = \text{odds}_3(X_i) / \text{total}(X_i)$, $p_5(X_i) = \text{odds}_5(X_i) / \text{total}(X_i)$, and $p_0(X_i) = 1 / \text{total}(X_i)$.&lt;/p>
&lt;p>Untreated potential outcomes at date $t \in {1, \dots, 6}$ are $Y_{i,t}(0) = \alpha_i + 0.1 t + 0.3 X_i t + \varepsilon_{i,t}$, with independent unit effect $\alpha_i \sim \mathcal{N}(0, 1)$ and shock $\varepsilon_{i,t} \sim \mathcal{N}(0, 0.5^2)$ independent of $(G_i, X_i, \alpha_i)$. Actual latent outcomes are $Y_{i,t} = Y_{i,t}(0) + \mathbf{1}{G_i &amp;gt; 0, t \ge G_i}(1 + 0.25(t - G_i))$. No anticipation holds ($\text{anticipation} = 0$). For posttreatment dates $t \ge g$ of cohort $g \in {3, 5}$, the population target is $\text{ATT}(g, t) = 1 + 0.25(t - g)$, and the dynamic event time target at $e = t - g \ge 0$ is the same function $1 + 0.25 e$.&lt;/p>
&lt;p>Each unit and date outcome is observed independently with probability $0.5$. The panel &lt;code>panel&lt;/code> retains all $N \times T = 12000$ rows across dates $1$ to $6$ with &lt;code>NA&lt;/code> in &lt;code>y&lt;/code> when unobserved, and &lt;code>units&lt;/code> retains one row per study unit (&lt;code>id&lt;/code>, &lt;code>first_treat&lt;/code>, &lt;code>x&lt;/code>), including units with zero or one observed outcome.&lt;/p>
&lt;h2 id="assumptions">Assumptions&lt;/h2>
&lt;p>The three fits vary only &lt;code>est_method&lt;/code> (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>).&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Argument&lt;/th>
&lt;th>Setting&lt;/th>
&lt;th>Purpose&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>yname&lt;/code>, &lt;code>tname&lt;/code>, &lt;code>idname&lt;/code>, &lt;code>gname&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;y&amp;quot;&lt;/code>, &lt;code>&amp;quot;period&amp;quot;&lt;/code>, &lt;code>&amp;quot;id&amp;quot;&lt;/code>, &lt;code>&amp;quot;first_treat&amp;quot;&lt;/code>&lt;/td>
&lt;td>Outcome, stored calendar date ($1$ to $6$), unit ID, and cohort ($0, 3, 5$).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>xformla&lt;/code>, &lt;code>data&lt;/code>, &lt;code>frame&lt;/code>&lt;/td>
&lt;td>&lt;code>~ x&lt;/code>, &lt;code>panel&lt;/code>, &lt;code>units&lt;/code>&lt;/td>
&lt;td>Covariate design, $N \times T$ panel with &lt;code>NA&lt;/code> outcomes, and $N$ row unit table (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#chained-arguments">Options&lt;/a>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>control_group&lt;/code>, &lt;code>est_method&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;nevertreated&amp;quot;&lt;/code>, &lt;code>&amp;quot;ipw&amp;quot;&lt;/code> / &lt;code>&amp;quot;reg&amp;quot;&lt;/code> / &lt;code>&amp;quot;dr&amp;quot;&lt;/code>&lt;/td>
&lt;td>Compares treated cohorts with $G_i = 0$ across IPW, OR, and DR (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>selection&lt;/code>, &lt;code>pt_assumption&lt;/code>, &lt;code>base_period&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;none&amp;quot;&lt;/code>, &lt;code>&amp;quot;post&amp;quot;&lt;/code>, &lt;code>&amp;quot;varying&amp;quot;&lt;/code>&lt;/td>
&lt;td>Representative observed pair changes, &lt;code>PT-post&lt;/code>, and consecutive preperiod reports (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>bstrap&lt;/code>, &lt;code>cband&lt;/code>, &lt;code>compute_inffunc&lt;/code>&lt;/td>
&lt;td>&lt;code>FALSE&lt;/code>, &lt;code>FALSE&lt;/code>, &lt;code>TRUE&lt;/code>&lt;/td>
&lt;td>Analytical standard errors, pointwise normal intervals, and complete unit influence functions (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#inference-and-computation">Options&lt;/a>).&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="why-this-law-satisfies-both-treatment-models-and-baseline-missingness">Why this law satisfies both treatment models and baseline missingness&lt;/h3>
&lt;p>Passing &lt;code>xformla = ~ x&lt;/code> to IPW and OR does not automatically make both models match the population law: IPW fits risk set cohort logits, whereas the explicit &lt;code>outcome_pooling = &amp;quot;pooled&amp;quot;&lt;/code> used in this example fits one regression of control outcome changes across all comparison blocks (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>). Here both hold by construction:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Cancellation of $\alpha_i$ and conditional parallel trends:&lt;/strong> Differencing across any stored calendar pair $e = (s, t)$ with $s &amp;lt; t$ cancels $\alpha_i$, giving $Y_{i,t}(0) - Y_{i,s}(0) = 0.1(t - s) + 0.3 X_i (t - s) + (\varepsilon_{i,t} - \varepsilon_{i,s})$. Since $\varepsilon_{i,t}$ has mean zero given $(G_i, X_i)$, conditional parallel trends hold at all dates $1$ to $6$.&lt;/li>
&lt;li>&lt;strong>Representative baseline missingness (&lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>):&lt;/strong> Because observation has probability $0.5$ independently of $(G_i, X_i, \alpha_i, \varepsilon_{i,t})$, observed pair changes within each cohort are mean representative of that cohort in &lt;code>units&lt;/code>. The estimator uses empirical cohort pair response rates without fitting an observation model; this is not an exact finite sample recovery of the population mean change (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>).&lt;/li>
&lt;li>&lt;strong>Correct pairwise treatment propensity logits ($p$):&lt;/strong> Conditioning on $G_i \in {3, 0}$, the odds of cohort $3$ versus never treated controls are $p_3(X_i) / p_0(X_i) = \exp(0.2 + 0.6 X_i)$, with linear log odds $0.2 + 0.6 X_i$. Conditioning on $G_i \in {5, 0}$, the odds of cohort $5$ versus never treated controls are $p_5(X_i) / p_0(X_i) = \exp(-0.2 - 0.4 X_i)$, with linear log odds $-0.2 - 0.4 X_i$. Compact support $X_i \in [-1, 1]$ bounds the population probabilities away from 0 and 1. The independent observation mask preserves these linear odds in observed pair populations; multiplying by cohort specific response-rate constants can change the intercept, without introducing nonlinear terms in $X_i$. This does not guarantee support or a finite logit root in a realized sample.&lt;/li>
&lt;li>&lt;strong>Correct shared counterfactual outcome regression ($m$):&lt;/strong> With all dates $1, \dots, 6$ stored, the calendar step count is $L(e) = t - s$. The control mean change is $E[Y_{i,t}(0) - Y_{i,s}(0) \mid X_i, G_i = 0] = 0.1 L(e) + 0.3 L(e) X_i$, matching &lt;code>cdid&lt;/code>&amp;rsquo;s single pooled control regression $m_b(X_i) = \alpha(b) + L(e) X_i \beta$ with local block intercept $\alpha(b) = 0.1 L(e)$ and shared global slope $\beta = 0.3$ (&lt;code>n_regression_fits = 1&lt;/code>).&lt;/li>
&lt;li>&lt;strong>Why &lt;code>&amp;quot;notyettreated&amp;quot;&lt;/code> alters the pooled odds:&lt;/strong> For cohort $3$ before period $5$, &lt;code>&amp;quot;notyettreated&amp;quot;&lt;/code> pools $G_i = 0$ and $G_i = 5$. Under this multinomial law, the odds of $G_i = 3$ against $G_i \in {0, 5}$ are $\exp(0.2 + 0.6 X_i) / (1 + \exp(-0.2 - 0.4 X_i))$, whose log odds are nonlinear in $X_i$. Linear pairwise log odds against &lt;code>nevertreated&lt;/code> do not imply linear risk set log odds for a &lt;code>notyettreated&lt;/code> mixture. This is a model specification issue for that mixture, rather than a claim that NYT by itself forces a difference between &lt;code>cdid&lt;/code> and &lt;code>did&lt;/code>. The distinct fixed-horizon control-pool moments retained by chained estimation are explained in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/#a-balanced-nyt-example">Moving from did&lt;/a>.&lt;/li>
&lt;/ol>
&lt;h2 id="code">Code&lt;/h2>
&lt;pre>&lt;code class="language-r">set.seed(20261028)
n_units &amp;lt;- 2000L
n_periods &amp;lt;- 6L
x &amp;lt;- stats::runif(n_units, min = -1, max = 1)
odds3 &amp;lt;- exp(0.2 + 0.6 * x)
odds5 &amp;lt;- exp(-0.2 - 0.4 * x)
total_weight &amp;lt;- 1 + odds3 + odds5
p3 &amp;lt;- odds3 / total_weight
p5 &amp;lt;- odds5 / total_weight
p0 &amp;lt;- 1 / total_weight
u_cohort &amp;lt;- stats::runif(n_units)
first_treat &amp;lt;- ifelse(u_cohort &amp;lt; p3, 3L, ifelse(u_cohort &amp;lt; p3 + p5, 5L, 0L))
units &amp;lt;- data.frame(id = seq_len(n_units), first_treat = first_treat, x = x)
panel &amp;lt;- data.frame(
id = rep(units$id, each = n_periods),
period = rep(seq_len(n_periods), times = n_units),
first_treat = rep(units$first_treat, each = n_periods),
x = rep(units$x, each = n_periods)
)
alpha &amp;lt;- stats::rnorm(n_units, mean = 0, sd = 1)
eps &amp;lt;- stats::rnorm(nrow(panel), mean = 0, sd = 0.5)
y0 &amp;lt;- rep(alpha, each = n_periods) + 0.1 * panel$period + 0.3 * panel$x * panel$period + eps
treated_now &amp;lt;- panel$first_treat &amp;gt; 0L &amp;amp; panel$period &amp;gt;= panel$first_treat
effect &amp;lt;- ifelse(treated_now, 1 + 0.25 * (panel$period - panel$first_treat), 0)
y_complete &amp;lt;- y0 + effect
observed &amp;lt;- stats::runif(nrow(panel)) &amp;lt; 0.5
panel$y &amp;lt;- ifelse(observed, y_complete, NA_real_)
methods &amp;lt;- c(ipw = &amp;quot;ipw&amp;quot;, or = &amp;quot;reg&amp;quot;, dr = &amp;quot;dr&amp;quot;)
fits &amp;lt;- lapply(methods, function(m) {
cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
xformla = ~ x, data = panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = m, selection = &amp;quot;none&amp;quot;,
pt_assumption = &amp;quot;post&amp;quot;, base_period = &amp;quot;varying&amp;quot;, bstrap = FALSE, cband = FALSE
)
})
common_cols &amp;lt;- c(&amp;quot;target.id&amp;quot;, &amp;quot;group&amp;quot;, &amp;quot;time&amp;quot;, &amp;quot;role&amp;quot;, &amp;quot;available&amp;quot;, &amp;quot;estimate&amp;quot;, &amp;quot;std.error&amp;quot;)
cell_tables &amp;lt;- Map(function(fit, method_name) {
tab &amp;lt;- cdid::tidy(fit)[, common_cols]
tab$method &amp;lt;- method_name
tab$estimator_label &amp;lt;- fit$chained$estimator
tab$population_truth &amp;lt;- ifelse(tab$role == &amp;quot;post&amp;quot;, 1 + 0.25 * (tab$time - tab$group), 0)
tab
}, fits, names(fits))
per_cell_comparison &amp;lt;- do.call(rbind, cell_tables)
per_cell_comparison[per_cell_comparison$role == &amp;quot;post&amp;quot;, ]
dynamic_fits &amp;lt;- lapply(fits, cdid::aggte, type = &amp;quot;dynamic&amp;quot;)
dynamic_comparison &amp;lt;- do.call(rbind, Map(function(agg, method_name) {
data.frame(
method = method_name, event_time = agg$egt,
estimate = agg$att.egt, std.error = agg$se.egt,
population_truth = ifelse(agg$egt &amp;gt;= 0, 1 + 0.25 * agg$egt, 0)
)
}, dynamic_fits, names(dynamic_fits)))
dynamic_comparison
gt_plots &amp;lt;- lapply(fits, cdid::ggdid)
dynamic_plots &amp;lt;- lapply(dynamic_fits, cdid::ggdid)
&lt;/code>&lt;/pre>
&lt;details>
&lt;summary>Console output&lt;/summary>
&lt;pre>&lt;code class="language-text">target.id group time role available estimate std.error method
ipw.2 ATT(g=3,t=3) 3 3 post TRUE 1.011155 0.05960259 ipw
ipw.3 ATT(g=3,t=4) 3 4 post TRUE 1.305540 0.06123456 ipw
ipw.4 ATT(g=3,t=5) 3 5 post TRUE 1.538407 0.05912689 ipw
ipw.5 ATT(g=3,t=6) 3 6 post TRUE 1.744085 0.06290892 ipw
ipw.9 ATT(g=5,t=5) 5 5 post TRUE 1.053864 0.06549822 ipw
ipw.10 ATT(g=5,t=6) 5 6 post TRUE 1.139585 0.06709454 ipw
or.2 ATT(g=3,t=3) 3 3 post TRUE 1.022526 0.05780193 or
or.3 ATT(g=3,t=4) 3 4 post TRUE 1.290286 0.05976722 or
or.4 ATT(g=3,t=5) 3 5 post TRUE 1.529845 0.05911358 or
or.5 ATT(g=3,t=6) 3 6 post TRUE 1.723973 0.06180484 or
or.9 ATT(g=5,t=5) 5 5 post TRUE 1.047170 0.06530943 or
or.10 ATT(g=5,t=6) 5 6 post TRUE 1.136599 0.06704396 or
dr.2 ATT(g=3,t=3) 3 3 post TRUE 1.007945 0.05946479 dr
dr.3 ATT(g=3,t=4) 3 4 post TRUE 1.298627 0.06084339 dr
dr.4 ATT(g=3,t=5) 3 5 post TRUE 1.528495 0.05908227 dr
dr.5 ATT(g=3,t=6) 3 6 post TRUE 1.728774 0.06184471 dr
dr.9 ATT(g=5,t=5) 5 5 post TRUE 1.053470 0.06544368 dr
dr.10 ATT(g=5,t=6) 5 6 post TRUE 1.143902 0.06712190 dr
estimator_label population_truth
ipw.2 chained IPW-GMM 1.00
ipw.3 chained IPW-GMM 1.25
ipw.4 chained IPW-GMM 1.50
ipw.5 chained IPW-GMM 1.75
ipw.9 chained IPW-GMM 1.00
ipw.10 chained IPW-GMM 1.25
or.2 chained outcome regression/control-mean GMM 1.00
or.3 chained outcome regression/control-mean GMM 1.25
or.4 chained outcome regression/control-mean GMM 1.50
or.5 chained outcome regression/control-mean GMM 1.75
or.9 chained outcome regression/control-mean GMM 1.00
or.10 chained outcome regression/control-mean GMM 1.25
dr.2 chained doubly robust GMM 1.00
dr.3 chained doubly robust GMM 1.25
dr.4 chained doubly robust GMM 1.50
dr.5 chained doubly robust GMM 1.75
dr.9 chained doubly robust GMM 1.00
dr.10 chained doubly robust GMM 1.25
method event_time estimate std.error population_truth
ipw.1 ipw -3 -0.0036005082 0.07624331 0.00
ipw.2 ipw -2 0.1276100192 0.07024728 0.00
ipw.3 ipw -1 0.0207240855 0.05430503 0.00
ipw.4 ipw 0 1.0279996411 0.04434251 1.00
ipw.5 ipw 1 1.2400861096 0.04047772 1.25
ipw.6 ipw 2 1.5384065010 0.05912689 1.50
ipw.7 ipw 3 1.7440852287 0.06290892 1.75
or.1 or -3 0.0099445749 0.07412692 0.00
or.2 or -2 0.1330753901 0.07008427 0.00
or.3 or -1 0.0213751385 0.05350763 0.00
or.4 or 0 1.0322457015 0.04343659 1.00
or.5 or 1 1.2296705225 0.03912655 1.25
or.6 or 2 1.5298454025 0.05911358 1.50
or.7 or 3 1.7239726289 0.06180484 1.75
dr.1 dr -3 -0.0003672074 0.07605146 0.00
dr.2 dr -2 0.1281262590 0.07029130 0.00
dr.3 dr -1 0.0193646340 0.05420753 0.00
dr.4 dr 0 1.0259005597 0.04426626 1.00
dr.5 dr 1 1.2376021460 0.04021797 1.25
dr.6 dr 2 1.5284947291 0.05908227 1.50
dr.7 dr 3 1.7287739283 0.06184471 1.75
&lt;/code>&lt;/pre>
&lt;/details>
&lt;h2 id="result">Result&lt;/h2>
&lt;p>Each entry in &lt;code>fits&lt;/code> is a &lt;code>cdid_MP&lt;/code> object (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#group-time-results">Results&lt;/a>). In &lt;code>per_cell_comparison&lt;/code> and &lt;code>dynamic_comparison&lt;/code>, &lt;code>population_truth&lt;/code> records the known population parameter, kept distinct from sample estimates (&lt;code>estimate&lt;/code>) and analytical standard errors (&lt;code>std.error&lt;/code>):&lt;/p>
&lt;ul>
&lt;li>Cohort $3$ posttreatment cells $(3, 3), (3, 4), (3, 5), (3, 6)$ at event times $e = 0, 1, 2, 3$ have population truth $1.00, 1.25, 1.50, 1.75$; cohort $5$ cells $(5, 5), (5, 6)$ at $e = 0, 1$ have truth $1.00, 1.25$.&lt;/li>
&lt;li>&lt;code>fit$chained$estimator&lt;/code> is documented on every chained fit, whereas &lt;code>cdid::tidy(fit)&lt;/code> includes the optional &lt;code>estimator&lt;/code> column for OR and DR fits and for imputation or augmented missing outcome routes. Selecting &lt;code>common_cols&lt;/code> avoids assuming identical optional tidy columns across methods.&lt;/li>
&lt;li>&lt;code>fit$n&lt;/code> equals $2000$ for all three fits because &lt;code>frame = units&lt;/code> keeps every study unit in &lt;code>fit$inffunc&lt;/code> and in cohort shares.&lt;/li>
&lt;/ul>
&lt;h2 id="interpretation">Interpretation&lt;/h2>
&lt;h3 id="why-finite-sample-estimates-can-differ-across-ipw-or-dr-and-did">Why finite sample estimates can differ across IPW, OR, DR, and &lt;code>did&lt;/code>&lt;/h3>
&lt;p>Even when both $p$ and $m$ are correct in the population, IPW, OR, and DR solve different sample equations before two step GMM combination: IPW uses normalized Hajek weights from risk set logits, OR subtracts predictions $\hat{\alpha}(b) + L(e) X_i \hat{\beta}$ from one pooled control regression across all blocks, and DR applies IPW to the control regression residuals (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/#doubly-robust-treatment-estimation-dr">Treatment adjustment&lt;/a>). Their finite sample estimates and standard errors can therefore differ. Covariate imbalance does not force a difference: fitted corrections can coincide or cancel in particular samples.&lt;/p>
&lt;p>Passing the same &lt;code>xformla = ~ x&lt;/code> formula to &lt;code>cdid&lt;/code> and &lt;code>did&lt;/code> likewise does not imply identical finite sample OR or DR estimates: &lt;code>cdid&lt;/code> and &lt;code>did&lt;/code> both fit separate control regressions by default. This example explicitly uses &lt;code>outcome_pooling = &amp;quot;pooled&amp;quot;&lt;/code>, which shares a per-step slope across comparisons. Chaining can also combine a different set of comparisons, even with separate slopes. If the full fitted procedure coincides, including coefficient restrictions, nuisance fitting, retained comparisons and weights, point estimates should agree up to numerical rounding; method labels alone establish neither equality nor a difference. With incomplete outcomes and explicit &lt;code>allow_unbalanced_panel = TRUE&lt;/code>, ordinary mode uses &lt;code>did&lt;/code>&amp;rsquo;s RCS routines based on levels. With &lt;code>FALSE&lt;/code> or its ordinary mode default, it instead keeps complete cases and estimates changes within units. Each route has its own sampling conditions; the independent mask here is compatible with them, but their fitted constructions differ. Use &lt;code>mode = &amp;quot;ordinary&amp;quot;&lt;/code> when exact &lt;code>did&lt;/code> behavior is required (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/#why-can-balanced-results-differ-and-which-should-i-use">Moving from did&lt;/a>).&lt;/p>
&lt;h3 id="practical-choice-among-ipw-or-and-dr">Practical choice among IPW, OR, and DR&lt;/h3>
&lt;ul>
&lt;li>&lt;strong>IPW (&lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code>):&lt;/strong> Needs a credible risk set treatment logit $p$ and strict overlap for every active comparison, while leaving period specific covariate effects on untreated changes unrestricted.&lt;/li>
&lt;li>&lt;strong>OR (&lt;code>est_method = &amp;quot;reg&amp;quot;&lt;/code>):&lt;/strong> Needs a credible control change regression $m$, without fitting treatment logits. Default separate fits allow each comparison its own coefficients. The explicit pooled specification used here instead requires a constant per step slope $\beta$ on $L(e) z(X_i)$ across its blocks; misspecification in one block can then move $\hat{\beta}$ elsewhere.&lt;/li>
&lt;li>&lt;strong>DR (&lt;code>est_method = &amp;quot;dr&amp;quot;&lt;/code>, default):&lt;/strong> Consistent for each comparison if either $p$ or $m$ is correct, under valid missing outcome handling, parallel trends, no anticipation, overlap and the usual large sample regularity conditions. Both active fits must still satisfy their computation and support checks. If an active treatment logit separates or is rank deficient, or if a required reduced control regression remains rank deficient, is badly conditioned or fails required prediction reconstruction, &lt;code>cdid&lt;/code> stops with an explicit error rather than falling back to OR or IPW. Exact aliases can first be removed when every required prediction is preserved; local rank deficiency alone need not invalidate an explicitly pooled fit, but the package never switches to pooling automatically.&lt;/li>
&lt;/ul>
&lt;p>There is no general finite sample unbiasedness guarantee for IPW, OR, or DR, and none is guaranteed to have the lowest variance across all designs. In any random finite draw, unsupported cells (&lt;code>available == FALSE&lt;/code>), unavailable Wald pretrend tests (&lt;code>fit$W&lt;/code>, &lt;code>fit$Wpval&lt;/code>), or numerical and conditioning refusals remain possible without automatic retry, redraw, or dropping of units or moments. See &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a> and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>.&lt;/p>
&lt;h2 id="next-step">Next step&lt;/h2>
&lt;ul>
&lt;li>Keep &lt;code>units&lt;/code>, &lt;code>panel&lt;/code>, &lt;code>y_complete&lt;/code>, and &lt;code>observed&lt;/code> in your R session and continue to &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>, &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>, &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>, and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>.&lt;/li>
&lt;/ul>
&lt;h2 id="references">References&lt;/h2>
&lt;ul>
&lt;li>Bellégo, C., Benatia, D. and Dortet-Bernadet, V. (2025). The Chained Difference-in-Differences. &lt;em>Journal of Econometrics&lt;/em>. &lt;a href="https://doi.org/10.1016/j.jeconom.2024.105783" target="_blank" rel="noopener">https://doi.org/10.1016/j.jeconom.2024.105783&lt;/a>&lt;/li>
&lt;li>Callaway, B. and Sant&amp;rsquo;Anna, P. H. C. (2021). Difference-in-Differences with Multiple Time Periods. &lt;em>Journal of Econometrics&lt;/em> 225(2). &lt;a href="https://doi.org/10.1016/j.jeconom.2020.12.001" target="_blank" rel="noopener">https://doi.org/10.1016/j.jeconom.2020.12.001&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>
&lt;figure >
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img src="https://www.davidbenatia.com/tools/cdid/assets/r/docs/outputs/incomplete-dr-dynamic.png" alt="Dynamic effects with treatment DR in the incomplete panel" loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/p>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 8 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;strong>Choose IPW, OR or DR in an incomplete panel&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>Clustered inference, confidence bands, and pretrend tests</title><link>https://www.davidbenatia.com/tools/cdid/guide/examples/inference/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/examples/inference/</guid><description>&lt;p>Results below were produced on October 29, 2026 with &lt;code>cdid&lt;/code> 1.1.0.0, &lt;code>did&lt;/code> 2.5.1 and &lt;code>DRDID&lt;/code> 1.3.0 under R 4.5.2, using the displayed seeds where applicable. These are individual examples; they do not establish repeated-sample coverage. OR/DR calls shown here explicitly retain the historical pooled specification; the current default uses separate comparison regressions.&lt;/p>
&lt;p>After estimating group time average treatment effects on an incomplete panel, applied analyses typically need standard errors that account for within cluster dependence, simultaneous confidence bands across cells or event study horizons, and diagnostic pretrend tests. &lt;code>cdid&lt;/code> builds on the chained difference in differences framework of Bellégo, Benatia and Dortet-Bernadet (2025) and the inference and aggregation workflow of Callaway and Sant&amp;rsquo;Anna (2021) (&lt;code>did&lt;/code>), propagating complete unit table influence functions through every output without refitting the underlying models.&lt;/p>
&lt;p>This article walks through a complete script on a clustered incomplete panel with staggered adoption, showing how to obtain clustered multiplier bootstrap standard errors and simultaneous bands in &lt;code>att_gt()&lt;/code> and &lt;code>aggte()&lt;/code>, inspect tidy tables and plots, and run both the unconditional Wald pretrend test and the separate conditional Cramér von Mises (&lt;code>CvM&lt;/code>) pretrend test. For a complete list of result fields, see the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results reference&lt;/a>.&lt;/p>
&lt;h2 id="question">Question&lt;/h2>
&lt;p>Suppose a longitudinal study follows $N = 2000$ units across $T = 6$ calendar dates in 100 regional clusters (&lt;code>region&lt;/code>), with staggered treatment cohorts first treated at $G = 3$ and $G = 5$ alongside never treated controls ($G = 0$), a fixed binary covariate &lt;code>x&lt;/code>, and missing outcomes generated by independent date observation. How do we compute clustered multiplier bootstrap standard errors and simultaneous confidence bands for group time effects and dynamic event study aggregates, distinguish pointwise intervals from joint bands across output families, and evaluate both unconditional and conditional pretrend tests?&lt;/p>
&lt;h2 id="data">Data&lt;/h2>
&lt;h3 id="study-population-clusters-and-staggered-cohorts">Study population, clusters, and staggered cohorts&lt;/h3>
&lt;p>The simulated study population consists of $N = 2000$ units recorded in the unit table &lt;code>units&lt;/code> (&lt;code>frame&lt;/code>), with one row per study unit and four columns: &lt;code>id&lt;/code> ($1, \dots, 2000$), treatment cohort &lt;code>g&lt;/code> in ${0, 3, 5}$ ($0$ for units never treated, $3$ and $5$ for cohorts first treated at $t = 3$ and $t = 5$), fixed binary covariate &lt;code>x&lt;/code> ($\text{Bernoulli}(0.5)$ independent of &lt;code>g&lt;/code> and &lt;code>region&lt;/code>), and cluster identifier &lt;code>region&lt;/code> ($1, \dots, 100$). Cohort assignment is independent of region, so clusters can mix cohorts, but a finite draw need not place every cohort in every cluster. The code checks overall cohort counts, not a within-cluster composition guarantee.&lt;/p>
&lt;h3 id="potential-outcomes-and-cluster-dependence">Potential outcomes and cluster dependence&lt;/h3>
&lt;p>Across $T = 6$ calendar dates ($t \in {1, 2, 3, 4, 5, 6}$), untreated outcomes follow&lt;/p>
&lt;p>$$Y_{i,t}(0) = \alpha_i + 0.1 t + 0.2 x_i t + u_{\text{region}(i)} t + \varepsilon_{i,t}$$&lt;/p>
&lt;p>where $\alpha_i \sim \mathcal{N}(0, 1)$ is a unit intercept, $0.1 t + 0.2 x_i t$ is the mean untreated trend, $u_r \sim \mathcal{N}(0, 0.15^2)$ is a mean zero cluster trend slope shared within cluster $r$, and $\varepsilon_{i,t} \sim \mathcal{N}(0, 0.5^2)$ is idiosyncratic noise. Differencing within unit $i$ removes $\alpha_i$ but leaves $(t - s) u_{\text{region}(i)}$ in every outcome change $\Delta Y_{s,t}$, correlating outcome changes within the same &lt;code>region&lt;/code>.&lt;/p>
&lt;p>For treated units ($G \in {3, 5}$) at periods $t \ge G$, the treatment effect is $\tau(G, t) = 1 + 0.25 (t - G)$, which equals $1.00$ at event time $e = t - G = 0$, $1.25$ at $e = 1$, $1.50$ at $e = 2$, and $1.75$ at $e = 3$.&lt;/p>
&lt;h3 id="independent-date-observation-with-full-panel-rows-retained">Independent date observation with full panel rows retained&lt;/h3>
&lt;p>At each unit and date row, the outcome is observed independently with probability $0.8$ ($\text{Bernoulli}(0.8)$), independent of all potential outcomes, &lt;code>g&lt;/code>, &lt;code>x&lt;/code>, and &lt;code>region&lt;/code>. All $N \times T = 12000$ unit and date rows are retained in &lt;code>panel_data&lt;/code> with unobserved outcomes set to &lt;code>NA&lt;/code>, keeping every calendar period in the stored calendar and aligned with &lt;code>frame = units&lt;/code>.&lt;/p>
&lt;h2 id="assumptions">Assumptions&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Representative pair observation (&lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>):&lt;/strong> Because date observation is independent of potential outcomes, &lt;code>g&lt;/code>, &lt;code>x&lt;/code>, and &lt;code>region&lt;/code>, the units observed at both endpoints of any date pair $(s, t)$ form a representative random subsample of each cohort in &lt;code>units&lt;/code>. Setting &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code> is therefore justified without an observation model, and the target parameter remains the average treatment effect over the full study population $F$ in &lt;code>frame = units&lt;/code> (retaining units observed once or never in cohort shares, cluster sums, and influence functions).&lt;/li>
&lt;li>&lt;strong>Parallel trends, no anticipation, and treatment DR:&lt;/strong> With &lt;code>control_group = &amp;quot;nevertreated&amp;quot;&lt;/code> and &lt;code>anticipation = 0&lt;/code>, reference periods are $t = 2$ for $G = 3$ and $t = 4$ for $G = 5$. Because &lt;code>g&lt;/code> and &lt;code>x&lt;/code> are independent of the mean zero cluster slope $u_r$ and unit intercept $\alpha_i$, parallel trends hold from each cohort&amp;rsquo;s reference period (&lt;code>pt_assumption = &amp;quot;post&amp;quot;&lt;/code>, &lt;code>PT-post&lt;/code>) and before treatment. With all six dates present in the stored calendar ($L(e) = t - s$), the conditional untreated change over pair $e$ is $(0.1 + 0.2 x) L(e)$, matching the pooled control regression $\alpha(b) + L(e) x \beta$ while the treatment propensity is constant in &lt;code>x&lt;/code>.&lt;/li>
&lt;li>&lt;strong>Finite sample support and regularity:&lt;/strong> In any single finite sample draw, random observation masks or covariate realizations can still produce empty cells, rank deficiency, or singular pretrend covariance matrices. The script checks basic cohort counts once without seed retry loops.&lt;/li>
&lt;/ul>
&lt;h2 id="code">Code&lt;/h2>
&lt;pre>&lt;code class="language-r">set.seed(20261028)
N &amp;lt;- 2000L
T_dates &amp;lt;- 6L
n_clusters &amp;lt;- 100L
units &amp;lt;- data.frame(
id = seq_len(N),
g = sample(c(0L, 3L, 5L), size = N, replace = TRUE, prob = c(0.4, 0.3, 0.3)),
x = stats::rbinom(N, size = 1L, prob = 0.5),
region = rep(seq_len(n_clusters), length.out = N)
)
stopifnot(all(table(factor(units$g, levels = c(0L, 3L, 5L))) &amp;gt; 0L))
alpha_i &amp;lt;- stats::rnorm(N, mean = 0, sd = 1)
cluster_slope &amp;lt;- stats::rnorm(n_clusters, mean = 0, sd = 0.15)
panel_data &amp;lt;- expand.grid(time = seq_len(T_dates), id = units$id)
panel_data &amp;lt;- panel_data[order(panel_data$id, panel_data$time), c(&amp;quot;id&amp;quot;, &amp;quot;time&amp;quot;)]
rownames(panel_data) &amp;lt;- NULL
panel_data$g &amp;lt;- units$g[panel_data$id]
panel_data$x &amp;lt;- units$x[panel_data$id]
panel_data$region &amp;lt;- units$region[panel_data$id]
treated_now &amp;lt;- panel_data$g &amp;gt; 0L &amp;amp; panel_data$time &amp;gt;= panel_data$g
effect &amp;lt;- ifelse(treated_now, 1 + 0.25 * (panel_data$time - panel_data$g), 0)
y_full &amp;lt;- alpha_i[panel_data$id] +
0.1 * panel_data$time +
0.2 * panel_data$x * panel_data$time +
cluster_slope[panel_data$region] * panel_data$time +
effect +
stats::rnorm(nrow(panel_data), mean = 0, sd = 0.5)
observed &amp;lt;- stats::runif(nrow(panel_data)) &amp;lt; 0.8
panel_data$y &amp;lt;- ifelse(observed, y_full, NA_real_)
# Fit chained DiD with treatment DR, PT-post, varying base period, and clustering.
fit_inf &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
xformla = ~ x, data = panel_data, panel = TRUE,
allow_unbalanced_panel = TRUE, control_group = &amp;quot;nevertreated&amp;quot;,
anticipation = 0, alp = 0.05, bstrap = TRUE, cband = TRUE,
biters = 999, clustervars = &amp;quot;region&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
base_period = &amp;quot;varying&amp;quot;, frame = units,
selection = &amp;quot;none&amp;quot;, pt_assumption = &amp;quot;post&amp;quot;
)
summary(fit_inf)
tidy_gt &amp;lt;- cdid::tidy(fit_inf)
glance_gt &amp;lt;- cdid::glance(fit_inf)
fit_inf$W
fit_inf$Wpval
fit_inf$chained$pretest[c(&amp;quot;status&amp;quot;, &amp;quot;reason&amp;quot;, &amp;quot;cells&amp;quot;, &amp;quot;df&amp;quot;, &amp;quot;W&amp;quot;, &amp;quot;Wpval&amp;quot;)]
# Dynamic event study aggregation and ggdid() plots.
agg_dyn &amp;lt;- cdid::aggte(fit_inf, type = &amp;quot;dynamic&amp;quot;)
summary(agg_dyn)
tidy_dyn &amp;lt;- cdid::tidy(agg_dyn)
glance_dyn &amp;lt;- cdid::glance(agg_dyn)
agg_dyn$overall.att
agg_dyn$overall.se
agg_dyn$chained$overall[c(&amp;quot;status&amp;quot;, &amp;quot;inference_kind&amp;quot;, &amp;quot;ci_lower&amp;quot;, &amp;quot;ci_upper&amp;quot;)]
plot_gt &amp;lt;- cdid::ggdid(fit_inf)
plot_dyn &amp;lt;- cdid::ggdid(agg_dyn)
# Separate conditional pretrend CvM test (takes data/route arguments directly,
# has no pt_assumption or gmm_weighting arguments, and defaults to est_method = &amp;quot;ipw&amp;quot;).
pre_cond_dr &amp;lt;- cdid::conditional_did_pretest(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
xformla = ~ x, data = panel_data, panel = TRUE,
allow_unbalanced_panel = TRUE, control_group = &amp;quot;nevertreated&amp;quot;,
alp = 0.05, bstrap = TRUE, cband = TRUE, biters = 999,
clustervars = &amp;quot;region&amp;quot;, est_method = &amp;quot;dr&amp;quot;, anticipation = 0,
base_period = &amp;quot;varying&amp;quot;, frame = units, selection = &amp;quot;none&amp;quot;
)
summary(pre_cond_dr)
pre_cond_dr[c(&amp;quot;CvM&amp;quot;, &amp;quot;CvMcval&amp;quot;, &amp;quot;CvMpval&amp;quot;, &amp;quot;KS&amp;quot;, &amp;quot;KSpval&amp;quot;)]
pre_cond_dr$chained[c(&amp;quot;status&amp;quot;, &amp;quot;reason&amp;quot;, &amp;quot;base_period&amp;quot;)]
# Optional export calls (unexecuted):
# utils::write.csv(tidy_gt, file = &amp;quot;att_gt_tidy.csv&amp;quot;, row.names = FALSE)
# ggplot2::ggsave(&amp;quot;aggte_dynamic_plot.png&amp;quot;, plot = plot_dyn, width = 7, height = 4)
# saveRDS(fit_inf, file = &amp;quot;fit_inf.rds&amp;quot;)
&lt;/code>&lt;/pre>
&lt;details>
&lt;summary>Console output&lt;/summary>
&lt;pre>&lt;code class="language-text">cdid chained difference-in-differences (chained doubly robust GMM): cdid_MP
cdid 1.1.0.0 result built on did 2.5.1 (tested: did 2.5.1); did's MP methods tabulate the estimates below.
Chained estimators: Bellego C., Benatia D. and V. Dortet-Bernadet (2025). &amp;quot;The Chained Difference-in-Differences.&amp;quot; Journal of Econometrics 248, 105783. doi:10.1016/j.jeconom.2024.105783.
Ordinary estimators: Callaway B. and P. H. C. Sant'Anna (2021). &amp;quot;Difference-in-Differences with Multiple Time Periods.&amp;quot; Journal of Econometrics 225(2), 200-230. doi:10.1016/j.jeconom.2020.12.001.
Call:
cdid::att_gt(yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
xformla = ~x, data = panel_data, panel = TRUE, allow_unbalanced_panel = TRUE,
control_group = &amp;quot;nevertreated&amp;quot;, anticipation = 0, alp = 0.05,
bstrap = TRUE, cband = TRUE, biters = 999, clustervars = &amp;quot;region&amp;quot;,
est_method = &amp;quot;dr&amp;quot;, base_period = &amp;quot;varying&amp;quot;, frame = units,
selection = &amp;quot;none&amp;quot;, pt_assumption = &amp;quot;post&amp;quot;)
Group-Time Average Treatment Effects:
Group Time ATT(g,t) Std. Error [95% Simult. Conf. Band]
3 2 -0.0428 0.0565 -0.1962 0.1107
3 3 1.0394 0.0457 0.9153 1.1636 *
3 4 1.2294 0.0519 1.0883 1.3705 *
3 5 1.5430 0.0487 1.4106 1.6754 *
3 6 1.7424 0.0560 1.5902 1.8945 *
5 2 -0.0012 0.0457 -0.1252 0.1229
5 3 -0.0129 0.0509 -0.1511 0.1253
5 4 -0.0244 0.0509 -0.1628 0.1139
5 5 1.0284 0.0409 0.9172 1.1396 *
5 6 1.3126 0.0404 1.2030 1.4223 *
---
Signif. codes: `*' confidence band does not cover 0
P-value for pre-test of parallel trends assumption: 0.867093175392542
Control Group: Never Treated, Anticipation Periods: 0
Estimation Method: Doubly Robust
Chained support: 10 of 10 requested cells available.
Units: 2000 in the unit table, 536 observed at all 6 dates, 1999 with at least two observed outcomes.
Observation correction: none (selection = &amp;quot;none&amp;quot;).
Parallel trends: PT-post; base_period = &amp;quot;varying&amp;quot;.
GMM weighting: optimal (two-step); covariance regularization: not applied (moment covariance well conditioned).
Inference: multiplier-bootstrap IQR standard errors (999 draws), clustered on 100 clusters (0 without eligible units); simultaneous band over the available cells.
Parallel-trends pre-test: W = 1.26614, df = 4, p = 0.8671 (Wald test of all 4 pretrend cells jointly).
[1] 1.266143
[1] 0.8670932
$status
[1] &amp;quot;computed&amp;quot;
$&amp;lt;NA&amp;gt;
NULL
$cells
[1] &amp;quot;pre(g=3,t=2)&amp;quot; &amp;quot;pre(g=5,t=2)&amp;quot; &amp;quot;pre(g=5,t=3)&amp;quot; &amp;quot;pre(g=5,t=4)&amp;quot;
$df
[1] 4
$W
[1] 1.266143
$Wpval
[1] 0.8670932
cdid chained difference-in-differences (chained doubly robust GMM): cdid_AGGTEobj
cdid 1.1.0.0 result built on did 2.5.1 (tested: did 2.5.1); did's AGGTEobj methods tabulate the estimates below.
Chained estimators: Bellego C., Benatia D. and V. Dortet-Bernadet (2025). &amp;quot;The Chained Difference-in-Differences.&amp;quot; Journal of Econometrics 248, 105783. doi:10.1016/j.jeconom.2024.105783.
Ordinary estimators: Callaway B. and P. H. C. Sant'Anna (2021). &amp;quot;Difference-in-Differences with Multiple Time Periods.&amp;quot; Journal of Econometrics 225(2), 200-230. doi:10.1016/j.jeconom.2020.12.001.
Call:
cdid::aggte(fit_inf, type = &amp;quot;dynamic&amp;quot;)
Overall summary of ATT's based on event-study/dynamic aggregation:
ATT Std. Error [ 95% Conf. Int.]
1.3978 0.0361 1.327 1.4687 *
Dynamic Effects:
Event time Estimate Std. Error [95% Simult. Conf. Band]
-3 -0.0012 0.0490 -0.1262 0.1238
-2 -0.0129 0.0480 -0.1354 0.1097
-1 -0.0333 0.0370 -0.1279 0.0612
0 1.0337 0.0290 0.9598 1.1077 *
1 1.2723 0.0314 1.1923 1.3523 *
2 1.5430 0.0498 1.4159 1.6701 *
3 1.7424 0.0574 1.5958 1.8889 *
---
Signif. codes: `*' confidence band does not cover 0
Control Group: Never Treated, Anticipation Periods: 0
Estimation Method: Doubly Robust
Chained dynamic aggregation: 7 of 7 intended aggregate(s) available; na.rm = FALSE.
Overall summary: available over its 4 intended bins; pointwise interval.
Parallel trends: PT-post; base_period = &amp;quot;varying&amp;quot;.
Inference: multiplier-bootstrap IQR standard errors (999 draws), clustered on 100 clusters (0 without eligible units); simultaneous band over the available estimates.
[1] 1.397846
[1] 0.0361435
$status
[1] &amp;quot;available&amp;quot;
$inference_kind
[1] &amp;quot;multiplier_bootstrap_iqr_se&amp;quot;
$ci_lower
[1] 1.327006
$ci_upper
[1] 1.468686
Chained conditional pretrend test (cdid, mode = &amp;quot;chained&amp;quot;)
Cramer von Mises:
Test Statistic: 7.059199
Critical Value: 35.25377
P-value : 0.7957958
Cells (base_period = &amp;quot;varying&amp;quot;): pre(g=3,t=2), pre(g=5,t=2), pre(g=5,t=3), pre(g=5,t=4)
Multiplier draws: 999 on 100 clusters
Clustering on : region,
X formula : ~x
Note : not the unconditional Wald test: att_gt()'s unconditional W/Wpval is separate and unchanged
$CvM
[1] 7.059199
$CvMcval
[1] 35.25377
$CvMpval
[1] 0.7957958
$KS
NULL
$KSpval
NULL
$status
[1] &amp;quot;available&amp;quot;
$reason
[1] NA
$base_period
[1] &amp;quot;varying&amp;quot;
&lt;/code>&lt;/pre>
&lt;/details>
&lt;h2 id="interpretation">Interpretation&lt;/h2>
&lt;h3 id="pointwise-intervals-versus-simultaneous-bands-across-output-families">Pointwise intervals versus simultaneous bands across output families&lt;/h3>
&lt;p>Following &lt;code>did&lt;/code> 2.5.1, &lt;code>bstrap&lt;/code> and &lt;code>cband&lt;/code> govern these ATT and aggregation endpoints (the separate conditional test has its own rules below):&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;code>bstrap&lt;/code>&lt;/th>
&lt;th>&lt;code>cband&lt;/code>&lt;/th>
&lt;th>Group time cells of &lt;code>att_gt()&lt;/code>&lt;/th>
&lt;th>Scalar &lt;code>aggte()&lt;/code> simple and &lt;code>overall.att&lt;/code> summaries&lt;/th>
&lt;th>Separate bins (&lt;code>att.egt&lt;/code>) of &lt;code>aggte()&lt;/code> group, dynamic, and calendar&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>FALSE&lt;/code>&lt;/td>
&lt;td>&lt;code>FALSE&lt;/code>&lt;/td>
&lt;td>Analytical SEs, pointwise normal intervals&lt;/td>
&lt;td>Analytical SE, pointwise normal interval&lt;/td>
&lt;td>Analytical SEs, pointwise normal intervals&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>TRUE&lt;/code>&lt;/td>
&lt;td>&lt;code>FALSE&lt;/code>&lt;/td>
&lt;td>Multiplier SEs, pointwise normal intervals&lt;/td>
&lt;td>Multiplier SE, pointwise normal interval&lt;/td>
&lt;td>Multiplier SEs, pointwise normal intervals&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>TRUE&lt;/code>&lt;/td>
&lt;td>&lt;code>TRUE&lt;/code>&lt;/td>
&lt;td>Multiplier SEs, simultaneous band over available cells&lt;/td>
&lt;td>Multiplier SE, pointwise normal interval&lt;/td>
&lt;td>Multiplier SEs, simultaneous band over available bins&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>FALSE&lt;/code>&lt;/td>
&lt;td>&lt;code>TRUE&lt;/code>&lt;/td>
&lt;td>Analytical SEs, pointwise normal intervals, zero draws&lt;/td>
&lt;td>Analytical SE, pointwise normal interval, zero draws&lt;/td>
&lt;td>Analytical SEs with a multiplier simultaneous critical value and &lt;code>did&lt;/code>&amp;rsquo;s warning&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The table describes supported nondegenerate families. Empty or exactly zero families can need no draws; inspect the recorded effective flags and count. “Zero draws” for a scalar overall endpoint does not mean a nontrivial aggregation call made no draws for its separate-bin band.&lt;/p>
&lt;p>Three distinctions matter when reading &lt;code>tidy_gt&lt;/code>, &lt;code>tidy_dyn&lt;/code>, and &lt;code>ggdid()&lt;/code> plots:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Band columns versus pointwise columns:&lt;/strong> With &lt;code>bstrap = TRUE, cband = TRUE&lt;/code>, &lt;code>conf.low&lt;/code> and &lt;code>conf.high&lt;/code> in &lt;code>tidy_gt&lt;/code> (and &lt;code>fit_inf$chained$cband_lower&lt;/code>, &lt;code>cband_upper&lt;/code>) form a simultaneous band over the available cells of &lt;code>fit_inf&lt;/code> using critical value &lt;code>fit_inf$c&lt;/code>. By contrast, &lt;code>p.value&lt;/code> is always pointwise, and &lt;code>point.conf.low&lt;/code> and &lt;code>point.conf.high&lt;/code> (and &lt;code>fit_inf$chained$ci_lower&lt;/code>, &lt;code>ci_upper&lt;/code>) are always pointwise normal intervals using &lt;code>qnorm(1 - alp / 2)&lt;/code>.&lt;/li>
&lt;li>&lt;strong>Event study bins versus scalar overall summaries:&lt;/strong> In &lt;code>agg_dyn&lt;/code>, the separate event time estimates (&lt;code>agg_dyn$att.egt&lt;/code>, appearing as &lt;code>estimate&lt;/code> with &lt;code>event.time&lt;/code> in &lt;code>tidy_dyn&lt;/code> and plotted by &lt;code>ggdid(agg_dyn)&lt;/code>) receive a simultaneous band across the available event times using &lt;code>agg_dyn$crit.val.egt&lt;/code>. Meanwhile, the scalar posttreatment summary &lt;code>agg_dyn$overall.att&lt;/code> (&lt;code>agg_dyn$overall.se&lt;/code>, with interval &lt;code>agg_dyn$chained$overall$ci_lower&lt;/code>, &lt;code>ci_upper&lt;/code>) always uses a pointwise normal critical value, just like &lt;code>aggte(..., type = &amp;quot;simple&amp;quot;)&lt;/code>.&lt;/li>
&lt;li>&lt;strong>Separate output families are not one global band:&lt;/strong> &lt;code>fit_inf&lt;/code>, &lt;code>agg_dyn&lt;/code>, group or calendar aggregations, and any optional basis contrasts each form their own &lt;code>band_family&lt;/code>; they do not form a single simultaneous band over their union.&lt;/li>
&lt;/ol>
&lt;h3 id="how-the-clustered-multiplier-bootstrap-and-influence-functions-work">How the clustered multiplier bootstrap and influence functions work&lt;/h3>
&lt;ul>
&lt;li>&lt;strong>No resampling or refitting:&lt;/strong> &lt;code>fit_inf$inffunc&lt;/code> is a matrix with one row per unit in &lt;code>units&lt;/code> (&lt;code>frame&lt;/code>, $n = 2000$). &lt;code>agg_dyn$inf.function&lt;/code> is a list: &lt;code>dynamic.inf.func.e&lt;/code> is the full-unit by event-bin matrix and &lt;code>dynamic.inf.func&lt;/code> is the full-unit vector for the overall summary. Both retain units observed once or never. They include the estimation uncertainty of all active nuisance models (treatment propensity logits, the pooled counterfactual regression, and when active, observation or imputation models), empirical response rates, and estimated cohort shares in &lt;code>aggte()&lt;/code>.&lt;/li>
&lt;li>&lt;strong>Clustered row sums and Rademacher draws:&lt;/strong> With &lt;code>clustervars = &amp;quot;region&amp;quot;&lt;/code>, influence function rows are summed within each of the 100 clusters (including clusters with no observed changes). For a supported nondegenerate family, the requested &lt;code>biters = 999&lt;/code> draws multiply each cluster sum by a Rademacher sign ($\pm 1$) from the session RNG stream (&lt;code>set.seed()&lt;/code> reproduces them).&lt;/li>
&lt;li>&lt;strong>Interquartile scale and symmetric intervals:&lt;/strong> Multiplier standard errors use the draw interquartile range divided by the standard normal interquartile range, converted to the scale of the estimate, and bands take the symmetric form $\text{estimate} \pm c \times \text{SE}$ (never percentile intervals).&lt;/li>
&lt;li>&lt;strong>Clustering never changes point estimates:&lt;/strong> Feasible two step GMM weights (&lt;code>gmm_weighting = &amp;quot;optimal&amp;quot;&lt;/code>) and any Tikhonov covariance ridge (&lt;code>gmm_covariance = &amp;quot;tikhonov&amp;quot;&lt;/code>) use unit level influence function covariances independently of &lt;code>clustervars&lt;/code>. Analytical standard errors use the estimated sandwich covariance of the complete target influence functions; multiplier standard errors use IQR scales from draws of those functions. Neither uses the inverse regularized criterion matrix as its variance estimate.&lt;/li>
&lt;/ul>
&lt;h3 id="unconditional-wald-test-versus-conditional-cvm-pretrend-test">Unconditional Wald test versus conditional CvM pretrend test&lt;/h3>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Feature&lt;/th>
&lt;th>Unconditional Wald test (&lt;code>att_gt()&lt;/code>)&lt;/th>
&lt;th>Conditional Cramér von Mises test (&lt;code>conditional_did_pretest()&lt;/code>)&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Call and arguments&lt;/td>
&lt;td>Computed inside &lt;code>cdid::att_gt()&lt;/code>; uses &lt;code>att_gt()&lt;/code>&amp;rsquo;s &lt;code>est_method = &amp;quot;dr&amp;quot;&lt;/code> default&lt;/td>
&lt;td>Separate call taking data and route arguments directly (not passed &lt;code>fit_inf&lt;/code>); has &lt;strong>no&lt;/strong> &lt;code>pt_assumption&lt;/code>, &lt;code>pt_start&lt;/code>, &lt;code>gmm_weighting&lt;/code>, or &lt;code>gmm_covariance&lt;/code> arguments; defaults to &lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code> unless overridden&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Null hypothesis&lt;/td>
&lt;td>Jointly tests that all nonreference preperiod cells (&lt;code>role == &amp;quot;pre&amp;quot;&lt;/code>) of &lt;code>base_period&lt;/code> equal zero unconditionally&lt;/td>
&lt;td>Tests that for every nonreference preperiod cell of &lt;code>base_period&lt;/code>, the conditional mean comparison given the &lt;code>xformla&lt;/code> design at the cell&amp;rsquo;s earlier date is zero across the full unit table grid&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Stored fields and status string&lt;/td>
&lt;td>&lt;code>fit_inf$W&lt;/code>, &lt;code>fit_inf$Wpval&lt;/code>, and &lt;code>fit_inf$chained$pretest$status&lt;/code> (&lt;code>&amp;quot;computed&amp;quot;&lt;/code>, &lt;code>&amp;quot;unavailable&amp;quot;&lt;/code>, &lt;code>&amp;quot;not_applicable&amp;quot;&lt;/code>, or &lt;code>&amp;quot;not_computed&amp;quot;&lt;/code>)&lt;/td>
&lt;td>&lt;code>pre_cond_dr$CvM&lt;/code>, &lt;code>CvMb&lt;/code>, &lt;code>CvMcval&lt;/code>, &lt;code>CvMpval&lt;/code> (&lt;code>KS&lt;/code>, &lt;code>KSb&lt;/code>, &lt;code>KScval&lt;/code>, &lt;code>KSpval&lt;/code> are &lt;code>NULL&lt;/code>), and &lt;code>pre_cond_dr$chained$status&lt;/code> (&lt;code>&amp;quot;available&amp;quot;&lt;/code>, &lt;code>&amp;quot;unavailable&amp;quot;&lt;/code>, or &lt;code>&amp;quot;not_applicable&amp;quot;&lt;/code>)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Availability requirements&lt;/td>
&lt;td>Requires &lt;strong>every&lt;/strong> declared preperiod cell and a well conditioned joint covariance; never substitutes an available subset&lt;/td>
&lt;td>Requires &lt;strong>every&lt;/strong> declared preperiod cell and complete &lt;code>xformla&lt;/code> covariates on &lt;strong>every&lt;/strong> unit table row (even units contributing no outcome changes); otherwise returns &lt;code>status = &amp;quot;unavailable&amp;quot;&lt;/code> with &lt;code>NA&lt;/code> statistics&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="finite-sample-cluster-count-and-pretest-caveats">Finite sample, cluster count, and pretest caveats&lt;/h3>
&lt;ul>
&lt;li>&lt;strong>Large sample cluster requirements:&lt;/strong> Analytical and multiplier inference require enough independent clusters (or units), overlap, and regularity conditions; dividing units across only a few clusters does not supply enough independent clusters, and &lt;code>cdid&lt;/code> makes no finite sample or few cluster coverage guarantee.&lt;/li>
&lt;li>&lt;strong>Full-null rank requirement:&lt;/strong> Centered influence sums from &lt;code>C&lt;/code> independent clusters have covariance rank at most &lt;code>C - 1&lt;/code>. A Wald test with more declared restrictions is unavailable even if rounding produces positive Cholesky pivots. The same bound applies to centered unit influence rows without clustering. No restrictions are removed, and point estimates and their other inference remain available.&lt;/li>
&lt;li>&lt;strong>Single draw outcomes and pretest limits:&lt;/strong> A single simulated sample is not guaranteed to pass the Wald or &lt;code>CvM&lt;/code> test, and finite sample support or rank failures remain possible. Conversely, failing to reject a pretrend test does not prove parallel trends, which also restrict posttreatment counterfactual trends (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/#pretrend-tests-under-each-choice">Parallel trends&lt;/a>).&lt;/li>
&lt;/ul>
&lt;h2 id="next-steps">Next steps&lt;/h2>
&lt;ul>
&lt;li>Read the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results reference&lt;/a>, &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options reference&lt;/a>, and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>.&lt;/li>
&lt;li>Compare model specifications in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Compare model robustness across treatment and missing outcome adjustments&lt;/a> and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Estimate treatment effects from incomplete panels&lt;/a>.&lt;/li>
&lt;/ul>
&lt;p>
&lt;figure >
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img src="https://www.davidbenatia.com/tools/cdid/assets/r/docs/outputs/clustered-cells.png" alt="Group-time effects with clustered multiplier bands" loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/p>
&lt;p>
&lt;figure >
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img src="https://www.davidbenatia.com/tools/cdid/assets/r/docs/outputs/clustered-dynamic.png" alt="Dynamic aggregation with clustered multiplier bands" loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/p>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 17 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;strong>Inference&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>Cohort-by-date fixed effects</title><link>https://www.davidbenatia.com/tools/cdid/guide/methods/cohort-time-fe/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/methods/cohort-time-fe/</guid><description>&lt;p>Use this preset for an absorbing treatment and a common linear untreated time path with unit fixed effects. Each treated cohort can have a different effect at each post-treatment date. The fit uses changes across each unit&amp;rsquo;s observed dates, including changes that span gaps.&lt;/p>
&lt;h2 id="fit-the-model">Fit the model&lt;/h2>
&lt;p>Supply a long panel with one row per unit and date, an outcome, and a cohort column. Use the adoption date as the cohort code and zero for never-treated units. Include at least one never-treated cohort, use consecutive positive integer study dates, and place every adoption after the first study date. You can leave rows with missing outcomes in the panel. An optional unit table supplies units with no observed outcomes and keeps the original influence-function rows.&lt;/p>
&lt;pre>&lt;code class="language-r">fit &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;t&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
data = panel, est_method = &amp;quot;reg&amp;quot;, base_period = &amp;quot;universal&amp;quot;,
control_group = &amp;quot;nevertreated&amp;quot;,
bstrap = FALSE, cband = FALSE,
control = list(preset = &amp;quot;cohort_time_fe&amp;quot;)
)
cdid::tidy(fit)
&lt;/code>&lt;/pre>
&lt;p>With never-treated controls, the pre-treatment period immediately preceding adoption is the reference. Other pre-treatment cells have their own estimated deviations. A joint test uses the covariance of the full declared set of pre-treatment deviations when it is available.&lt;/p>
&lt;p>For the common untreated path across both never-treated and not-yet-treated cohorts, use &lt;code>control_group = &amp;quot;notyettreated&amp;quot;&lt;/code>, &lt;code>pt_assumption = &amp;quot;all&amp;quot;&lt;/code> and &lt;code>pt_start = min(panel$t)&lt;/code>. That model imposes the common path on all untreated cells from the first study date. It reports post-treatment effects. Its pre-treatment restrictions are part of the fitted model.&lt;/p>
&lt;p>Use zero anticipation and unit sampling weights. The example uses &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>. The usual &lt;code>clustervars&lt;/code> and multiplier inference options apply. The fit reports support for each requested cell. Inspect the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">missing-outcomes guide&lt;/a> when observed changes may be selective. The cohort-by-date model needs the observed changes to satisfy its within-unit mean restriction. With this setting the preset fits the model to observed changes directly.&lt;/p>
&lt;h2 id="adjust-for-covariates">Adjust for covariates&lt;/h2>
&lt;p>Set &lt;code>xformla = ~ x1 + x2&lt;/code> to allow the untreated calendar path and each
cohort-date effect to vary with time-invariant covariates. Use
&lt;code>outcome_pooling = &amp;quot;separate&amp;quot;&lt;/code>. The fitted design has one set of common
calendar slopes and separate cohort-date deviations.&lt;/p>
&lt;p>Supply the covariates for every unit in the study frame, including units
observed once or never. The reported treatment effect averages the fitted
contrast over the corresponding cohort in that frame. A unit without an
observed outcome change contributes to that covariate average and its
influence function. The solve uses connected components with requested
contrasts and removes one coefficient origin in each of them. Their remaining
covariate design must have sufficient rank. The fit reports rank deficiency
or numerical singularity in that system. Disconnected cells remain unavailable.&lt;/p>
&lt;h2 id="treatment-weighting-and-doubly-robust-adjustment">Treatment weighting and doubly robust adjustment&lt;/h2>
&lt;p>Set &lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code> to reweight clean comparison units to each
treated cohort&amp;rsquo;s covariate distribution. Set &lt;code>est_method = &amp;quot;dr&amp;quot;&lt;/code> to combine
a shared untreated change model with reweighted residuals. Both methods
estimate the average untreated change separately for each cohort, over
its entire study frame. If the same conditional trend is steeper at high
values of a covariate, cohorts with more high-covariate units can have
larger untreated changes.&lt;/p>
&lt;p>Propensity models use the target and donor cohorts in the study frame
and include an intercept. They are reused across eligible pairs of
dates. A never-treated fit uses only the never-treated donor. A
not-yet-treated fit can also use each other cohort for changes ending
before its adoption. The DR outcome nuisance fits a shared linear
calendar path to clean changes. The default &lt;code>gmm_weighting = &amp;quot;optimal&amp;quot;&lt;/code>
uses the covariance of the original-unit moment scores. Choose
&lt;code>gmm_weighting = &amp;quot;identity&amp;quot;&lt;/code> for equal weight on each retained moment.
The exact R and Stata regression matches below use &lt;code>est_method = &amp;quot;reg&amp;quot;&lt;/code>.&lt;/p>
&lt;p>These weighting and DR fits require support for the treated-cohort
average and overlap with the clean donors used to estimate it. With
&lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>, a sufficient condition is that the observations
behind each cohort and date pair preserve its covariate distribution
and conditional mean change. The observed actual changes of the
treated cohort must represent its full-cohort changes. Given those
conditions and the stated parallel trends, DR is consistent when
either the treatment propensity or the untreated change model is
correct. The propensity-only guarantee requires the weighting odds
to remain correct after the package&amp;rsquo;s probability cap. See the
&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">missing-outcomes guide&lt;/a>.&lt;/p>
&lt;h2 id="adjust-for-selective-observation">Adjust for selective observation&lt;/h2>
&lt;p>Use &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code> when observed within-unit changes are
representative of cohort changes conditional on the covariates in the relevant
selection or imputation model. Choose the treatment method with &lt;code>est_method&lt;/code>
and the observation correction with &lt;code>selection_est_method&lt;/code>.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Observation correction&lt;/th>
&lt;th>Response for each unit and supported date pair&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>&amp;quot;ipw&amp;quot;&lt;/code>&lt;/td>
&lt;td>The observed change divided by its probability of being observed, or zero when either outcome is missing.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;imputation&amp;quot;&lt;/code>&lt;/td>
&lt;td>The fitted conditional mean change for that cohort and pair.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;dr&amp;quot;&lt;/code>&lt;/td>
&lt;td>The fitted conditional mean change plus the observed residual divided by its observation probability. A unit with a missing change contributes the fitted mean.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>With &lt;code>&amp;quot;pair_logit&amp;quot;&lt;/code>, the observation model predicts whether both outcomes
are observed. With &lt;code>&amp;quot;independent_period_logit&amp;quot;&lt;/code>, it predicts observation at
each date and multiplies the probabilities. The latter requires conditional
independence of the two observation indicators. Weighting and augmentation
use &lt;code>selection_xformla&lt;/code>, which can differ from the treatment and imputation
formula &lt;code>xformla&lt;/code>. The independent-period model and both imputation routes
use the full study frame (&lt;code>selection_universe = &amp;quot;F&amp;quot;&lt;/code>). Direct-pair weighting
can also use &lt;code>&amp;quot;A&amp;quot;&lt;/code> or &lt;code>&amp;quot;B&amp;quot;&lt;/code> with a justified transport ratio. The full-frame
probability is then the conditional fitted probability times the known ratio
and the share of the cohort in the fitting sample. See the
&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">missing-outcomes guide&lt;/a> for these assumptions and options.&lt;/p>
&lt;p>For example, augment the observation correction and use DR for treatment:&lt;/p>
&lt;pre>&lt;code class="language-r">fit_dr &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;t&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
data = panel, xformla = ~ x1, est_method = &amp;quot;dr&amp;quot;,
selection = &amp;quot;conditional_mtar&amp;quot;, selection_est_method = &amp;quot;dr&amp;quot;,
selection_model = &amp;quot;pair_logit&amp;quot;, selection_xformla = ~ x1 + x2,
base_period = &amp;quot;universal&amp;quot;, control_group = &amp;quot;nevertreated&amp;quot;,
bstrap = FALSE, cband = FALSE, control = list(preset = &amp;quot;cohort_time_fe&amp;quot;)
)
&lt;/code>&lt;/pre>
&lt;p>The adjusted responses enter the original cohort and calendar restrictions.
The regression combines them with the within-unit least-squares geometry.
Treatment IPW and DR average the adjusted responses over the full cohort
frame, including missing-change rows. In treatment DR, the calendar model
uses the adjusted clean changes and treatment propensities use the target
and donor cohorts. The inference includes estimating the active observation,
imputation, outcome and propensity models. A missing adjustment or weak
overlap can still invalidate the effect. A date pair with no observed change
in a cohort supplies no fitted comparison there. Corrected fits use the
connected comparisons that identify a requested contrast. Treatment DR
also uses the clean pairs needed to fit its common calendar changes.
All supported links in those components enter the fit.&lt;/p>
&lt;h2 id="match-r-etwfe-and-stata-jwdid">Match R etwfe and Stata jwdid&lt;/h2>
&lt;p>The following commands match the cell specification in the example above. In R, explicitly supply the unit identifier and the never-treated cohort reference.&lt;/p>
&lt;pre>&lt;code class="language-r">ref &amp;lt;- etwfe::etwfe(
y ~ 1, tvar = t, gvar = g, ivar = id, gref = 0,
data = panel, cgroup = &amp;quot;never&amp;quot;, vcov = ~id,
ssc = fixest::ssc(K.adj = FALSE, G.adj = FALSE)
)
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-stata">jwdid y, ivar(id) tvar(t) gvar(g) never cluster(id)
&lt;/code>&lt;/pre>
&lt;p>For the not-yet-treated comparison, set &lt;code>cgroup = &amp;quot;notyet&amp;quot;&lt;/code> in R and omit &lt;code>never&lt;/code> in Stata. Match the same input rows, calendar, controls and cohort-date coefficients. On incomplete panels, verify that each command uses the same observations. For example, &lt;code>jwdid&lt;/code> can exclude treated units whose first observed outcome is already treated. Cohort and date labels still refer to the same adoption and study periods.&lt;/p>
&lt;p>With &lt;code>bstrap = FALSE&lt;/code>, cdid uses the original-unit sandwich without a degrees-of-freedom multiplier. Pass an equivalent cluster to all commands. The R call above requests that normalization explicitly. When Stata fits with &lt;code>reghdfe&lt;/code>, divide the stored &lt;code>e(V)&lt;/code> by the finite-sample factor
&lt;code>(e(N) - 1) / (e(N) - e(df_m) - e(df_a) - (e(df_a_nested) &amp;gt; 0)) * e(N_clust) / (e(N_clust) - 1)&lt;/code>
to compare covariance on the same scale. The corresponding standard-error conversion divides by the square root of the factor. Check critical values separately when comparing intervals.&lt;/p>
&lt;p>These comparisons concern matched cohort-date effects and their joint covariance. On incomplete panels, &lt;code>cdid::aggte()&lt;/code> weights cohorts using the study-unit frame. The reference post-estimation routines can weight the observed treated cells. Compare those summaries only after aligning the weights and whether the weights contribute to sampling uncertainty.&lt;/p>
&lt;p>&lt;a href="https://grantmcdermott.com/etwfe/reference/etwfe.html" target="_blank" rel="noopener">etwfe model reference&lt;/a> · &lt;a href="https://friosavila.github.io/app_metrics/app_metrics11.html" target="_blank" rel="noopener">jwdid model reference&lt;/a>&lt;/p>
&lt;h2 id="how-the-changes-are-combined">How the changes are combined&lt;/h2>
&lt;p>For the regression fit, eliminating a unit intercept gives the same least-squares objective as forming consecutive differences along that unit&amp;rsquo;s observed dates and using the inverse of their joint covariance under uncorrelated level errors with equal variance. For example, a unit observed in dates 1, 3 and 4 contributes changes from 1 to 3 and 3 to 4. The changes share the outcome at date 3. The fit accounts for that dependence when combining them. Inference then uses the empirical unit or cluster scores.&lt;/p>
&lt;p>The regression solver reuses parts of the within-unit calculation for units in the same cohort with the same observation dates. One factorization supplies all available cohort-date estimates and their scores. The observed changes must connect each cell to the corresponding calendar path. Covariate adjustment also requires enough variation in the relevant covariates to identify the fitted contrast. Treatment IPW and DR instead combine observed changes and cohort-standardized
untreated changes by GMM. Each link enters once for each supported comparison
cohort, and the default weighting accounts for the covariance across those
moments. See the &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/docs/theory/cohort_time_fe_linear.tex" target="_blank" rel="noopener">derivation&lt;/a>.&lt;/p>
&lt;h2 id="verified-comparisons">Verified comparisons&lt;/h2>
&lt;h3 id="intercept-only-model">Intercept-only model&lt;/h3>
&lt;p>The intercept-only fits were compared on the same complete and incomplete synthetic panels with 128, 2,048 and 10,000 units and 6, 12 and 20 dates, respectively. The 24 cases cover both control groups and unit or larger cluster levels. The incomplete design has non-nested observation dates. Every treated unit has a pre-treatment observation in these comparisons.&lt;/p>
&lt;p>Across the 24 cases, the largest absolute ATT difference is $1.9 \times 10^{-10}$ against R etwfe 0.6.2 and $3.3 \times 10^{-12}$ against Stata jwdid. With the matched sandwich convention, the largest absolute standard-error difference is $2.8 \times 10^{-8}$ against etwfe at its default fixed-effect tolerance. It falls to $3.1 \times 10^{-12}$ when etwfe uses &lt;code>fixef.tol = 3e-12&lt;/code>. After the documented variance conversion, the Stata standard-error difference is below $7.0 \times 10^{-13}$.&lt;/p>
&lt;p>These are median seconds over three runs at 10,000 units and 20 dates with one computing thread and clustering by unit. Timed calls include the regression and reported coefficient covariance. The R benchmark uses the default fixed-effect tolerance. Stata uses &lt;code>tolerance(1e-12)&lt;/code>. Peak resident memory measures the program process, including package startup and reading the input.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Panel&lt;/th>
&lt;th>Controls&lt;/th>
&lt;th style="text-align:right">cdid seconds&lt;/th>
&lt;th style="text-align:right">R etwfe seconds&lt;/th>
&lt;th style="text-align:right">Stata jwdid seconds&lt;/th>
&lt;th style="text-align:right">cdid MiB&lt;/th>
&lt;th style="text-align:right">R etwfe MiB&lt;/th>
&lt;th style="text-align:right">Stata jwdid MiB&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Complete&lt;/td>
&lt;td>Never treated&lt;/td>
&lt;td style="text-align:right">0.049&lt;/td>
&lt;td style="text-align:right">1.516&lt;/td>
&lt;td style="text-align:right">5.441&lt;/td>
&lt;td style="text-align:right">501&lt;/td>
&lt;td style="text-align:right">1,100&lt;/td>
&lt;td style="text-align:right">1,162&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Complete&lt;/td>
&lt;td>Not yet treated&lt;/td>
&lt;td style="text-align:right">0.037&lt;/td>
&lt;td style="text-align:right">1.245&lt;/td>
&lt;td style="text-align:right">2.739&lt;/td>
&lt;td style="text-align:right">478&lt;/td>
&lt;td style="text-align:right">958&lt;/td>
&lt;td style="text-align:right">829&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Incomplete&lt;/td>
&lt;td>Never treated&lt;/td>
&lt;td style="text-align:right">0.045&lt;/td>
&lt;td style="text-align:right">1.084&lt;/td>
&lt;td style="text-align:right">4.756&lt;/td>
&lt;td style="text-align:right">533&lt;/td>
&lt;td style="text-align:right">730&lt;/td>
&lt;td style="text-align:right">899&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Incomplete&lt;/td>
&lt;td>Not yet treated&lt;/td>
&lt;td style="text-align:right">0.036&lt;/td>
&lt;td style="text-align:right">0.842&lt;/td>
&lt;td style="text-align:right">2.385&lt;/td>
&lt;td style="text-align:right">482&lt;/td>
&lt;td style="text-align:right">653&lt;/td>
&lt;td style="text-align:right">553&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The largest panel has five treated cohorts. For panels with many more distinct cohort-date cells, the current solver&amp;rsquo;s dense factorization can become the largest cost. Recovering standard errors also requires retaining the requested unit-by-effect influence functions.&lt;/p>
&lt;h3 id="time-invariant-covariates">Time-invariant covariates&lt;/h3>
&lt;p>For the covariate comparison use &lt;code>y ~ x&lt;/code> in R and &lt;code>jwdid y x, xasis ...&lt;/code>
in Stata. The coefficient on a cohort-date indicator can refer to different
covariate values in the two programs. Evaluate the fitted intercept and
slope contrast at the same cohort covariate mean in each program. To match
a covariance that holds that mean fixed, compare the coefficient score
at that common evaluation point. The default cdid covariance also includes
sampling variation in the estimated cohort mean.&lt;/p>
&lt;p>In nine matched cases with one covariate, the largest absolute ATT
differences were $2.9 \times 10^{-12}$ against R and $2.7 \times 10^{-13}$
against Stata. The largest differences in the fixed-evaluation joint
covariances were $7.8 \times 10^{-14}$ and $2.7 \times 10^{-13}$,
respectively. At 10,000 units and 20 dates, the incomplete not-yet-treated
fit took 0.035 seconds in cdid, 3.941 in R etwfe and 6.198 in Stata jwdid
using the matching fixed-effect tolerances and covariance conventions.
The complete and incomplete 5,000-unit, 10-date fits with four covariates
took 0.017 to 0.026 seconds including dynamic aggregation, with peak
process memory between 440 and 451 MiB on this machine.&lt;/p>
&lt;h2 id="match-the-simple-summary">Match the simple summary&lt;/h2>
&lt;p>To compare with &lt;code>etwfe::emfx(ref, type = &amp;quot;simple&amp;quot;, compress = FALSE)&lt;/code> or Stata&amp;rsquo;s &lt;code>estat simple&lt;/code>, weight cohort-date effects by the number of observed treated rows in those cells. The following computes the same linear contrast and holds the observed cell weights fixed for inference.&lt;/p>
&lt;pre>&lt;code class="language-r">post &amp;lt;- !is.na(panel$y) &amp;amp; panel$g &amp;gt; 0 &amp;amp; panel$t &amp;gt;= panel$g
cell &amp;lt;- paste(panel$g[post], panel$t[post], sep = &amp;quot;:&amp;quot;)
fit_cell &amp;lt;- paste(fit$group, fit$t, sep = &amp;quot;:&amp;quot;)
position &amp;lt;- match(cell, fit_cell)
stopifnot(length(position) &amp;gt; 0L, !anyNA(position))
w &amp;lt;- tabulate(position, nbins = length(fit_cell)) / length(position)
keep &amp;lt;- which(w &amp;gt; 0)
stopifnot(all(is.finite(fit$att[keep])))
V &amp;lt;- fit$V_analytical[keep, keep, drop = FALSE] / fit$n
c(estimate = sum(w[keep] * fit$att[keep]),
std.error = sqrt(drop(crossprod(w[keep], V %*% w[keep]))))
&lt;/code>&lt;/pre>
&lt;p>On the 128-unit validation panels, these simple summaries agree across both control pools and both observation designs. The point estimates agree to numerical precision. The maximum absolute standard-error gap is $1.6 \times 10^{-8}$ against &lt;code>emfx()&lt;/code> and below $10^{-12}$ against Stata after converting its covariance to the same normalization.&lt;/p></description></item><item><title>Compare model robustness across treatment and missing outcome adjustments</title><link>https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/</guid><description>&lt;p>Results below were produced on October 29, 2026 with &lt;code>cdid&lt;/code> 1.1.0.0, &lt;code>did&lt;/code> 2.5.1 and &lt;code>DRDID&lt;/code> 1.3.0 under R 4.5.2, using the displayed seeds where applicable. These are individual examples; they do not establish repeated-sample coverage. OR/DR calls shown here explicitly retain the historical pooled specification; the current default uses separate comparison regressions.&lt;/p>
&lt;p>When covariates influence which units enter treatment, how untreated outcomes evolve, and which outcomes are recorded across dates, chained difference in differences (&lt;code>cdid&lt;/code>, extending Bellégo, Benatia and Dortet-Bernadet 2025 and Callaway and Sant&amp;rsquo;Anna 2021) separates estimation into two distinct modeling layers: &lt;strong>treatment adjustment&lt;/strong> (&lt;code>est_method&lt;/code>) and &lt;strong>handling missing outcomes&lt;/strong> (&lt;code>selection&lt;/code> and &lt;code>selection_est_method&lt;/code>).&lt;/p>
&lt;p>This article explains the four models across the two layers, summarizes the large sample consistency conditions for each supported combination, and walks through concrete misspecification scenarios using the base R script below. For full mathematical definitions, see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a> and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>.&lt;/p>
&lt;h2 id="question">Question&lt;/h2>
&lt;p>Suppose an incomplete longitudinal panel tracks a study population listed in a unit table (&lt;code>frame&lt;/code>) with a baseline covariate &lt;code>x&lt;/code> that shifts both treatment assignment and outcome trajectories, alongside an additional variable &lt;code>z&lt;/code> that shifts whether outcomes are observed. How do the treatment adjustment models and the missing outcome adjustment models interact in &lt;code>cdid&lt;/code>, which estimators remain consistent when one model is misspecified, and when does pooling slopes or supplying extra selection covariates invalidate a doubly robust branch?&lt;/p>
&lt;h2 id="data">Data&lt;/h2>
&lt;h3 id="study-population-and-four-labeled-models">Study population and four labeled models&lt;/h3>
&lt;p>Consider a study population of $N = 2000$ units in the unit table &lt;code>units&lt;/code> (&lt;code>frame&lt;/code>) across $T = 6$ calendar dates $t \in {1, 2, 3, 4, 5, 6}$, with treatment cohort $G = 3$ (&lt;code>first_treat == 3&lt;/code>), never treated controls ($G = 0$, &lt;code>first_treat == 0&lt;/code>), and static unit covariates &lt;code>x&lt;/code> and &lt;code>z&lt;/code>. In the panel dataset &lt;code>obs_panel&lt;/code>, some outcomes are missing, so only a subset of units is observed at both endpoints of any ordered date pair $e = (s, t)$. In the script, &lt;code>x&lt;/code> and &lt;code>z&lt;/code> are independent Uniform(-1, 1) variables. The stated treatment and date-observation logits are then bounded away from zero and one in the population; this does not guarantee a successful fit in every finite draw.&lt;/p>
&lt;p>To recover average treatment effects for the study population in &lt;code>units&lt;/code>, &lt;code>cdid&lt;/code> uses up to four labeled models across two layers:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Symbol&lt;/th>
&lt;th>Model name&lt;/th>
&lt;th>Layer and active options&lt;/th>
&lt;th>What it models and where it is fitted&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>$p$&lt;/td>
&lt;td>Treatment propensity model&lt;/td>
&lt;td>Treatment adjustment (&lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>, using &lt;code>xformla&lt;/code>)&lt;/td>
&lt;td>For each distinct risk set, a logit model of membership in target cohort $g$ versus &lt;code>control_group&lt;/code>, weighted by the chosen missing outcome route.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>$m$&lt;/td>
&lt;td>Counterfactual untreated change regression&lt;/td>
&lt;td>Treatment adjustment (&lt;code>est_method = &amp;quot;reg&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>, using &lt;code>xformla&lt;/code>)&lt;/td>
&lt;td>Weighted least squares on control units: $m_b(X) = \alpha(b) + L(e) z(X)' \beta_b$. &lt;code>outcome_pooling = &amp;quot;separate&amp;quot;&lt;/code> (default) gives each distinct comparison block its own slopes; &lt;code>&amp;quot;pooled&amp;quot;&lt;/code> uses one shared slope vector across blocks. Intercepts are local when the formula includes one.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>$q$&lt;/td>
&lt;td>Observation pair probability model&lt;/td>
&lt;td>Handling missing outcomes (&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code> with &lt;code>selection_est_method = &amp;quot;ipw&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>, using &lt;code>selection_xformla&lt;/code>)&lt;/td>
&lt;td>For each needed cohort and date pair cell $c = (k, e)$, a logit model $q_c(W)$ for observing both dates of pair $e$, either directly (&lt;code>&amp;quot;pair_logit&amp;quot;&lt;/code>) or as the product of two date logits (&lt;code>&amp;quot;independent_period_logit&amp;quot;&lt;/code>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>$j$&lt;/td>
&lt;td>Actual cohort change imputer&lt;/td>
&lt;td>Handling missing outcomes (&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code> with &lt;code>selection_est_method = &amp;quot;imputation&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>, using &lt;code>xformla&lt;/code>)&lt;/td>
&lt;td>For each needed cohort and date pair cell $c = (k, e)$, a weighted least squares linear model $j_c(X) = \alpha(k, e) + L(e) z(X)' \beta(r)$ fitted to observed changes of cohort $k$, &lt;strong>treatment effects included&lt;/strong>, and evaluated across every unit of cohort $k$ in &lt;code>frame&lt;/code>.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="how-the-two-outcome-regressions-differ">How the two outcome regressions differ&lt;/h3>
&lt;p>Both $m$ and $j$ use &lt;code>xformla&lt;/code> and scale covariate slopes by $L(e)$, the number of calendar steps between the positions of dates $s$ and $t$ in the stored calendar (never raw subtraction of date labels), but they serve different layers:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Counterfactual untreated change regression ($m$):&lt;/strong> Fitted only to control units, separately for each distinct comparison block by default (including preperiod comparisons). Setting &lt;code>outcome_pooling = &amp;quot;pooled&amp;quot;&lt;/code> shares one slope vector $\beta$ across blocks and periods. Each block keeps a local intercept $\alpha(b)$ whenever &lt;code>xformla&lt;/code> includes an intercept (&lt;code>~ 0 + x&lt;/code> omits local block intercepts; &lt;code>~ 1&lt;/code> fits block intercepts with zero slopes; &lt;code>~ 0&lt;/code> is refused).&lt;/li>
&lt;li>&lt;strong>Actual cohort change imputer ($j$):&lt;/strong> Fitted within each cohort $k$ (both treated and control cohorts) on units observed at both endpoints of pair $e$ ($S_e = 1$), using fixed unit weights. For a treated cohort after treatment starts, $j_c(X)$ predicts the &lt;strong>actual&lt;/strong> outcome change $\Delta Y_e = Y_t - Y_s$, &lt;strong>including treatment effects&lt;/strong>. It keeps a local intercept $\alpha(k, e)$ per cell when &lt;code>xformla&lt;/code> has an intercept and shares its slope vector $\beta(r)$ according to &lt;code>imputation_pooling&lt;/code>: &lt;code>&amp;quot;separate&amp;quot;&lt;/code> (default, separate slopes per cohort and pair cell), &lt;code>&amp;quot;within_cohort&amp;quot;&lt;/code> (one slope vector per cohort across its pairs), or &lt;code>&amp;quot;across_cohorts&amp;quot;&lt;/code> (one slope vector across all cells).&lt;/li>
&lt;/ol>
&lt;p>The observation probability model $q$ keeps separate cell intercepts when &lt;code>selection_xformla&lt;/code> includes an intercept and pools slopes via &lt;code>selection_pooling&lt;/code> (&lt;code>&amp;quot;separate&amp;quot;&lt;/code>, &lt;code>&amp;quot;within_cohort&amp;quot;&lt;/code>, or &lt;code>&amp;quot;across_cohorts&amp;quot;&lt;/code>), independently of &lt;code>imputation_pooling&lt;/code>. Only &lt;code>selection_xformla&lt;/code> accepts an empty design (&lt;code>~ 0&lt;/code>), fixing each pair probability to $0.5$ (or $0.25$ for a two date product).&lt;/p>
&lt;h3 id="four-routes-for-handling-missing-outcomes">Four routes for handling missing outcomes&lt;/h3>
&lt;ul>
&lt;li>&lt;strong>Without an observation correction (&lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>):&lt;/strong> Fits neither $q$ nor $j$. Observed pair changes within each cohort are scaled by the cohort&amp;rsquo;s empirical pair response rate and passed to treatment adjustment ($p$, $m$, or both).&lt;/li>
&lt;li>&lt;strong>Observation weighting (&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;, selection_est_method = &amp;quot;ipw&amp;quot;&lt;/code>):&lt;/strong> Fits $q_c(W)$ only and weights observed pair changes by inverse fitted pair probabilities combined with cohort repeat rates before running $p$, $m$, or both.&lt;/li>
&lt;li>&lt;strong>Change imputation (&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;, selection_est_method = &amp;quot;imputation&amp;quot;&lt;/code>):&lt;/strong> Fits $j_c(X)$ on observed pairs and averages the predictions $j_c(X)$ over &lt;strong>every&lt;/strong> unit of cohort $k$ in the unit table (&lt;code>selection_universe = &amp;quot;F&amp;quot;&lt;/code>, &lt;code>selection_rho = NULL&lt;/code>), including units whose change was observed. No observation model $q$ is fitted (&lt;code>selection_model&lt;/code>, &lt;code>selection_pooling&lt;/code>, and &lt;code>selection_xformla&lt;/code> are inactive and never evaluated). Treatment adjustment ($p$, $m$, or both) runs on these imputed changes.&lt;/li>
&lt;li>&lt;strong>Augmented correction (&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;, selection_est_method = &amp;quot;dr&amp;quot;&lt;/code>):&lt;/strong> Supports built-in &lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>&amp;quot;reg&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code> on &lt;code>selection_universe = &amp;quot;F&amp;quot;&lt;/code> (&lt;code>selection_rho = NULL&lt;/code>). For each needed cell $c = (k, e)$, every unit of cohort $k$ in &lt;code>frame&lt;/code> receives the reconstructed change&lt;/li>
&lt;/ul>
&lt;p>$$Z_c = j_c(X) + S_e \frac{\Delta Y_e - j_c(X)}{\max(q_c(W),10^{-6})}$$&lt;/p>
&lt;p>where $S_e = 1$ for units observed at both dates of pair $e$ and $0$ otherwise, and $W$ is the union of the covariates in &lt;code>xformla&lt;/code> and &lt;code>selection_xformla&lt;/code>. The residual adjustment is not renormalized. Version 1.1.0.0 floors its inverse observation denominator at $10^{-6}$ (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#probability-safeguards">Probability safeguards&lt;/a>). Treatment adjustment ($p$ for IPW, $m$ for OR, or both for DR) runs on $Z_c$, forming a single estimator that generally differs in finite samples from both observation weighting and change imputation and is not their average.&lt;/p>
&lt;h2 id="assumptions">Assumptions&lt;/h2>
&lt;h3 id="shared-identification-and-regularity-conditions">Shared identification and regularity conditions&lt;/h3>
&lt;p>Every consistency result below is a qualified large sample property requiring the following conditions and, since version 1.1.0.0, inactive probability safeguards in population or additional conditions preserving the original ATT. When clipping binds, the usual robustness branches need not hold; influence-function inference also requires negligible threshold-crossing remainder (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#probability-safeguards">Probability safeguards&lt;/a>).&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Scientifically sufficient conditioning:&lt;/strong> Writing formulas in &lt;code>xformla&lt;/code> or &lt;code>selection_xformla&lt;/code> does not prove sufficiency; the covariates must justify parallel trends and missing outcome assumptions in the population.&lt;/li>
&lt;li>&lt;strong>Parallel trends and no anticipation:&lt;/strong> Conditional on &lt;code>xformla&lt;/code>, untreated potential outcome changes satisfy &lt;code>PT-post&lt;/code> (or &lt;code>PT-all&lt;/code> when selected) with no anticipation beyond &lt;code>anticipation&lt;/code> (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>).&lt;/li>
&lt;li>&lt;strong>Valid missing outcome condition on every used pair:&lt;/strong> Under &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>, observed pair changes must represent each cohort&amp;rsquo;s study population mean for every used pair. Under &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, conditional mean trends missing at random must hold for &lt;strong>every&lt;/strong> cohort $k$ (including actual changes of treated cohorts) and &lt;strong>every&lt;/strong> date pair $(s, t)$ used by the catalog, including preperiod comparisons:&lt;/li>
&lt;/ul>
&lt;p>$$E[Y_t - Y_s \mid W, G = k, S_{s,t} = 1] = E[Y_t - Y_s \mid W, G = k]$$&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Overlap, support, and valid GMM moments:&lt;/strong> Treatment propensities stay strictly below one; observation weighting and augmented correction require $q_c(W) &amp;gt; 0$; change imputation requires observed training mass and prediction support. Active logits need finite regular interior roots and their required design rank; active WLS models need identified, well-conditioned fitting directions and valid required predictions, and all catalog links combined by GMM must satisfy valid moment conditions for the common target parameter (incompatible link pseudo targets make the limit depend on the GMM weights).&lt;/li>
&lt;/ul>
&lt;h3 id="correctness-conditions-across-both-layers">Correctness conditions across both layers&lt;/h3>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Missing outcome route&lt;/th>
&lt;th>&lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code>&lt;/th>
&lt;th>&lt;code>est_method = &amp;quot;reg&amp;quot;&lt;/code>&lt;/th>
&lt;th>&lt;code>est_method = &amp;quot;dr&amp;quot;&lt;/code>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>selection = &amp;quot;none&amp;quot;&lt;/code> (no $q$ or $j$)&lt;/td>
&lt;td>$p$ correct&lt;/td>
&lt;td>$m$ correct across all blocks&lt;/td>
&lt;td>$p$ correct &lt;strong>or&lt;/strong> $m$ correct&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, &lt;code>selection_est_method = &amp;quot;ipw&amp;quot;&lt;/code> (fits $q$)&lt;/td>
&lt;td>$q$ correct in every cell &lt;strong>and&lt;/strong> $p$ correct&lt;/td>
&lt;td>$q$ correct in every cell &lt;strong>and&lt;/strong> $m$ correct&lt;/td>
&lt;td>$q$ correct in every cell &lt;strong>and&lt;/strong> ($p$ correct &lt;strong>or&lt;/strong> $m$ correct)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, &lt;code>selection_est_method = &amp;quot;imputation&amp;quot;&lt;/code> (fits $j$)&lt;/td>
&lt;td>$j$ correct in every cell/group &lt;strong>and&lt;/strong> $p$ correct&lt;/td>
&lt;td>$j$ correct in every cell/group &lt;strong>and&lt;/strong> $m$ correct&lt;/td>
&lt;td>$j$ correct in every cell/group &lt;strong>and&lt;/strong> ($p$ correct &lt;strong>or&lt;/strong> $m$ correct)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, &lt;code>selection_est_method = &amp;quot;dr&amp;quot;&lt;/code> (fits $q$ and $j$)&lt;/td>
&lt;td>For every needed cell $c$, ($q_c$ correct &lt;strong>or&lt;/strong> $j_c$ correct), &lt;strong>and&lt;/strong> $p$ correct&lt;/td>
&lt;td>For every needed cell $c$, ($q_c$ correct &lt;strong>or&lt;/strong> $j_c$ correct), &lt;strong>and&lt;/strong> $m$ correct under the chosen outcome pooling&lt;/td>
&lt;td>For every needed cell $c$, ($q_c$ correct &lt;strong>or&lt;/strong> $j_c$ correct), &lt;strong>and&lt;/strong> ($p$ correct &lt;strong>or&lt;/strong> $m$ correct)&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Four essential qualifications govern this table:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Treatment DR supplies no general correction for a wrong imputer:&lt;/strong> Under pure imputation, the sufficient condition still requires correct $j$ within each needed cell/pooling group. Choosing treatment DR provides the $p$-or-$m$ alternative after reconstruction; it does not generally repair incorrect reconstructed changes. A wrong $j$ can therefore bias the result even when $p$ and $m$ are correct. These conditions are sufficient, not necessary: special projection, aggregation or error cancellations can preserve an effect despite a misspecified nuisance.&lt;/li>
&lt;li>&lt;strong>Coupling through shared fits:&lt;/strong> When &lt;code>outcome_pooling = &amp;quot;pooled&amp;quot;&lt;/code> shares coefficients in $m$, or the selected imputation or observation specification shares coefficients across cells or dates, misspecification in one cell or block can shift a shared slope everywhere it is used.&lt;/li>
&lt;li>&lt;strong>Common conditioning set $W$ and covariates only in &lt;code>selection_xformla&lt;/code>:&lt;/strong> Under the augmented correction, &lt;code>xformla&lt;/code> builds $j$, $m$, and $p$ from covariates $X$, whereas &lt;code>selection_xformla&lt;/code> builds $q$ from $W = (X, Z)$. Variables $Z$ only in &lt;code>selection_xformla&lt;/code> never enter $j$, $m$, or $p$. If $Z$ shifts the conditional mean of actual changes given W but is absent from &lt;code>xformla&lt;/code>, $j_c(X)$ cannot generally represent that W-conditional mean. The stated imputer-correct sufficient branch then fails; correct $q_c(W)$ together with valid treatment adjustment supplies the alternative branch. This does not prove that every effect is biased when both nuisance specifications fail. Adding selection covariates is not automatically harmless.&lt;/li>
&lt;li>&lt;strong>All active fit failures are retained without fallback:&lt;/strong> Active logits must pass their rank/interior-root checks, and active regressions must pass their own rank/conditioning and prediction-support checks, even when the alternative doubly robust model is correct. A completely observed or completely unobserved cell with a free intercept in $q$ has no finite interior logit root and stops with an error (and pooling slopes via &lt;code>selection_pooling&lt;/code> retains cell intercepts, so it does not prevent separation). Pure imputation runs on complete cells because $q$ is inactive, but the augmented correction refuses when $q$, $j$ or an active treatment model fails. Treatment IPW does not fit $m$; treatment OR does not fit $p$. Fixed probability safeguards apply to finite fitted weights; they do not rescue failed fits, and nothing falls back automatically.&lt;/li>
&lt;/ol>
&lt;h2 id="code">Code&lt;/h2>
&lt;pre>&lt;code class="language-r">set.seed(20261027)
n_units &amp;lt;- 2000L
n_periods &amp;lt;- 6L
# Bounded continuous covariates keep the stated population logits away from 0/1.
x &amp;lt;- stats::runif(n_units, min = -1, max = 1)
z &amp;lt;- stats::runif(n_units, min = -1, max = 1)
first_treat &amp;lt;- ifelse(stats::runif(n_units) &amp;lt; stats::plogis(0.6 * x), 3L, 0L)
unit_effect &amp;lt;- stats::rnorm(n_units)
units &amp;lt;- data.frame(id = seq_len(n_units), first_treat = first_treat, x = x, z = z)
full_panel &amp;lt;- data.frame(
id = rep(units$id, each = n_periods),
period = rep(seq_len(n_periods), times = n_units),
first_treat = rep(units$first_treat, each = n_periods),
x = rep(units$x, each = n_periods),
z = rep(units$z, each = n_periods)
)
treated_now &amp;lt;- full_panel$first_treat &amp;gt; 0L &amp;amp; full_panel$period &amp;gt;= full_panel$first_treat
effect &amp;lt;- ifelse(
treated_now,
1 + 0.25 * (full_panel$period - full_panel$first_treat) + 0.5 * full_panel$x,
0
)
full_panel$y &amp;lt;- rep(unit_effect, each = n_periods) +
(0.4 + 0.3 * full_panel$x) * full_panel$period +
effect +
stats::rnorm(nrow(full_panel), mean = 0, sd = 0.5)
# This is scenario 1 only; later scenario changes are discussed, not executed.
observed &amp;lt;- stats::runif(nrow(full_panel)) &amp;lt;
stats::plogis(1.2 + 0.7 * full_panel$x + 0.6 * full_panel$z)
obs_panel &amp;lt;- full_panel[observed, ]
fit_none_dr &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
xformla = ~ x, data = obs_panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
selection = &amp;quot;none&amp;quot;, bstrap = FALSE, cband = FALSE
)
fit_obs_or &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
xformla = ~ x, selection_xformla = ~ x + z, data = obs_panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;reg&amp;quot;,
selection = &amp;quot;conditional_mtar&amp;quot;, selection_est_method = &amp;quot;ipw&amp;quot;,
selection_model = &amp;quot;independent_period_logit&amp;quot;, selection_pooling = &amp;quot;separate&amp;quot;,
bstrap = FALSE, cband = FALSE
)
fit_obs_dr &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
xformla = ~ x, selection_xformla = ~ x + z, data = obs_panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
selection = &amp;quot;conditional_mtar&amp;quot;, selection_est_method = &amp;quot;ipw&amp;quot;,
selection_model = &amp;quot;independent_period_logit&amp;quot;, selection_pooling = &amp;quot;separate&amp;quot;,
bstrap = FALSE, cband = FALSE
)
fit_imp_dr &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
xformla = ~ x, data = obs_panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
selection = &amp;quot;conditional_mtar&amp;quot;, selection_est_method = &amp;quot;imputation&amp;quot;,
imputation_pooling = &amp;quot;separate&amp;quot;, bstrap = FALSE, cband = FALSE
)
fit_aug_dr &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
xformla = ~ x, selection_xformla = ~ x + z, data = obs_panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
selection = &amp;quot;conditional_mtar&amp;quot;, selection_est_method = &amp;quot;dr&amp;quot;,
selection_model = &amp;quot;independent_period_logit&amp;quot;, selection_pooling = &amp;quot;separate&amp;quot;,
imputation_pooling = &amp;quot;separate&amp;quot;, bstrap = FALSE, cband = FALSE
)
fits &amp;lt;- list(none_dr = fit_none_dr, obs_or = fit_obs_or, obs_dr = fit_obs_dr,
imp_dr = fit_imp_dr, aug_dr = fit_aug_dr)
simple_summaries &amp;lt;- lapply(fits, cdid::aggte, type = &amp;quot;simple&amp;quot;)
&lt;/code>&lt;/pre>
&lt;p>Table derived from the five returned &lt;code>simple_summaries&lt;/code> objects (the code above assigns them without printing):&lt;/p>
&lt;pre>&lt;code class="language-text">method estimate std.error
None + treatment DR 1.436272 0.03399377
Observation IPW + OR 1.381341 0.03226414
Observation IPW + DR 1.391160 0.03292001
Imputation + DR 1.377307 0.03253647
Observation DR + DR 1.388394 0.03291157
&lt;/code>&lt;/pre>
&lt;h2 id="interpretation">Interpretation&lt;/h2>
&lt;h3 id="concrete-misspecification-scenarios">Concrete misspecification scenarios&lt;/h3>
&lt;p>The code above specifies only scenario 1. Scenarios 2 to 5 are hypothetical modifications, not additional fitted objects or executed checks. Hold the formulas fixed as indicated; in scenario 4 change only the active imputation pooling options. “Consistent” below names a sufficient large sample branch, conditional on all stated assumptions and regular fitted limits. “No guarantee” means those sufficient conditions no longer establish consistency; it does not prove bias for a particular effect or exclude cancellation.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Scenario&lt;/th>
&lt;th>Correct vs misspecified models&lt;/th>
&lt;th>&lt;code>fit_none_dr&lt;/code>&lt;/th>
&lt;th>&lt;code>fit_obs_or&lt;/code>&lt;/th>
&lt;th>&lt;code>fit_obs_dr&lt;/code>&lt;/th>
&lt;th>&lt;code>fit_imp_dr&lt;/code>&lt;/th>
&lt;th>&lt;code>fit_aug_dr&lt;/code>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;strong>1. Baseline script:&lt;/strong> &lt;code>z&lt;/code> shifts observation only; linear changes in &lt;code>x&lt;/code>; logit $p(x)$ and date logit $q(x, z)$&lt;/td>
&lt;td>$p$, $m$, $q$, $j$ all correct&lt;/td>
&lt;td>Generally biased&lt;/td>
&lt;td>Consistent&lt;/td>
&lt;td>Consistent&lt;/td>
&lt;td>Consistent&lt;/td>
&lt;td>Consistent&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>2. Nonlinear untreated trend:&lt;/strong> replace &lt;code>0.3 * x&lt;/code> by &lt;code>0.3 * x^2&lt;/code> in outcomes&lt;/td>
&lt;td>$p$, $q$ correct; linear $m$, $j$ misspecified&lt;/td>
&lt;td>No guarantee&lt;/td>
&lt;td>No guarantee&lt;/td>
&lt;td>Consistent&lt;/td>
&lt;td>No guarantee&lt;/td>
&lt;td>Consistent&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>3. Wrong observation model $q$:&lt;/strong> independent date observation uses &lt;code>z^2&lt;/code>, but fitted date logits keep &lt;code>~ x + z&lt;/code>&lt;/td>
&lt;td>$j$ correct; imputation/augmented treatment models valid on W; fitted $q$ generally misspecified&lt;/td>
&lt;td>No guarantee&lt;/td>
&lt;td>No guarantee&lt;/td>
&lt;td>No guarantee&lt;/td>
&lt;td>Consistent&lt;/td>
&lt;td>Consistent if the active $q$ fit has a regular interior limit&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>4. Mispooled imputer $j$:&lt;/strong> set &lt;code>imputation_pooling = &amp;quot;within_cohort&amp;quot;&lt;/code> or &lt;code>&amp;quot;across_cohorts&amp;quot;&lt;/code>&lt;/td>
&lt;td>$q$ correct and the original counterfactual model representable; imposed $j$ pooling misspecified&lt;/td>
&lt;td>No guarantee&lt;/td>
&lt;td>Consistent&lt;/td>
&lt;td>Consistent&lt;/td>
&lt;td>No guarantee&lt;/td>
&lt;td>Consistent&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>5. &lt;code>z&lt;/code> also shifts outcomes:&lt;/strong> add &lt;code>0.4 * z * period&lt;/code> while keeping &lt;code>xformla = ~ x&lt;/code>&lt;/td>
&lt;td>$q$ and $p$ correct on W; $j$ and $m$ omit the outcome-shifting &lt;code>z&lt;/code>&lt;/td>
&lt;td>No guarantee&lt;/td>
&lt;td>No guarantee from the stated W-based branch&lt;/td>
&lt;td>Consistent through $q$ and $p$&lt;/td>
&lt;td>No guarantee&lt;/td>
&lt;td>Consistent through $q$ and $p$&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>Scenario 1 (Baseline script):&lt;/strong> Because &lt;code>x&lt;/code> raises both the observation probability and the treatment effect, &lt;code>fit_none_dr&lt;/code> (&lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>) is generally biased. Because &lt;code>z&lt;/code> is independent of &lt;code>(x, first_treat)&lt;/code> and affects only observation, $E[\Delta Y_e \mid x, z, G = k] = E[\Delta Y_e \mid x, G = k]$ is linear in $L(e) x$ within every cell, so $p$, $m$, $q$, and $j$ are all correctly specified.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Scenario 2 (Nonlinear untreated trend in &lt;code>x&lt;/code>):&lt;/strong> Replacing $0.3 x$ with $0.3 x^2$ misspecifies both linear regressions $m$ and $j$ (a nonlinear term is not harmless without a special cancellation). For pure imputation, treatment DR alone no longer supplies a consistency guarantee once $j$ is wrong; a particular effect could still benefit from a special cancellation. Both &lt;code>fit_obs_dr&lt;/code> and &lt;code>fit_aug_dr&lt;/code> remain consistent because $q_c(x, z)$ and $p(x)$ are correct.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Scenario 3 (Misspecified observation model $q$):&lt;/strong> Replace the observation logit by &lt;code>1.2 + 0.7 * x + 0.6 * z^2&lt;/code>, keeping independent date observation and fitted &lt;code>selection_xformla = ~ x + z&lt;/code>. This preserves conditional mean-MTAR: observation uses only the covariates and independent draws, while &lt;code>z&lt;/code> still affects no changes given &lt;code>x&lt;/code>. The fitted $q$ is generally misspecified. Observation weighting then lacks its stated sufficient guarantee; wrong $q$ need not bias every effect. Correct separate-cell $j$ and valid treatment adjustment preserve the imputation and augmented branches, provided every active fit remains regular. Permanent dropout is not implemented here and would require its own stated missingness, support and date-dependence conditions.
The treatment propensity in a reconstructed route is a synthetic weighted-cohort logit, not necessarily the original assignment probability. With correct reconstruction in this law, cohort-rate rescaling changes its intercept while the &lt;code>~ x&lt;/code> design remains adequate. When an observation model or imputer is wrong, do not infer correctness of every downstream fitted nuisance merely because the original assignment or untreated-outcome equation was simple.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Scenario 4 (Mispooled imputer $j$):&lt;/strong> Cohort 3&amp;rsquo;s actual change slope on &lt;code>x&lt;/code> is $0.3 L(e)$ before treatment but shifts by $0.5$ across pairs spanning period 3. A single duration-scaled slope within the treated cohort or across cohorts cannot generally represent both crossing and noncrossing pairs. This misspecifies $j$ and removes the pure-imputation guarantee; it does not misspecify the separate shared counterfactual regression $m$. Correct $q$ preserves the augmented branch under its remaining assumptions.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Scenario 5 (Extra selection covariate &lt;code>z&lt;/code> shifts outcome changes):&lt;/strong> When &lt;code>z&lt;/code> directly shifts outcome changes but is omitted from &lt;code>xformla = ~ x&lt;/code>, $j_c(x)$ is misspecified on $W = (x, z)$. Pure imputation therefore has no guarantee from its stated $j$ branch. Here &lt;code>z&lt;/code> is independent of treatment conditional on &lt;code>x&lt;/code>, so $p$ remains correctly specified on W even though its formula uses only &lt;code>x&lt;/code>; together with correct $q$, this supplies the observation-DR and augmented branches. A different treatment law would require checking that conclusion again. No claim of inevitable OR or imputation bias follows from omitted-variable labels alone.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h3 id="what-a-repeated-sample-robustness-check-requires">What a repeated sample robustness check requires&lt;/h3>
&lt;p>Evaluating finite sample performance across these specifications requires a separate repeated sample Monte Carlo study that computes the exact population truth from the data generating law, runs many independent replicates per design, and reports bias, root mean squared error (RMSE), empirical interval coverage with Monte Carlo standard errors, and the exact count of failed or refused fits. No repeated sample campaign has been executed for this article.&lt;/p>
&lt;h2 id="next-steps">Next steps&lt;/h2>
&lt;ul>
&lt;li>Read &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a> and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a> for full method details.&lt;/li>
&lt;li>Continue to &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Clustered inference, confidence bands, and pretrend tests&lt;/a>, &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options reference&lt;/a>, and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results reference&lt;/a>.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 16 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;strong>Robustness&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>Cross-Pair Chaining, Control Parallel Trends (`PT-ctrl`), and Within-Unit GMM Weighting</title><link>https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/</guid><description>&lt;p>If the target cohort and its controls are observed over different intervals, they may have no date pair in common. Cross-pair chaining uses changes in each group separately and links them through calendar dates where the trend assumptions apply. Set &lt;code>cross_pair = TRUE&lt;/code> to allow those comparisons and use &lt;code>chain_report()&lt;/code> to see how they identify an effect.&lt;/p>
&lt;p>The &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/docs/theory/cross_pair_and_control_trends.tex" target="_blank" rel="noopener">proof of identification and regression equivalence&lt;/a> gives the mathematical conditions. The &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/outputs/cross_pair_monte_carlo_results/">simulation examples&lt;/a> show how the choices matter in different observation patterns.&lt;/p>
&lt;hr>
&lt;p>A simple extension of the original chained DiD idea links successive control cohorts. Balla-Elliott and Norwich proposed this approach for cohorts with short pre-treatment windows. Their stacked cohort fixed-effects regression reproduces the calendar trend by linking those windows. The benchmark below shows how to reproduce its point estimates in &lt;code>cdid&lt;/code> when the cohorts share observation dates within each cohort, and when the within-unit version applies. &lt;a href="https://pdfs.dballaelliott.com/ccdid.pdf" target="_blank" rel="noopener">Cohort-Chained DiD, footnote 2 and Section 2&lt;/a> · &lt;a href="https://doi.org/10.1016/j.jeconom.2024.105783" target="_blank" rel="noopener">Original chained DiD paper&lt;/a>&lt;/p>
&lt;h2 id="options-for-chaining">Options for chaining&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Dimension&lt;/th>
&lt;th>Default &lt;code>cdid::att_gt()&lt;/code>&lt;/th>
&lt;th>Stacked unit-FE slice benchmark in &lt;code>cdid::att_gt()&lt;/code>&lt;/th>
&lt;th>When to use each setting&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;strong>Moment pairing (&lt;code>cross_pair&lt;/code>)&lt;/strong>&lt;/td>
&lt;td>&lt;code>FALSE&lt;/code>: same-pair DiD moments $(s, t)$ where both target $g$ and clean controls $K$ are observed at $(s, t)$&lt;/td>
&lt;td>&lt;code>TRUE&lt;/code>: separate target change moments $\Delta Y_g(s, t)$ and clean control change moments $\Delta Y_k(s, t)$&lt;/td>
&lt;td>Use &lt;code>cross_pair = TRUE&lt;/code> when target and clean controls lack shared date pairs; either &lt;code>FALSE&lt;/code> or &lt;code>TRUE&lt;/code> works on contiguous windows&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Parallel trends (&lt;code>pt_assumption&lt;/code>)&lt;/strong>&lt;/td>
&lt;td>&lt;code>&amp;quot;post&amp;quot;&lt;/code>: parallel trends from each cohort&amp;rsquo;s reference date $b_g$ onward&lt;/td>
&lt;td>&lt;code>&amp;quot;ctrl&amp;quot;&lt;/code>: adds parallel pre-trends among clean control cohorts $k, k' &amp;gt; g$ from &lt;code>pt_start&lt;/code> onward&lt;/td>
&lt;td>Prefer &lt;code>&amp;quot;post&amp;quot;&lt;/code> unless pre-reference control pooling is specifically needed for disconnected pre-periods&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>GMM metric (&lt;code>gmm_weighting&lt;/code>)&lt;/strong>&lt;/td>
&lt;td>&lt;code>&amp;quot;optimal&amp;quot;&lt;/code>: feasible two-step GMM using empirical unit influence functions&lt;/td>
&lt;td>&lt;code>&amp;quot;within&amp;quot;&lt;/code>: analytical within-unit covariance of changes under uncorrelated level shocks&lt;/td>
&lt;td>Use &lt;code>&amp;quot;optimal&amp;quot;&lt;/code> to estimate the moment covariance from the data. Use &lt;code>&amp;quot;within&amp;quot;&lt;/code> for analytical weighting.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Fixed effects / attrition&lt;/strong>&lt;/td>
&lt;td>Within-unit differencing $\Delta Y_{i,s,t}$ (cancels unit $\alpha_i$)&lt;/td>
&lt;td>Within-unit differencing $\Delta Y_{i,s,t}$ (matches stacked unit-FE slice OLS under nested/monotone attrition, and cohort-FE slice OLS on cohort-balanced windows)&lt;/td>
&lt;td>Differencing eliminates the fixed unit level. Representative changes and the other identifying assumptions are still required.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>For the stacked target-slice benchmark, match the target and clean-control sample for each slice, set &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code> and &lt;code>xformla = NULL&lt;/code>, and use the same unit weights. Fit with &lt;code>control_group = &amp;quot;notyettreated&amp;quot;&lt;/code>, &lt;code>base_period = &amp;quot;universal&amp;quot;&lt;/code>, &lt;code>cross_pair = TRUE&lt;/code>, &lt;code>pt_assumption = &amp;quot;ctrl&amp;quot;&lt;/code>, &lt;code>pt_start = NULL&lt;/code> and &lt;code>gmm_weighting = &amp;quot;within&amp;quot;&lt;/code>. With nested observation windows within each cohort, the available point estimates equal the unit-fixed-effect regression coefficients. With a common window for all units in each cohort, they also equal the cohort-fixed-effect coefficients. The installed tests check these cases against independent regressions. Inference in &lt;code>cdid&lt;/code> uses its original-unit influence functions.&lt;/p>
&lt;hr>
&lt;h2 id="2-identification-contiguous-windows-vs-disjoint-cross-pair-windows">2. Identification: Contiguous Windows vs. Disjoint Cross-Pair Windows&lt;/h2>
&lt;h3 id="21-contiguous-short-pre-treatment-windows-need-only-pt-post">2.1 Contiguous short pre-treatment windows need only &lt;code>PT-post&lt;/code>&lt;/h3>
&lt;p>In staggered designs with short pre-treatment windows (for example, cohorts &lt;code>2005..2010&lt;/code> each observed from $g - 4$ onward with no never-treated group), each control cohort&amp;rsquo;s clean untreated dates form a contiguous interval of stored calendar dates.&lt;/p>
&lt;p>Whenever $b_g$ and $t$ lie in the same connected component of the cohort-date observation graph under contiguous cohort windows, every consecutive step $(u_{h-1}, u_h)$ between $b_g$ and $t$ is covered by at least one cohort $k &amp;gt; g$ still untreated at $u_h$. That cohort belongs to the clean control pool $K_{\mathrm{orig}}$ for $(u_{h-1}, u_h)$, so &lt;strong>standard &lt;code>cdid::att_gt(..., control_group = &amp;quot;notyettreated&amp;quot;)&lt;/code> with &lt;code>cross_pair = FALSE&lt;/code> and &lt;code>pt_assumption = &amp;quot;post&amp;quot;&lt;/code> already identifies the exact same post-treatment effects&lt;/strong>—including long-horizon cells where two-period &lt;code>did::att_gt()&lt;/code> returns &lt;code>NA&lt;/code>—and chains directly across biennial or irregular wave spacing.&lt;/p>
&lt;h3 id="22-non-overlapping-observation-pairs-cross_pair--true">2.2 Non-overlapping observation pairs (&lt;code>cross_pair = TRUE&lt;/code>)&lt;/h3>
&lt;p>In rotating or irregular panels where a target cohort and its clean controls are never observed on the &lt;em>same&lt;/em> pair of dates—for example, target cohort $G = 3$ observed at ${1, 2, 4}$, control cohort $G = 4$ at ${2, 3}$, and control cohort $G = 5$ at ${3, 4}$—no control unit has an observed change over $(2, 4)$, and no target unit is observed at date $3$. Same-pair DiD has zero causal links.&lt;/p>
&lt;p>Setting &lt;code>cross_pair = TRUE&lt;/code> constructs separate within-unit change moments for the target cohort ($\gamma_g(t) - \gamma_g(s)$) and for each clean control cohort ($\lambda_{g,k}(t) - \lambda_{g,k}(s)$), anchored at $\gamma_g(b_g) = \lambda_{g,k}(b_g) = 0$. The solver then recovers
$$
\mathrm{ATT}(3, 4) = \mathbb{E}[Y_4 - Y_2 \mid G = 3] - \mathbb{E}[Y_3 - Y_2 \mid G = 4] - \mathbb{E}[Y_4 - Y_3 \mid G = 5]
$$
Use &lt;code>pt_assumption = &amp;quot;post&amp;quot;&lt;/code>, &lt;code>&amp;quot;ctrl&amp;quot;&lt;/code> or &lt;code>&amp;quot;all&amp;quot;&lt;/code> as appropriate for the comparison. Cross-pair fits support IPW, OR and DR treatment adjustment and reference-date covariates and weights. The outcome regression can use separate or pooled slopes.&lt;/p>
&lt;p>With &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, choose observation weighting, actual-change imputation or augmentation. The full study frame supports both probability models where probabilities are used. The options &lt;code>selection_universe = &amp;quot;A&amp;quot;&lt;/code> and &lt;code>&amp;quot;B&amp;quot;&lt;/code> are for observation weighting with a direct pair logit. They require the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#advanced-fitting-the-observation-model-on-part-of-the-unit-table">transport assumptions and inputs&lt;/a>. Independent-period logits, change imputation and augmentation use &lt;code>selection_universe = &amp;quot;F&amp;quot;&lt;/code>.&lt;/p>
&lt;p>The rows of &lt;code>fit$inffunc&lt;/code> follow the original study units. The influence function carries the fitted nuisance contributions, including contributions from units with fewer than two observed outcomes when they enter an active model or a cohort share. Analytical, clustered and multiplier inference use those contributions for cell effects and summaries.&lt;/p>
&lt;hr>
&lt;h2 id="3-parallel-trends-choices-post-ctrl-and-all">3. Parallel-Trends Choices: &lt;code>&amp;quot;post&amp;quot;&lt;/code>, &lt;code>&amp;quot;ctrl&amp;quot;&lt;/code>, and &lt;code>&amp;quot;all&amp;quot;&lt;/code>&lt;/h2>
&lt;p>For a target cohort $g$ with reference date $b_g$:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>&lt;code>pt_assumption = &amp;quot;post&amp;quot;&lt;/code> (default in &lt;code>att_gt()&lt;/code>):&lt;/strong> Assumes conditional parallel trends between cohort $g$ and clean control cohorts from $b_g$ onward. Pre-reference differentials are left free per control pool.&lt;/li>
&lt;li>&lt;strong>&lt;code>pt_assumption = &amp;quot;ctrl&amp;quot;&lt;/code>:&lt;/strong> Keeps &lt;code>PT-post&lt;/code> and assumes clean control cohorts $k, k' &amp;gt; g$ share identical untreated trends from &lt;code>pt_start&lt;/code> onward (&lt;code>pt_start = NULL&lt;/code> defaults to the earliest stored calendar date). Target cohort $g$&amp;rsquo;s own pre-reference drift remains unrestricted, so pre-treatment leads remain genuine falsification checks of $g$&amp;rsquo;s pre-trends against the pooled controls.&lt;/li>
&lt;li>&lt;strong>&lt;code>pt_assumption = &amp;quot;all&amp;quot;&lt;/code> (requires explicit &lt;code>pt_start&lt;/code>):&lt;/strong> Restricts both control cohorts and target cohort $g$ to share common untreated trends from &lt;code>pt_start&lt;/code> onward, setting in-window pre-reference differentials to zero.&lt;/li>
&lt;/ul>
&lt;p>Jointly across all target cohorts, standard not-yet-treated &lt;code>PT-post&lt;/code> for the earliest treated cohort $g_{\min}$ already implies equal untreated trends among clean cohorts from $b_{g_{\min}}$ onward; thus &lt;code>PT-ctrl&lt;/code>&amp;rsquo;s additional empirical restriction is concentrated prior to $b_{g_{\min}}$. If a control cohort experiences an idiosyncratic trend shift before $b_g$, &lt;code>PT-ctrl&lt;/code> (and stacked slice regression) transmits bias into post-treatment estimates, while PT-post leaves that shift unrestricted.&lt;/p>
&lt;hr>
&lt;h2 id="4-inspecting-identification-chains-with-chain_report">4. Inspecting Identification Chains with &lt;code>chain_report()&lt;/code>&lt;/h2>
&lt;p>&lt;code>chain_report()&lt;/code> shows which effects need chaining, a set of comparisons that identifies each effect, and the weights used to combine the available comparisons of a &lt;code>cdid_MP&lt;/code> fit:&lt;/p>
&lt;pre>&lt;code class="language-r">fit &amp;lt;- att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;G&amp;quot;,
data = panel_df,
control_group = &amp;quot;notyettreated&amp;quot;, base_period = &amp;quot;universal&amp;quot;,
cross_pair = TRUE, pt_assumption = &amp;quot;ctrl&amp;quot;, gmm_weighting = &amp;quot;within&amp;quot;,
bstrap = FALSE
)
# Print the comparisons that identify effects for cohort 2005 (set include_pre = TRUE to include pre-treatment cells)
cr &amp;lt;- chain_report(fit, cohort = 2005)
print(cr)
# Tables of effects, identifying comparisons and GMM weights
as.data.frame(cr, what = &amp;quot;summary&amp;quot;)
as.data.frame(cr, what = &amp;quot;witness&amp;quot;)
as.data.frame(cr, what = &amp;quot;gmm_weights&amp;quot;)
&lt;/code>&lt;/pre>
&lt;p>For every estimable cell, the &lt;code>contribution&lt;/code> column (&lt;code>gmm_weight * link_estimate&lt;/code>) in &lt;code>as.data.frame(cr, what = &amp;quot;gmm_weights&amp;quot;)&lt;/code> sums to the reported &lt;code>ATT(g, t)&lt;/code> estimate up to floating-point rounding.&lt;/p>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 21 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/p>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p></description></item><item><title>Diagnose errors and unavailable results</title><link>https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/</guid><description>&lt;p>A chained fit can stop with an error, report effects as unavailable, or complete with surprising results. Each calls for a different check, so first tell them apart.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>What you see&lt;/th>
&lt;th>What it usually means&lt;/th>
&lt;th>First check&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>An error before estimation starts&lt;/td>
&lt;td>A refused request or input&lt;/td>
&lt;td>The condition class&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>A cell or aggregate reported as &lt;code>NA&lt;/code> with a reason&lt;/td>
&lt;td>The available information cannot support that target&lt;/td>
&lt;td>Cell &lt;code>support.status&lt;/code>/&lt;code>support.reason&lt;/code>, or aggregate &lt;code>reason&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>An error during the fit that names a model, covariance or solve&lt;/td>
&lt;td>A computation failed on this sample&lt;/td>
&lt;td>The named component and the data that feed it&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>A completed fit with unexpected estimates or standard errors&lt;/td>
&lt;td>Assumptions, overlap, sample size or estimator choices&lt;/td>
&lt;td>The observation pattern and the inference record&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The package never drops units or comparisons, pools models or substitutes another method to make a fit succeed. Version 1.1.0.0 applies fixed probability safeguards to finite weights, but these do not repair failed nuisance fits or support violations (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#probability-safeguards">Probability safeguards&lt;/a>). A change you make in response, such as a different formula, pooling choice, comparison group or parallel trends assumption, changes the analysis and its assumptions. Justify it from the application, not from whether the new fit runs.&lt;/p>
&lt;p>The inspection snippets use your own data and fitted result, with the names in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>: a long panel &lt;code>panel_data&lt;/code> with columns &lt;code>id&lt;/code>, &lt;code>time&lt;/code>, &lt;code>g&lt;/code> and &lt;code>y&lt;/code>, the unit table &lt;code>units&lt;/code>, and a completed chained result &lt;code>fit&lt;/code>.&lt;/p>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/investigate-missingness/">Investigate missingness and data structure&lt;/a> provides a self-contained example of study-population coverage, selected-pair counts and the fitted diagnostics. Start there when the main question is what the observation pattern supplies.&lt;/p>
&lt;h2 id="read-the-condition-class">Read the condition class&lt;/h2>
&lt;p>Typed chained refusals and fit failures inherit class &lt;code>cdid_error&lt;/code>. Keep the condition and read it instead of retrying with other settings:&lt;/p>
&lt;pre>&lt;code class="language-r">res &amp;lt;- tryCatch(
cdid::att_gt(yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
data = panel_data, frame = units, bstrap = FALSE, cband = FALSE),
cdid_error = function(e) e
)
if (inherits(res, &amp;quot;cdid_error&amp;quot;)) {
print(class(res))
cat(conditionMessage(res), &amp;quot;\n&amp;quot;)
}
&lt;/code>&lt;/pre>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Class&lt;/th>
&lt;th>Cause&lt;/th>
&lt;th>Where to look&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>cdid_mode_error&lt;/code>, &lt;code>cdid_chained_panel&lt;/code>&lt;/td>
&lt;td>An invalid &lt;code>mode&lt;/code> or &lt;code>panel&lt;/code>, or chained mode without &lt;code>panel = TRUE&lt;/code>&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/#repeated-cross-sections">Repeated cross sections&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_chained_balanced&lt;/code>&lt;/td>
&lt;td>&lt;code>allow_unbalanced_panel = FALSE&lt;/code> in chained mode&lt;/td>
&lt;td>&lt;code>did&lt;/code>&amp;rsquo;s balanced subset needs &lt;code>mode = &amp;quot;ordinary&amp;quot;&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_chained_unavailable&lt;/code>&lt;/td>
&lt;td>An unknown &lt;code>est_method&lt;/code> string, or &lt;code>selection_est_method = &amp;quot;dr&amp;quot;&lt;/code> without &lt;code>est_method = &amp;quot;dr&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#supported-combinations">Supported combinations&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_chained_request_*&lt;/code>&lt;/td>
&lt;td>Other unsupported requests or inputs, such as an invalid &lt;code>pt_start&lt;/code>&lt;/td>
&lt;td>The argument named in the message, in the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">options reference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_chained_request_parallel_error&lt;/code>&lt;/td>
&lt;td>&lt;code>pl = TRUE, cores = k&lt;/code> beyond &lt;code>control$workers&lt;/code>&lt;/td>
&lt;td>&lt;a href="#resources-and-parallel-draws">Resources and parallel draws&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_chained_public_control_error&lt;/code>, &lt;code>cdid_chained_public_accuracy_deferred&lt;/code>&lt;/td>
&lt;td>An invalid &lt;code>control&lt;/code> list, or the entry &lt;code>relative_accuracy&lt;/code>, which is not provided&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#the-control-list">The control list&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_custom_ipw_error&lt;/code>&lt;/td>
&lt;td>Malformed or nonfinite output of a custom IPW function&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#treatment-adjustment">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_chained_request_no_inffunc_error&lt;/code>&lt;/td>
&lt;td>&lt;code>aggte()&lt;/code> on a fit with &lt;code>compute_inffunc = FALSE&lt;/code>&lt;/td>
&lt;td>That fit has point estimates only&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_untested_upstream&lt;/code>&lt;/td>
&lt;td>&lt;code>did&lt;/code> older than 2.5.1 or &lt;code>DRDID&lt;/code> older than 1.4.0&lt;/td>
&lt;td>The library your session loads&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>An upstream-version refusal can occur while loading the package, before the call inside this handler starts; inspect the loaded library versions separately. R&amp;rsquo;s own dependency check can refuse an older &lt;code>did&lt;/code> first, with its own message instead of this class. Later versions of &lt;code>did&lt;/code> and &lt;code>DRDID&lt;/code> load but have not been tested with this release.&lt;/p>
&lt;p>Repeated unit and date pairs, dates that are not finite numbers and cohorts that change within a unit are easiest to find before fitting, with the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/#concise-base-r-data-checklist-and-examples">base R checks&lt;/a>. No count of observed outcomes reveals missing outcomes recoded as 0, so check how the data were built.&lt;/p>
&lt;h2 id="inspect-a-completed-fit">Inspect a completed fit&lt;/h2>
&lt;p>Several chained records are nested lists whose layout depends on the estimator. Rely only on entries named in the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#the-chained-record">results reference&lt;/a> or the methods pages, and read the others with &lt;code>str()&lt;/code> first.&lt;/p>
&lt;pre>&lt;code class="language-r">tab &amp;lt;- cdid::tidy(fit)
tab[tab$available %in% FALSE, c(&amp;quot;target.id&amp;quot;, &amp;quot;role&amp;quot;, &amp;quot;support.status&amp;quot;, &amp;quot;support.reason&amp;quot;)]
cdid::glance(fit)[, c(&amp;quot;n.requested&amp;quot;, &amp;quot;n.available&amp;quot;, &amp;quot;inference&amp;quot;, &amp;quot;clustered&amp;quot;)]
fit$chained$inference$kind # &amp;quot;analytic&amp;quot;, &amp;quot;multiplier_bootstrap_iqr_se&amp;quot; or &amp;quot;not_computed&amp;quot;
fit$chained$pretest$status # status of the unconditional pretrend test
fit$chained$selection$method # handling of missing outcomes
str(fit$chained$covariance_handling, max.level = 1)
str(fit$chained$outcome_design, max.level = 1)
str(fit$chained$nuisance_diagnostics, max.level = 1)
&lt;/code>&lt;/pre>
&lt;h2 id="an-effect-is-unavailable">An effect is unavailable&lt;/h2>
&lt;p>An unavailable cell has &lt;code>NA&lt;/code>, never zero, as its estimate, standard error and influence function column, with a support status and reason. Either no chain of observed changes connects the needed dates for the cohort or its controls, or the parallel trends choice does not cover a needed step. The status is relative to the comparisons available to the estimator; it is not a finding that the effect is unidentified in the population.&lt;/p>
&lt;pre>&lt;code class="language-r"># Choose a few relevant pairs in your stored calendar, rather than expanding
# all within-unit pairs. The unit table supplies the full denominators.
obs &amp;lt;- panel_data[!is.na(panel_data$y), c(&amp;quot;id&amp;quot;, &amp;quot;time&amp;quot;, &amp;quot;g&amp;quot;)]
selected_pairs &amp;lt;- data.frame(start = c(1, 2), end = c(2, 3))
pair_support &amp;lt;- do.call(rbind, lapply(seq_len(nrow(selected_pairs)), function(j) {
s &amp;lt;- selected_pairs$start[j]
t &amp;lt;- selected_pairs$end[j]
both &amp;lt;- intersect(obs$id[obs$time == s], obs$id[obs$time == t])
do.call(rbind, lapply(sort(unique(units$g)), function(g) {
take &amp;lt;- units$g == g
data.frame(start = s, end = t, cohort = g, n_study_units = sum(take),
n_both = sum(units$id[take] %in% both),
share_both = mean(units$id[take] %in% both))
}))
}))
pair_support
sort(unique(panel_data$time)) # a date with no rows at all is never reported
&lt;/code>&lt;/pre>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Finding&lt;/th>
&lt;th>Implication&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>No units of the cohort, or no eligible controls, observed at both dates of a needed pair&lt;/td>
&lt;td>That pair supplies no observed comparison. Check for valid alternative paths; a route through earlier dates works only when the unrestricted trends cancel (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/#comparisons-through-earlier-dates">Comparisons through earlier dates&lt;/a>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>A recovery path needs an additional trend restriction before the reference period&lt;/td>
&lt;td>PT-post does not supply it. PT-all may cover the represented step from a &lt;code>pt_start&lt;/code> chosen before seeing results, if that restriction is credible. False restrictions can bias estimates.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>A date of the study calendar has no rows&lt;/td>
&lt;td>Keep its rows with &lt;code>y = NA&lt;/code> so that the date and its cells are reported.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>An aggregate that needs an unavailable cell is &lt;code>NA&lt;/code>; &lt;code>cdid::tidy(agg)&lt;/code> shows &lt;code>available&lt;/code>, &lt;code>n.intended&lt;/code>, &lt;code>n.used&lt;/code>, &lt;code>excluded.ids&lt;/code> and &lt;code>reason&lt;/code>. &lt;code>na.rm = TRUE&lt;/code> instead reports a restricted target over the available cells, marked in &lt;code>restricted&lt;/code>, which is a different estimand.&lt;/p>
&lt;h2 id="a-logit-model-has-no-finite-solution">A logit model has no finite solution&lt;/h2>
&lt;p>Treatment propensity logits are fitted for &lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code> and &lt;code>&amp;quot;dr&amp;quot;&lt;/code>; observation logits only under &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code> with &lt;code>selection_est_method = &amp;quot;ipw&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>. Logits do not drop aliased columns. A logit fit is refused, with its component named, in these cases:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Cause&lt;/th>
&lt;th>Check&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>A covariate or factor level perfectly separates treated from comparison units in a risk set&lt;/td>
&lt;td>The covariate by cohort on the actual fitting support: observed pairs for baseline/observation weighting, all study units after reconstructing missing changes for imputation/augmentation&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>A covariate perfectly separates observed from unobserved units in an observation cell&lt;/td>
&lt;td>The covariate by pair or endpoint-date observation status within the cohort, according to &lt;code>selection_model&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>An active observation cell is all observed or all unobserved and has its own free intercept&lt;/td>
&lt;td>Pair observation by cohort for &lt;code>&amp;quot;pair_logit&amp;quot;&lt;/code>; observation at each endpoint for &lt;code>&amp;quot;independent_period_logit&amp;quot;&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>The design is rank deficient&lt;/td>
&lt;td>Duplicated or constant columns in the formula&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;pre>&lt;code class="language-r"># Units of the unit table observed at both dates 2 and 3, by cohort
ids_both &amp;lt;- intersect(obs$id[obs$time == 2], obs$id[obs$time == 3])
table(cohort = units$g,
observed_both = factor(units$id %in% ids_both, levels = c(FALSE, TRUE)))
# Optional: if region is a static factor covariate supplied in the unit table.
# Use the actual fitting support of your route when checking separation.
if (&amp;quot;region&amp;quot; %in% names(units)) {
with(units[units$id %in% ids_both, ], table(region, cohort = g))
}
&lt;/code>&lt;/pre>
&lt;p>A zero in either column of the first table marks an all observed or all unobserved cell, and pooling slopes leaves its intercept in place. The fixed &lt;code>1e-6&lt;/code> inverse-probability floor does not repair this refusal. No observations are trimmed, observing every unit of a cell does not make its probability a known 1, and known probabilities are not supported. The separation check suffices to show that no finite solution exists, but it is not a complete test for separation. A refusal is not a conclusion about identification: it can reflect a lack of overlap or positivity in the population, or only a small sample.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Observation model setting&lt;/th>
&lt;th>Requirement&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>selection_universe = &amp;quot;F&amp;quot;&lt;/code> (default)&lt;/td>
&lt;td>Fitted on the whole unit table.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;B&amp;quot;&lt;/code> or &lt;code>&amp;quot;A&amp;quot;&lt;/code>&lt;/td>
&lt;td>Only with observation weighting and &lt;code>selection_model = &amp;quot;pair_logit&amp;quot;&lt;/code>, plus a &lt;code>selection_justification&lt;/code>. With &lt;code>selection_rho = NULL&lt;/code> it asserts that the fitting set has the cohort&amp;rsquo;s covariate distribution; otherwise &lt;code>selection_rho&lt;/code> names known normalized density ratios. No diagnostic can confirm it, and the population and standard errors still use the whole unit table.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>selection_model = &amp;quot;independent_period_logit&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;F&amp;quot;&lt;/code>, and observation at the two dates independent given cohort and covariates, which generally fails under permanent dropout.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Change imputation fits no observation logit, but replaces it with a linear model of actual changes that must be correct within each pooling group. The augmented correction refuses an all observed or all unobserved active observation cell with its own free intercept. Pure imputation avoids that observation-logit obstruction, but must still satisfy its own training, model and prediction-support checks. Pooling and formula changes restrict or change the model. Each is a different assumption, to be judged on its own terms (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#which-models-must-be-correct">Which models must be correct&lt;/a>).&lt;/p>
&lt;h2 id="an-outcome-regression-or-imputation-design-is-refused">An outcome regression or imputation design is refused&lt;/h2>
&lt;p>Outcome regression (OR), used by &lt;code>est_method = &amp;quot;reg&amp;quot;&lt;/code> and &lt;code>&amp;quot;dr&amp;quot;&lt;/code>, and change imputation fit linear models. Exact collinearity is preprocessed; unsupported predictions are refused.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Situation&lt;/th>
&lt;th>What the package does&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Exactly collinear columns on the fitting rows&lt;/td>
&lt;td>Pivoted QR (tolerance &lt;code>1e-7&lt;/code>) proposes an alias, accepted only if the retained columns reconstruct every needed prediction row to arithmetic roundoff, &lt;code>64 * .Machine$double.eps&lt;/code> times the original column count. The removal is recorded.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>A direction that varies on treated prediction rows but not among control fitting rows, such as a level present only among treated units&lt;/td>
&lt;td>Refused; its slope is never set to zero.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>A comparison block that is rank deficient on its own&lt;/td>
&lt;td>In default separate mode, valid alias removal must preserve that block&amp;rsquo;s required predictions. Explicit pooled mode can use other blocks to identify shared slopes. There is no automatic switch to pooling.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Nearly collinear columns that fail the alias check&lt;/td>
&lt;td>Retained. The fit is refused if the reduced design is rank deficient or badly conditioned overall; no further columns, observations or moments are dropped.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>An imputation pooling group whose reduced design remains rank deficient&lt;/td>
&lt;td>Refused; nothing is pooled automatically.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;code>fit$chained$outcome_design&lt;/code> and &lt;code>fit$chained$nuisance_diagnostics&lt;/code> record the designs and their preprocessing. The layout depends on the route: inspect the relevant pooled-control or imputation-group record with &lt;code>str()&lt;/code> rather than assuming one common &lt;code>basis&lt;/code> subfield. A removed alias reparameterizes redundant columns; it is not an assumption that a coefficient is zero. For a refused fit, tabulate the covariate by cohort as in the logit check.&lt;/p>
&lt;h2 id="missing-covariates-or-weights-versus-missing-outcomes">Missing covariates or weights versus missing outcomes&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Missing value&lt;/th>
&lt;th>How the package reads it&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>An outcome&lt;/td>
&lt;td>&lt;code>y = NA&lt;/code> is nonresponse at that date, and the row stays. Never recode it as 0 or carry an earlier value forward.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>A covariate that changes within units&lt;/td>
&lt;td>Read at each cohort&amp;rsquo;s reference date, or at the earlier date of a comparison before treatment, from the actual rows, including rows with &lt;code>y = NA&lt;/code>. The default warns and excludes units lacking a required reference covariate from that cohort’s comparisons. Supply known covariates on the relevant rows with &lt;code>y = NA&lt;/code> for missing outcomes. Use &lt;code>missing_reference = &amp;quot;error&amp;quot;&lt;/code> to see the original unit, date, variable and purpose.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>A sampling weight that changes within units&lt;/td>
&lt;td>&lt;code>fix_weights = NULL&lt;/code> and &lt;code>&amp;quot;varying&amp;quot;&lt;/code> are refused; choose &lt;code>&amp;quot;first_period&amp;quot;&lt;/code> or &lt;code>&amp;quot;base_period&amp;quot;&lt;/code> from the design of the weights.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>A treated unit&amp;rsquo;s weight at the first stored date, in aggregates of such fits&lt;/td>
&lt;td>An aggregate that depends on cohort shares is &lt;code>NA&lt;/code>, with the unit identifiers. One-cohort bins and a one-bin group overall summary cancel these shares exactly. Units never treated do not need the mass.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Which rows need covariates depends on the route (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/#static-versus-changing-covariates-and-sampling-weights">Static versus changing covariates and sampling weights&lt;/a>). Values are needed only where an estimate reads them: no route requires every unit to have an observed outcome at the reference date, rows at dates that no comparison reads, or a unit table that is a census. Under &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>, rows present only in the unit table may have an unknown cohort, which makes aggregates that depend on cohort shares unavailable. Observation weighting, change imputation and the augmented correction need known cohorts on every row; the last two also need complete covariates there.&lt;/p>
&lt;h2 id="covariance-regularization">Covariance regularization&lt;/h2>
&lt;p>Under &lt;code>gmm_weighting = &amp;quot;optimal&amp;quot;&lt;/code>, the default, the generalized method of moments (GMM) weights comparisons by the inverse of their estimated covariance. When that covariance needs regularization after exact reductions, &lt;code>gmm_covariance = &amp;quot;tikhonov&amp;quot;&lt;/code> adds a ridge proportional to its trace. At exactly zero covariance a separate least-squares rule applies, with the actual zero sandwich variance. The control entries &lt;code>condition_trigger&lt;/code> (default &lt;code>1e-10&lt;/code>) and &lt;code>ridge_relative&lt;/code> (default &lt;code>1e-4&lt;/code>) set the trigger and size, and &lt;code>fit$chained$covariance_handling&lt;/code> records its use. The ridge changes only the weighting: it supplies no identifying information, cannot make an unavailable cell available, and says nothing by itself about identification. Standard errors still use the sandwich variance of the complete influence functions, identity weighting is never substituted, and nonfinite or materially indefinite covariance inputs are refused without clipping eigenvalues or enlarging the ridge.&lt;/p>
&lt;h2 id="pretrend-tests-are-unavailable">Pretrend tests are unavailable&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Test&lt;/th>
&lt;th>Unavailable when&lt;/th>
&lt;th>Record&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Unconditional Wald test, &lt;code>fit$W&lt;/code> and &lt;code>fit$Wpval&lt;/code>&lt;/td>
&lt;td>A needed nonreference preperiod cell is unavailable or the full joint covariance fails the Cholesky/solve and conditioning checks; with no such cell it is not applicable, and with &lt;code>compute_inffunc = FALSE&lt;/code> it is not computed&lt;/td>
&lt;td>&lt;code>fit$chained$pretest$status&lt;/code>: &lt;code>&amp;quot;computed&amp;quot;&lt;/code>, &lt;code>&amp;quot;unavailable&amp;quot;&lt;/code>, &lt;code>&amp;quot;not_applicable&amp;quot;&lt;/code> or &lt;code>&amp;quot;not_computed&amp;quot;&lt;/code>, with its reason&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Conditional test, &lt;code>cdid::conditional_did_pretest()&lt;/code>&lt;/td>
&lt;td>A needed cell is unavailable; a covariate needed on the grid is missing or has a level absent from the fitted design; no cell before treatment exists; clustered inference has fewer than two clusters; or the estimated process is exactly zero&lt;/td>
&lt;td>&lt;code>pre$chained$status&lt;/code> and &lt;code>pre$chained$reason&lt;/code>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>No test on an available subset is substituted. The conditional test is &lt;code>&amp;quot;not_applicable&amp;quot;&lt;/code> for a custom treatment function. The conditional grid has one point for every unit of the unit table, so one row with a missing &lt;code>xformla&lt;/code> covariate can make the test unavailable while every effect is estimated.&lt;/p>
&lt;p>For the next template, &lt;code>x1&lt;/code> is an application covariate supplied on the route&amp;rsquo;s required supports and on the full testing grid; replace the formula with your justified design.&lt;/p>
&lt;pre>&lt;code class="language-r">set.seed(1) # an available conditional test uses multiplier draws
pre &amp;lt;- cdid::conditional_did_pretest(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
xformla = ~ x1, data = panel_data, frame = units
)
pre$chained$status
pre$chained$reason
&lt;/code>&lt;/pre>
&lt;p>An unavailable test is not evidence about parallel trends, and a test that does not reject does not establish them. Under PT-all, cells before &lt;code>pt_start&lt;/code> can reject without contradicting the assumption (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/#pretrend-tests-under-each-choice">Pretrend tests under each choice&lt;/a>).&lt;/p>
&lt;h2 id="standard-errors-look-unusual">Standard errors look unusual&lt;/h2>
&lt;p>Uncertainty rests on large sample approximations: enough independent units or clusters, overlap, the model conditions of the chosen method and regularity conditions. A completed fit does not establish them, and no finite sample, few cluster or nominal coverage guarantee is made (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#what-the-uncertainty-assumes">What the uncertainty assumes&lt;/a>).&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Symptom&lt;/th>
&lt;th>Likely source&lt;/th>
&lt;th>Check&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Large standard errors for some cells&lt;/td>
&lt;td>Few units observed at both dates of the pairs that reach them&lt;/td>
&lt;td>The pair table above&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Large standard errors under treatment or observation weighting&lt;/td>
&lt;td>Weak overlap: fitted probabilities near 0 or 1&lt;/td>
&lt;td>&lt;code>str(fit$chained$nuisance_diagnostics, max.level = 2)&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Clustered standard errors with few clusters&lt;/td>
&lt;td>The approximation needs many independent clusters&lt;/td>
&lt;td>The clustering record in &lt;code>str(fit$chained$inference)&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Multiplier results that change between runs&lt;/td>
&lt;td>New random signs&lt;/td>
&lt;td>&lt;code>set.seed()&lt;/code> before the call; workers do not change the draws&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>An unusual standard error alone is not evidence of a numerical error. Investigate as a possible software problem an unexplained difference where chained and &lt;code>did&lt;/code> point estimates are expected to agree: &lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>, a complete panel, never treated controls, no covariates, each unit&amp;rsquo;s weight fixed across comparisons, PT-post, and the same &lt;code>anticipation&lt;/code> and &lt;code>base_period&lt;/code>.&lt;/p>
&lt;h2 id="results-differ-from-did">Results differ from did&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Setting&lt;/th>
&lt;th>Relation to &lt;code>did&lt;/code>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>The matched case above&lt;/td>
&lt;td>Point estimates agree up to floating point rounding.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>OR or doubly robust (DR) treatment adjustment&lt;/td>
&lt;td>Can differ when fitted coefficient restrictions or procedures differ. Chained OR uses separate coefficients by default; explicit &lt;code>outcome_pooling = &amp;quot;pooled&amp;quot;&lt;/code> shares slopes across comparison blocks. The method label alone does not imply a difference.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Units not yet treated as controls, even in a balanced panel&lt;/td>
&lt;td>Can differ: chained estimation keeps additional valid control pool moments for the same date pair.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>PT-all&lt;/td>
&lt;td>Need not agree; &lt;code>did&lt;/code> has no such option.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Incomplete panel&lt;/td>
&lt;td>Different observations and assumptions: &lt;code>did&lt;/code>&amp;rsquo;s balanced subset, or its repeated cross section estimators with &lt;code>allow_unbalanced_panel = TRUE&lt;/code>.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Match every setting, and compare point estimates, standard errors and aggregates separately. Outside the matched case, a difference can reflect these choices and is not by itself evidence of an error (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/#why-can-balanced-results-differ-and-which-should-i-use">Why can balanced results differ&lt;/a>). &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a> shows an incomplete panel in which the two routes target different quantities.&lt;/p>
&lt;h2 id="resources-and-parallel-draws">Resources and parallel draws&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;code>control&lt;/code> entry&lt;/th>
&lt;th>Default&lt;/th>
&lt;th>Meaning&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>numeric_workspace_bytes&lt;/code>&lt;/td>
&lt;td>1073741824 (1 GiB)&lt;/td>
&lt;td>Admission limit for the counted numeric workspace; work is split into chunks of &lt;code>chunk_rows&lt;/code> rows, chosen automatically&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>counted_work_limit&lt;/code>&lt;/td>
&lt;td>&lt;code>Inf&lt;/code>&lt;/td>
&lt;td>No estimated work cap; a finite positive whole number opts in&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>workers&lt;/code>&lt;/td>
&lt;td>1&lt;/td>
&lt;td>Worker processes for multiplier draws; never raised automatically&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>A fit whose conservative payload or work estimate exceeds these limits is refused before the stage runs, and nothing is dropped or relaxed. The limits do not bound the memory of the R process or CPU time, and the package does not detect the memory or speed of your machine. A larger &lt;code>numeric_workspace_bytes&lt;/code> admits a larger counted payload; whether the machine can hold it, plus memory the count omits, is yours to judge. A finite &lt;code>counted_work_limit&lt;/code> should be a deliberate budget: the estimate is conservative, so a tight value can refuse fits your machine could complete. &lt;code>fit$chained$public$counted_work_limit&lt;/code> and &lt;code>fit$chained$public$work_cap&lt;/code> record the public cap and the internal ceiling.&lt;/p>
&lt;p>Parallel multiplier draws need a matching declaration of workers:&lt;/p>
&lt;pre>&lt;code class="language-r">fit &amp;lt;- cdid::att_gt(yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
data = panel_data, frame = units,
pl = TRUE, cores = 4, control = list(workers = 4))
&lt;/code>&lt;/pre>
&lt;p>Estimation stays serial, results equal those of &lt;code>cores = 1&lt;/code>, worker buffers count against the workspace, and later &lt;code>aggte()&lt;/code> calls reuse the workers. &lt;code>compute_inffunc = FALSE&lt;/code> returns the same point estimates without influence functions, standard errors, bands or pretrend test, and &lt;code>aggte()&lt;/code> refuses such a fit.&lt;/p>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 20 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;strong>Diagnose errors and unavailable results&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>Estimate familiar DiD models with cdid</title><link>https://www.davidbenatia.com/tools/cdid/guide/from-other-packages/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/from-other-packages/</guid><description>&lt;p>The same &lt;code>cdid::att_gt()&lt;/code> interface can reproduce several widely used difference-in-differences estimators and extend them to panels with incomplete outcomes. Choose the comparison groups and treatment history first. Then decide how to adjust for treatment assignment and whether to correct for selective observation. This page describes cdid 1.3.0.0. The &lt;a href="https://cran.r-project.org/package=cdid" target="_blank" rel="noopener">CRAN release&lt;/a> has its own help and release notes.&lt;/p>
&lt;h2 id="matched-specifications-in-cdid">Matched specifications in cdid&lt;/h2>
&lt;p>For a numerical match, use the same sample, outcome and covariates, untreated reference, and weights on the reported effects. Match the variance convention separately. Here &lt;code>g&lt;/code> is the first treatment date for an absorbing treatment and &lt;code>d&lt;/code> is the current binary treatment status for a treatment that can switch on and off.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>To reproduce&lt;/th>
&lt;th>Use in &lt;code>cdid::att_gt()&lt;/code>&lt;/th>
&lt;th>Where the match holds&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Callaway–Sant&amp;rsquo;Anna, R &lt;a href="https://bcallaway11.github.io/did/reference/att_gt.html" target="_blank" rel="noopener">did&lt;/a>&lt;/td>
&lt;td>&lt;code>mode = &amp;quot;ordinary&amp;quot;&lt;/code>&lt;/td>
&lt;td>Direct delegation, including repeated cross sections. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/#when-chained-and-did-estimates-should-agree">Matched chained cases&lt;/a> explain when the within-unit version gives the same estimates.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Callaway–Sant&amp;rsquo;Anna, Stata &lt;a href="https://psantanna.com/csdid/articles/comparing-did-commands.html" target="_blank" rel="noopener">csdid&lt;/a>&lt;/td>
&lt;td>&lt;code>mode = &amp;quot;ordinary&amp;quot;&lt;/code> for the corresponding R calculation, or a chained fit on the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/#when-chained-and-did-estimates-should-agree">matched cases&lt;/a>&lt;/td>
&lt;td>Align the two-date samples, controls, nuisance fits, and aggregation. In an incomplete panel, &lt;code>bal(pair)&lt;/code> keeps the units with both outcomes in each comparison. Chaining can also use other supported pairs to estimate an effect.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Wooldridge&amp;rsquo;s linear cohort-by-date regression, R &lt;a href="https://grantmcdermott.com/etwfe/reference/etwfe.html" target="_blank" rel="noopener">etwfe&lt;/a> and Stata &lt;a href="https://github.com/friosavila/stpackages/blob/main/jwdid/readme.md" target="_blank" rel="noopener">jwdid&lt;/a>&lt;/td>
&lt;td>&lt;code>est_method = &amp;quot;reg&amp;quot;, control = list(preset = &amp;quot;cohort_time_fe&amp;quot;)&lt;/code>&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cohort-time-fe/#match-r-etwfe-and-stata-jwdid">Matched linear models&lt;/a> with unit fixed effects, never-treated or not-yet-treated controls, and optional time-invariant covariates. The comparison covers complete and incomplete panels. See the &lt;a href="#what-the-linear-etwfe-match-covers">supported specifications&lt;/a>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Sun–Abraham, R &lt;a href="https://lrberge.github.io/fixest/reference/sunab.html" target="_blank" rel="noopener">fixest::sunab&lt;/a> and Stata &lt;a href="https://github.com/lsun20/EventStudyInteract" target="_blank" rel="noopener">eventstudyinteract&lt;/a>&lt;/td>
&lt;td>Same cohort-by-date preset and &lt;code>control_group = &amp;quot;nevertreated&amp;quot;&lt;/code>&lt;/td>
&lt;td>The saturated linear cohort-event specification with the same reference period and never-treated controls. We checked the complete-panel post-treatment cells against &lt;code>sunab()&lt;/code>. To compare the event-study curve, &lt;a href="#how-event-study-averages-are-weighted">average the same cohort effects at each horizon&lt;/a>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Gardner&amp;rsquo;s &lt;a href="https://kylebutts.github.io/did2s/" target="_blank" rel="noopener">did2s&lt;/a> and Borusyak–Jaravel–Spiess &lt;a href="https://github.com/borusyak/did_imputation" target="_blank" rel="noopener">did_imputation&lt;/a> in R and Stata&lt;/td>
&lt;td>Same cohort-by-date preset, &lt;code>control_group = &amp;quot;notyettreated&amp;quot;, pt_assumption = &amp;quot;all&amp;quot;, pt_start = min(panel$t)&lt;/code>&lt;/td>
&lt;td>On a complete, unweighted panel, match the linear untreated regression with unit and date fixed effects, optionally interacting time-invariant covariates with dates. The post-treatment cohort-date effects are unrestricted. &lt;a href="#two-stage-and-imputation-event-studies">Examples with and without covariates&lt;/a>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Dube, Girardi, Jordà and Taylor&amp;rsquo;s &lt;a href="https://github.com/danielegirardi/lpdid" target="_blank" rel="noopener">LP-DiD&lt;/a>&lt;/td>
&lt;td>Fit the &lt;a href="#two-date-comparison-with-r-did">two-date comparison&lt;/a> for the chosen baseline and horizon, or use the linear preset on a complete panel with one adoption cohort and never-treated controls&lt;/td>
&lt;td>The unweighted clean-control long difference in that design. Match the risk sets and the horizon weights to compare a pooled staggered-adoption LP-DiD. Its other weighting and baseline options are outside this example.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Harmon&amp;rsquo;s &lt;a href="https://web.econ.ku.dk/nharmon/docs/harmon2024onlineappendix.pdf" target="_blank" rel="noopener">stepwise DiD&lt;/a>&lt;/td>
&lt;td>Estimate each consecutive two-date comparison with &lt;code>att_gt()&lt;/code> and add the estimates&lt;/td>
&lt;td>Stepwise DiD is the consecutive-link case of chained DiD. Each step uses the cohorts still untreated at its endpoint. &lt;a href="#harmons-stepwise-did">Example with a changing set of controls&lt;/a>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Static binary switching, R &lt;a href="https://cran.r-project.org/package=DIDmultiplegtSTAT" target="_blank" rel="noopener">DIDmultiplegtSTAT&lt;/a> and Stata &lt;a href="https://github.com/Credible-Answers/did_multiplegt_stat" target="_blank" rel="noopener">did_multiplegt_stat&lt;/a>&lt;/td>
&lt;td>&lt;code>att_gt(dname = &amp;quot;d&amp;quot;, ...)&lt;/code>&lt;/td>
&lt;td>&lt;a href="#binary-static-switcher-summaries">Matched binary switcher effects&lt;/a> on complete panels with no covariates. The &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/static-entry-exit/">static model&lt;/a> also supports chained estimation with incomplete outcomes under no carryover.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Balla-Elliott and Norwich&amp;rsquo;s &lt;a href="https://pdfs.dballaelliott.com/ccdid.pdf" target="_blank" rel="noopener">Cohort-Chained DiD&lt;/a>&lt;/td>
&lt;td>&lt;code>control_group = &amp;quot;notyettreated&amp;quot;, base_period = &amp;quot;universal&amp;quot;, cross_pair = TRUE, pt_assumption = &amp;quot;ctrl&amp;quot;, gmm_weighting = &amp;quot;within&amp;quot;&lt;/code>&lt;/td>
&lt;td>Reproduces their stacked &lt;strong>cohort&lt;/strong> fixed-effects point estimates with common observation dates within each cohort and the same sample and weights. &lt;a href="#cohort-chained-did">How the original chaining argument extends to cohorts&lt;/a>.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="what-the-linear-etwfe-match-covers">What the linear ETWFE match covers&lt;/h2>
&lt;p>The preset matches the fully interacted linear panel regression using unit fixed effects, calendar effects and a separate effect for each treated cohort and date. The never-treated option also estimates pre-treatment deviations relative to the date before adoption. The not-yet-treated option fits a common untreated path from the first study date. For covariates, use &lt;code>xformla = ~ x1 + x2&lt;/code> to allow both the untreated calendar path and the cohort-date effects to vary with time-invariant characteristics. These are point-estimate and covariance matches on the same estimation rows, after aligning the covariance normalization and the covariate values used to evaluate each effect. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cohort-time-fe/#match-r-etwfe-and-stata-jwdid">R and Stata calls and validation&lt;/a>&lt;/p>
&lt;p>The preset requires a never-treated cohort, equal unit weights, zero anticipation and fixed covariates. The linear cohort-fixed-effects regression also gives the same point estimates in the corresponding complete-panel design. When observation dates vary within a cohort, use unit fixed effects in the reference command for this comparison. The upstream packages also offer linear specifications outside this preset, including time-varying regressors, sampling weights, additional fixed effects, and restrictions on treatment effects such as &lt;code>jwdid&lt;/code>&amp;rsquo;s &lt;code>hettype(event)&lt;/code>. That option estimates a common effect at each event time directly. Averaging the separate fitted cohort effects at that event time is a different operation. &lt;a href="https://grantmcdermott.com/etwfe/reference/etwfe.html" target="_blank" rel="noopener">R etwfe reference&lt;/a> · &lt;a href="https://github.com/friosavila/stpackages/blob/main/jwdid/jwdid.sthlp" target="_blank" rel="noopener">Stata jwdid help&lt;/a> · &lt;a href="https://doi.org/10.1007/s00181-025-02807-z" target="_blank" rel="noopener">Wooldridge, Sections 5 and 10&lt;/a>&lt;/p>
&lt;h2 id="how-event-study-averages-are-weighted">How event-study averages are weighted&lt;/h2>
&lt;p>An event-study point at horizon 1 averages effects measured one period after adoption. For example, if the 2020 cohort has 60 units and an estimated effect of 1 in 2021, and the 2022 cohort has 40 units and an effect of 3 in 2023, the cohort-size-weighted point is &lt;code>0.6 × 1 + 0.4 × 3 = 1.8&lt;/code>. If only 20 units in the later cohort have an observed outcome in 2023, an average weighted by those observed outcomes would instead be &lt;code>(60 × 1 + 20 × 3) / 80 = 1.5&lt;/code>, even with the same two estimated cohort effects.&lt;/p>
&lt;p>For the comparison, first check the cohort-date effects. Then average the same cohorts at each horizon with the same weights. In the unweighted-panel examples, &lt;code>aggte(type = &amp;quot;dynamic&amp;quot;)&lt;/code> weights each cohort by its study-unit count. If a requested effect is unavailable, it takes an explicit &lt;code>na.rm = TRUE&lt;/code> to average over the supported effects. A regression post-estimation command can instead average over observed treated rows. On a complete panel, the counts coincide when the estimation samples and supported cohorts are the same. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#aggregated-results">Aggregate effects&lt;/a> · &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cohort-time-fe/#match-the-simple-summary">Match an observed-row average&lt;/a>&lt;/p>
&lt;h2 id="two-date-comparison-with-r-did">Two-date comparison with R did&lt;/h2>
&lt;p>Take a complete, unweighted panel with one adoption cohort and never-treated controls. Keep the baseline and one follow-up date, and code them as 1 and 2 with adoption at 2. With &lt;code>base_period = &amp;quot;universal&amp;quot;&lt;/code> and the same time-invariant covariates, compare the follow-up cell. In this design the cohort-by-date preset gives the corresponding single comparison for &lt;code>est_method = &amp;quot;reg&amp;quot;&lt;/code>, &lt;code>&amp;quot;ipw&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>. With no covariates, it also equals the coefficient on the treated indicator in a regression of the long outcome change, the clean-control LP-DiD comparison for these two dates.&lt;/p>
&lt;p>With more dates, a cohort-by-date fit combines supported changes under a common conditional untreated calendar path. The standard chained estimator instead follows the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">chosen parallel-trends window&lt;/a>. In Stata &lt;code>csdid&lt;/code> and the experimental pair-balancing option of R &lt;a href="https://tsailintung.github.io/fastdid/reference/fastdid.html" target="_blank" rel="noopener">fastdid&lt;/a>, each two-date comparison has its own sample. &lt;code>chain_report()&lt;/code> shows which pairs actually contribute to a chained effect. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">R did transition guide&lt;/a>&lt;/p>
&lt;h2 id="two-stage-and-imputation-event-studies">Two-stage and imputation event studies&lt;/h2>
&lt;p>On a complete panel, fitting unit and date effects on untreated observations gives the common calendar path for the match below. The treated observations have their own unrestricted cohort-by-date effects. Averaging their residuals by horizon with the same cohort weights gives the same post-treatment point estimates. The R example compares &lt;code>cdid&lt;/code> with &lt;a href="https://github.com/kylebutts/didimputation" target="_blank" rel="noopener">didimputation&lt;/a> on the same data.&lt;/p>
&lt;pre>&lt;code class="language-r">set.seed(14603)
panel &amp;lt;- expand.grid(t = 1:6, id = 1:72)
panel$g &amp;lt;- rep(c(0L, 3L, 5L), length.out = 72)[panel$id]
panel$y &amp;lt;- rnorm(72)[panel$id] + sin(panel$t) + rnorm(nrow(panel)) +
ifelse(panel$g &amp;gt; 0 &amp;amp; panel$t &amp;gt;= panel$g, (panel$t - panel$g + 1) / 2, 0)
fit &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;t&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;, data = panel,
est_method = &amp;quot;reg&amp;quot;, control_group = &amp;quot;notyettreated&amp;quot;,
base_period = &amp;quot;universal&amp;quot;, pt_assumption = &amp;quot;all&amp;quot;, pt_start = min(panel$t),
bstrap = FALSE, cband = FALSE, control = list(preset = &amp;quot;cohort_time_fe&amp;quot;)
)
es &amp;lt;- cdid::aggte(fit, type = &amp;quot;dynamic&amp;quot;, bstrap = FALSE, cband = FALSE)
ref &amp;lt;- didimputation::did_imputation(panel, &amp;quot;y&amp;quot;, &amp;quot;g&amp;quot;, &amp;quot;t&amp;quot;, &amp;quot;id&amp;quot;, horizon = 0:3)
data.frame(horizon = es$egt, cdid = es$att.egt,
didimputation = ref$estimate[match(as.character(es$egt), ref$term)])
&lt;/code>&lt;/pre>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align:right">Horizon&lt;/th>
&lt;th style="text-align:right">cdid&lt;/th>
&lt;th style="text-align:right">didimputation&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align:right">0&lt;/td>
&lt;td style="text-align:right">0.607052&lt;/td>
&lt;td style="text-align:right">0.607052&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:right">1&lt;/td>
&lt;td style="text-align:right">0.516187&lt;/td>
&lt;td style="text-align:right">0.516187&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:right">2&lt;/td>
&lt;td style="text-align:right">1.918483&lt;/td>
&lt;td style="text-align:right">1.918483&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:right">3&lt;/td>
&lt;td style="text-align:right">1.807355&lt;/td>
&lt;td style="text-align:right">1.807355&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Gardner&amp;rsquo;s two-stage estimator also matches the six cohort-date point estimates in this panel. Give each post-treatment cohort-date cell its own second-stage indicator.&lt;/p>
&lt;pre>&lt;code class="language-r">panel$treated &amp;lt;- as.integer(panel$g &amp;gt; 0 &amp;amp; panel$t &amp;gt;= panel$g)
panel$cell &amp;lt;- ifelse(panel$treated == 1,
paste0(&amp;quot;g&amp;quot;, panel$g, &amp;quot;t&amp;quot;, panel$t), &amp;quot;untreated&amp;quot;)
two_stage &amp;lt;- did2s::did2s(
panel, yname = &amp;quot;y&amp;quot;, first_stage = ~ 0 | id + t,
second_stage = ~ i(cell, ref = &amp;quot;untreated&amp;quot;),
treatment = &amp;quot;treated&amp;quot;, cluster_var = &amp;quot;id&amp;quot;
)
rbind(cdid = fit$att,
did2s = coef(two_stage)[paste0(&amp;quot;cell::g&amp;quot;, fit$group, &amp;quot;t&amp;quot;, fit$t)])
&lt;/code>&lt;/pre>
&lt;h3 id="add-time-invariant-covariates">Add time-invariant covariates&lt;/h3>
&lt;p>For a baseline covariate &lt;code>x&lt;/code>, specify &lt;code>xformla = ~ x&lt;/code> in &lt;code>cdid&lt;/code>. Match the untreated models in Gardner and Borusyak–Jaravel–Spiess by interacting &lt;code>x&lt;/code> with date. The unit effects absorb the time-invariant main effect of &lt;code>x&lt;/code>. The following continues the complete-panel example.&lt;/p>
&lt;pre>&lt;code class="language-r">panel$x &amp;lt;- rnorm(72)[panel$id]
panel_x &amp;lt;- transform(panel, y = y + (0.4 * t + 0.2 * treated * (t - g + 1)) * x)
fit_x &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;t&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;, data = panel_x,
xformla = ~ x, est_method = &amp;quot;reg&amp;quot;, control_group = &amp;quot;notyettreated&amp;quot;,
base_period = &amp;quot;universal&amp;quot;, pt_assumption = &amp;quot;all&amp;quot;, pt_start = min(panel_x$t),
bstrap = FALSE, cband = FALSE, control = list(preset = &amp;quot;cohort_time_fe&amp;quot;)
)
es_x &amp;lt;- cdid::aggte(fit_x, type = &amp;quot;dynamic&amp;quot;, bstrap = FALSE, cband = FALSE)
ref_x &amp;lt;- didimputation::did_imputation(
panel_x, &amp;quot;y&amp;quot;, &amp;quot;g&amp;quot;, &amp;quot;t&amp;quot;, &amp;quot;id&amp;quot;, first_stage = ~ i(t, x, ref = 1) | id + t,
horizon = 0:3
)
two_stage_x &amp;lt;- did2s::did2s(
panel_x, yname = &amp;quot;y&amp;quot;, first_stage = ~ i(t, x, ref = 1) | id + t,
second_stage = ~ i(cell, ref = &amp;quot;untreated&amp;quot;),
treatment = &amp;quot;treated&amp;quot;, cluster_var = &amp;quot;id&amp;quot;
)
c(
didimputation = max(abs(es_x$att.egt -
ref_x$estimate[match(as.character(es_x$egt), ref_x$term)])),
did2s = max(abs(fit_x$att -
coef(two_stage_x)[paste0(&amp;quot;cell::g&amp;quot;, fit_x$group, &amp;quot;t&amp;quot;, fit_x$t)]))
)
# Largest absolute difference is about 5.8e-8 for each match.
&lt;/code>&lt;/pre>
&lt;p>These are post-treatment point-estimate matches. Other first-stage specifications, such as time-varying controls, require their own comparison. With incomplete observations, joint fixed-effects regression and untreated-only imputation can use different information to fit the untreated path. The weights and inference can differ as well. &lt;a href="https://doi.org/10.1007/s00181-025-02807-z" target="_blank" rel="noopener">Wooldridge, Section 5.5&lt;/a> · &lt;a href="https://doi.org/10.1093/restud/rdae007" target="_blank" rel="noopener">Borusyak, Jaravel and Spiess&lt;/a>&lt;/p>
&lt;h2 id="harmons-stepwise-did">Harmon&amp;rsquo;s stepwise DiD&lt;/h2>
&lt;p>For cohort 3 and an effect at date 6, the stepwise estimator adds the DiDs for dates 2–3, 3–4, 4–5 and 5–6. Cohort 5 is eligible as a control for the first two steps. The later steps use the never-treated units. The code below imposes exactly these comparisons on the complete example above. All estimates use the same target cohort. Each two-date fit codes that cohort as treated in its second date and the eligible controls as untreated.&lt;/p>
&lt;pre>&lt;code class="language-r">g0 &amp;lt;- 3L
steps &amp;lt;- vapply(g0:6L, function(s) {
keep &amp;lt;- panel$t %in% c(s - 1L, s) &amp;amp;
(panel$g == g0 | panel$g == 0L | panel$g &amp;gt; s)
pair &amp;lt;- panel[keep, ]
pair$g &amp;lt;- ifelse(pair$g == g0, 2L, 0L)
pair$t &amp;lt;- pair$t - s + 2L
link &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;t&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;, data = pair,
est_method = &amp;quot;reg&amp;quot;, base_period = &amp;quot;universal&amp;quot;, bstrap = FALSE, cband = FALSE
)
link$att[link$t == 2L]
}, numeric(1))
sum(steps)
# [1] 1.696038
&lt;/code>&lt;/pre>
&lt;p>This reproduces the point estimate. To reproduce a stepwise result on an incomplete panel, use Harmon&amp;rsquo;s target units eligible for the requested horizon and the same observed controls in each step. To compute uncertainty for the sum, account for covariance across steps because units can contribute to several comparisons. A single standard chained &lt;code>att_gt()&lt;/code> fit can also combine longer pairs and additional control pools where supported. Its point estimate can then differ from the consecutive-link estimate. &lt;a href="https://web.econ.ku.dk/nharmon/docs/harmon2024onlineappendix.pdf" target="_blank" rel="noopener">Harmon, online appendix, Equation 12&lt;/a>&lt;/p>
&lt;h2 id="cohort-chained-did">Cohort-Chained DiD&lt;/h2>
&lt;p>Cohort-Chained DiD is a simple extension of the original chained DiD argument. Balla-Elliott and Norwich proposed applying it across later-treated control cohorts whose pre-treatment windows are short. For example, one untreated cohort can supply the calendar change from dates 1 to 3 and another can supply the change from 3 to 5. Their stacked regression recovers the change from 1 to 5 through the date effects, even if no single untreated cohort spans it. Their paper cites the original chained DiD argument in footnote 2. &lt;a href="https://doi.org/10.1016/j.jeconom.2024.105783" target="_blank" rel="noopener">Chained DiD&lt;/a> · &lt;a href="https://pdfs.dballaelliott.com/ccdid.pdf" target="_blank" rel="noopener">Cohort-Chained DiD, Section 2&lt;/a>&lt;/p>
&lt;p>In &lt;code>cdid&lt;/code>, &lt;code>cross_pair = TRUE&lt;/code> lets the target cohort and the controls supply changes over different pairs, &lt;code>pt_assumption = &amp;quot;ctrl&amp;quot;&lt;/code> imposes the shared untreated calendar path among eligible controls, and &lt;code>gmm_weighting = &amp;quot;within&amp;quot;&lt;/code> gives the regression weighting. With common observation dates within each cohort and a common regression sample and weights, these settings recover the paper&amp;rsquo;s cohort fixed-effects point estimates. The cross-pair implementation also supports changes measured within individuals when their dates of observation differ, and allows &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#how-to-adjust">observation corrections&lt;/a> for selective observation. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/#options-for-chaining">Cross-pair settings and equivalence&lt;/a> · &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Worked example with short pre-treatment windows&lt;/a>&lt;/p>
&lt;h2 id="binary-static-switcher-summaries">Binary static switcher summaries&lt;/h2>
&lt;p>For this comparison, supply a complete panel with columns &lt;code>id&lt;/code>, &lt;code>time&lt;/code>, &lt;code>d&lt;/code> and &lt;code>y&lt;/code>. Use the current binary treatment status &lt;code>d&lt;/code> in each call. With no covariates, the matched summary averages switches into and out of treatment, expressed in the treated-minus-untreated direction and weighted by the number of switchers.&lt;/p>
&lt;pre>&lt;code class="language-r">fit &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, dname = &amp;quot;d&amp;quot;,
data = panel, est_method = &amp;quot;reg&amp;quot;, xformla = ~1,
switchers = &amp;quot;both&amp;quot;, bstrap = FALSE, cband = FALSE
)
fit$aggregate
ref &amp;lt;- DIDmultiplegtSTAT::did_multiplegt_stat(
df = panel, Y = &amp;quot;y&amp;quot;, ID = &amp;quot;id&amp;quot;, Time = &amp;quot;time&amp;quot;, D = &amp;quot;d&amp;quot;,
estimator = &amp;quot;waoss&amp;quot;, estimation_method = &amp;quot;ra&amp;quot;, exact_match = FALSE
)
ref$results$table[&amp;quot;WAOSS&amp;quot;, ]
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-stata">did_multiplegt_stat y id time d, estimator(was) exact_match graph_off
matrix list e(WAS)
&lt;/code>&lt;/pre>
&lt;p>The complete-panel example with 384 units and eight dates gives 1.211393 in all three programs. Standard errors depend on the variance normalization. With missing outcomes, &lt;code>cdid&lt;/code> can also use changes from other supported dates in the static fit. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/static-entry-exit/">Static entry and exit&lt;/a>&lt;/p>
&lt;h2 id="how-software-uses-incomplete-panels">How software uses incomplete panels&lt;/h2>
&lt;p>The original chained DiD paper formalized a missing-trends assumption. The baseline, called &lt;strong>missing trends completely at random (MTCAR)&lt;/strong> here, asks whether units with both outcomes are representative of their cohort with respect to the &lt;strong>mean change&lt;/strong> over that pair. This is weaker than missing outcomes completely at random (MCAR). For example, survey response can depend on a persistent difference in levels that cancels in changes. Missingness can still select changes if it depends on characteristics related to outcome growth. &lt;a href="https://doi.org/10.1016/j.jeconom.2024.105783" target="_blank" rel="noopener">Chained DiD paper, Assumption 2 and Corollary 1&lt;/a>&lt;/p>
&lt;p>The usual options in the matched commands change which observations enter the calculation. A repeated-cross-section DiD compares outcome levels from separate samples at each date, so it needs assumptions about how those samples represent the population. A pair-balanced DiD uses changes from units observed at both dates. To interpret those changes as population means requires mean-change representativeness, as in MTCAR. A linear regression on available rows uses the outcome model to link those rows. Its application to an incomplete sample still relies on the corresponding restrictions on the observed changes or levels. These sample choices do not by themselves fit a model of outcome observation. &lt;a href="https://bcallaway11.github.io/did/reference/att_gt.html" target="_blank" rel="noopener">R did documentation&lt;/a> · &lt;a href="https://psantanna.com/csdid/articles/comparing-did-commands.html" target="_blank" rel="noopener">Stata csdid sample choices&lt;/a> · &lt;a href="https://doi.org/10.1007/s00181-025-02807-z" target="_blank" rel="noopener">Wooldridge, Section 10&lt;/a>&lt;/p>
&lt;p>Of the implementations compared here, &lt;code>cdid&lt;/code> is the one that combines within-unit chaining with explicit correction for covariate-dependent observation. Under &lt;strong>conditional mean trends missing at random&lt;/strong>, the observed changes must represent the cohort&amp;rsquo;s mean changes &lt;strong>at the same covariate values&lt;/strong>. The corrections average over the study units, including those who are missing one or both outcomes for a given pair. This requires the relevant overlap or prediction support, in addition to the chosen parallel-trends assumption. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Preparing a panel&lt;/a> · &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>How to handle observation&lt;/th>
&lt;th>Set in &lt;code>att_gt()&lt;/code>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Baseline MTCAR&lt;/td>
&lt;td>&lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Weight changes by their probability of observation&lt;/td>
&lt;td>&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;, selection_est_method = &amp;quot;ipw&amp;quot;&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Predict missing actual changes&lt;/td>
&lt;td>&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;, selection_est_method = &amp;quot;imputation&amp;quot;&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Combine observation weighting and change imputation&lt;/td>
&lt;td>&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;, selection_est_method = &amp;quot;dr&amp;quot;&lt;/code>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The same choices are available with outcome regression (&lt;code>est_method = &amp;quot;reg&amp;quot;&lt;/code>), treatment weighting (&lt;code>&amp;quot;ipw&amp;quot;&lt;/code>) and treatment doubly robust adjustment (&lt;code>&amp;quot;dr&amp;quot;&lt;/code>) in the chained adoption and static switching models, including the cohort-by-date preset. That gives three treatment choices and four ways to handle observation. With both DR options, the treatment step combines an untreated-change model and a treatment propensity. The observation step combines an actual-change model and an observation propensity. The missing treated changes can include treatment effects. This is a different prediction from the untreated counterfactual imputed in the Borusyak–Jaravel–Spiess estimator. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a> · &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Observation models&lt;/a>&lt;/p>
&lt;h2 id="measured-runtime">Measured runtime&lt;/h2>
&lt;p>These comparisons use matched regression specifications and analytical inference. The cohort-by-date runs use one thread and unit clustering. The table shows the complete and incomplete not-yet-treated examples from the larger benchmark, plus the complete static switcher example.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Matched specification&lt;/th>
&lt;th>Panel&lt;/th>
&lt;th style="text-align:right">cdid&lt;/th>
&lt;th style="text-align:right">R reference&lt;/th>
&lt;th style="text-align:right">Stata reference&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Linear cohort-by-date, 10,000 units × 20 dates&lt;/td>
&lt;td>Complete&lt;/td>
&lt;td style="text-align:right">0.037 s&lt;/td>
&lt;td style="text-align:right">1.245 s, etwfe&lt;/td>
&lt;td style="text-align:right">2.739 s, jwdid&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Linear cohort-by-date, 10,000 units × 20 dates&lt;/td>
&lt;td>Incomplete&lt;/td>
&lt;td style="text-align:right">0.036 s&lt;/td>
&lt;td style="text-align:right">0.842 s, etwfe&lt;/td>
&lt;td style="text-align:right">2.385 s, jwdid&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Binary static regression, 384 units × 8 dates&lt;/td>
&lt;td>Complete&lt;/td>
&lt;td style="text-align:right">0.033 s&lt;/td>
&lt;td style="text-align:right">0.149 s, DIDmultiplegtSTAT&lt;/td>
&lt;td style="text-align:right">0.162 s, did_multiplegt_stat&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The cohort-by-date benchmark also covers never-treated controls and reports covariate fits, numerical agreement and peak memory. The examples above use no covariates or observation model. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cohort-time-fe/#verified-comparisons">Benchmark settings and results&lt;/a>&lt;/p>
&lt;h2 id="extensions">Extensions&lt;/h2>
&lt;p>Dynamic switching with carryover, as in &lt;a href="https://cran.r-project.org/package=DIDmultiplegtDYN" target="_blank" rel="noopener">DIDmultiplegtDYN&lt;/a> and Stata &lt;a href="https://github.com/Credible-Answers/did_multiplegt_dyn" target="_blank" rel="noopener">did_multiplegt_dyn&lt;/a>, is future work. The current binary switching route targets a static effect. Nonlinear cohort-by-date models, such as Poisson in &lt;code>jwdid&lt;/code>, are also planned extensions. The LP-DiD match above covers the clean-control long difference in the stated design. A dedicated interface for its other horizon and variance-weighting choices would extend that match.&lt;/p>
&lt;p>Other methods start from a different design or target. &lt;a href="https://cran.r-project.org/package=DIDHAD" target="_blank" rel="noopener">DIDHAD&lt;/a> uses quasi-stayers, &lt;a href="https://bcallaway11.github.io/contdid/" target="_blank" rel="noopener">contdid&lt;/a> targets dose responses, and &lt;a href="https://github.com/jonathandroth/staggered" target="_blank" rel="noopener">staggered&lt;/a> assumes randomized treatment timing. &lt;a href="https://cran.r-project.org/package=PanelMatch" target="_blank" rel="noopener">PanelMatch&lt;/a> matches treatment histories, &lt;a href="https://yiqingxu.org/packages/fect/" target="_blank" rel="noopener">fect&lt;/a> also offers factor models, and &lt;a href="https://github.com/synth-inference/synthdid" target="_blank" rel="noopener">synthdid&lt;/a> and Stata &lt;a href="https://github.com/Daniel-Pailanir/sdid" target="_blank" rel="noopener">sdid&lt;/a> use synthetic weights. &lt;a href="https://github.com/asheshrambachan/HonestDiD" target="_blank" rel="noopener">HonestDiD&lt;/a> starts from an estimated event study and its covariance to study sensitivity to parallel trends. Its input can come from a suitably aligned &lt;code>cdid&lt;/code> event study.&lt;/p>
&lt;p>If you would like your method, or another DiD method you use, added to &lt;code>cdid&lt;/code>, please propose it in &lt;a href="https://github.com/dvbn/cdid/issues" target="_blank" rel="noopener">cdid&amp;rsquo;s GitHub issue tracker&lt;/a>. A paper or package link and a short example of the target specification help us understand the request.&lt;/p>
&lt;h2 id="references">References&lt;/h2>
&lt;ul>
&lt;li>Balla-Elliott, D. and I. Norwich (2025). &lt;a href="https://pdfs.dballaelliott.com/ccdid.pdf" target="_blank" rel="noopener">Cohort-Chained DiD: Long-Run Effects with Limited Pre-Treatment Data&lt;/a>.&lt;/li>
&lt;li>Bellégo, C., D. Benatia and V. Dortet-Bernadet (2025). &lt;a href="https://doi.org/10.1016/j.jeconom.2024.105783" target="_blank" rel="noopener">The Chained Difference-in-Differences&lt;/a>. &lt;em>Journal of Econometrics&lt;/em>.&lt;/li>
&lt;li>Borusyak, K., X. Jaravel and J. Spiess (2024). &lt;a href="https://doi.org/10.1093/restud/rdae007" target="_blank" rel="noopener">Revisiting Event-Study Designs: Robust and Efficient Estimation&lt;/a>. &lt;em>Review of Economic Studies&lt;/em>.&lt;/li>
&lt;li>Callaway, B. and P. H. C. Sant’Anna (2021). &lt;a href="https://doi.org/10.1016/j.jeconom.2020.12.001" target="_blank" rel="noopener">Difference-in-Differences with Multiple Time Periods&lt;/a>. &lt;em>Journal of Econometrics&lt;/em>.&lt;/li>
&lt;li>de Chaisemartin, C., X. D’Haultfœuille, F. Pasquier, D. Sow and G. Vazquez-Bare (2026). &lt;a href="https://arxiv.org/abs/2201.06898v7" target="_blank" rel="noopener">Difference-in-Differences Estimators for Treatments Continuously Distributed at Every Period&lt;/a>. The binary, static switcher comparison uses this framework.&lt;/li>
&lt;li>de Chaisemartin, C. and X. D’Haultfœuille (2026). &lt;a href="https://arxiv.org/abs/2007.04267v14" target="_blank" rel="noopener">Difference-in-Differences Estimators of Intertemporal Treatment Effects&lt;/a>. This is the reference for dynamic switching.&lt;/li>
&lt;li>Dube, A., D. Girardi, Ò. Jordà and A. M. Taylor (2025). &lt;a href="https://doi.org/10.1002/jae.70000" target="_blank" rel="noopener">A Local Projections Approach to Difference-in-Differences&lt;/a>. &lt;em>Journal of Applied Econometrics&lt;/em>.&lt;/li>
&lt;li>Gardner, J. (2022). &lt;a href="https://arxiv.org/abs/2207.05943" target="_blank" rel="noopener">Two-Stage Differences in Differences&lt;/a>.&lt;/li>
&lt;li>Harmon, N. A. (2024). &lt;a href="https://web.econ.ku.dk/nharmon/docs/harmon2022difference.pdf" target="_blank" rel="noopener">Difference-in-Differences and Efficient Estimation of Treatment Effects&lt;/a>.&lt;/li>
&lt;li>Sun, L. and S. Abraham (2021). &lt;a href="https://doi.org/10.1016/j.jeconom.2020.09.006" target="_blank" rel="noopener">Estimating Dynamic Treatment Effects in Event Studies with Heterogeneous Treatment Effects&lt;/a>. &lt;em>Journal of Econometrics&lt;/em>.&lt;/li>
&lt;li>Wooldridge, J. M. (2025). &lt;a href="https://doi.org/10.1007/s00181-025-02807-z" target="_blank" rel="noopener">Two-Way Fixed Effects, the Two-Way Mundlak Regression, and Difference-in-Differences Estimators&lt;/a>. &lt;em>Empirical Economics&lt;/em>.&lt;/li>
&lt;/ul></description></item><item><title>Estimate treatment effects from incomplete panels</title><link>https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/</guid><description>&lt;p>Results below were produced on October 29, 2026 with &lt;code>cdid&lt;/code> 1.1.0.0, &lt;code>did&lt;/code> 2.5.1 and &lt;code>DRDID&lt;/code> 1.3.0 under R 4.5.2, using the displayed seeds where applicable. These are individual examples; they do not establish repeated-sample coverage.&lt;/p>
&lt;p>Many longitudinal studies track the same units over time but do not observe every unit at every calendar date. Survey rotation designs observe each wave for a limited window, administrative registers miss periods during temporary gaps, and panel studies experience late entry or dropout. &lt;code>cdid&lt;/code> implements chained difference in differences (Bellégo, Benatia and Dortet-Bernadet 2025), extending the group and time framework of Callaway and Sant&amp;rsquo;Anna (2021) and the workflow of &lt;code>did&lt;/code> so you can estimate treatment effects from incomplete panels without restricting the analysis to complete cases or discarding within unit links.&lt;/p>
&lt;p>This guide shows how chained DiD combines short outcome changes across observation patterns, states the assumptions required for those combinations to identify the target effect, and walks through a complete rotating panel script in base R. For an initial balanced panel walkthrough, see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a> and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Coming from &lt;code>did&lt;/code>&lt;/a>.&lt;/p>
&lt;p>For your own panel, &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a> states the minimum inputs, and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/investigate-missingness/">Investigate missingness and data structure&lt;/a> shows counts and selected-pair checks that include units observed once or never.&lt;/p>
&lt;h2 id="question">Question&lt;/h2>
&lt;p>Suppose a study population contains units first treated at period $G = 3$ (treatment cohort $G = 3$) and units never treated ($G = 0$) across five calendar dates $t \in {1, 2, 3, 4, 5}$. With no treatment anticipation (&lt;code>anticipation = 0&lt;/code>), period $t = 2$ is the baseline reference period for cohort $G = 3$. How can we identify and estimate the average treatment effect for cohort $G = 3$ at period $t = 5$, denoted $\text{ATT}(3, 5)$, when no single unit in the study population is observed at both the reference period $t = 2$ and the target period $t = 5$?&lt;/p>
&lt;h2 id="usable-pair-changes-versus-raw-level-comparisons">Usable pair changes versus raw level comparisons&lt;/h2>
&lt;p>An incomplete panel differs fundamentally from genuine repeated cross sections. When repeated observations on the same unit are linked by &lt;code>idname&lt;/code>, any unit observed at two dates $s &amp;lt; t$ provides an observed outcome change&lt;/p>
&lt;p>$$\Delta Y_{s,t} = Y_t - Y_s$$&lt;/p>
&lt;p>Taking the difference between period $t$ and period $s$ within the same unit removes any additive unobserved individual component $\alpha_i$ that is constant over time.&lt;/p>
&lt;p>Treating an incomplete panel as if it were repeated cross sections compares raw outcome levels across dates without linking observations from the same unit. When entry, dropout, or rotation changes the composition of unobserved fixed effects across dates, raw level samples at different dates can fail to represent the same study population even when within unit changes satisfy the assumptions for chained DiD. Repeated cross section estimators require additional representativeness conditions on outcome levels and stable sample composition across dates that assumptions about outcome changes do not supply.&lt;/p>
&lt;p>At the same time, restricting a panel to complete cases (units observed at all five dates) discards every unit with missing outcomes and fails entirely in a rotating design where no unit is observed in every period. Chained DiD instead forms comparisons from units observed at both dates of each usable pair ${s, t}$ and chains those comparisons together across time. Because a unit must have at least two observed outcomes to supply a change, units with repeated observations contribute outcome differences, while units with one or no observed outcomes remain in the unit table (&lt;code>frame&lt;/code>) to represent the study population.&lt;/p>
&lt;h2 id="four-observation-patterns-across-five-dates">Four observation patterns across five dates&lt;/h2>
&lt;p>To see how observation patterns determine which pair comparisons are available, consider five calendar dates $t = 1, 2, 3, 4, 5$, one treated cohort first treated at $t = 3$ ($G = 3$), and a comparison group of units never treated ($G = 0$).&lt;/p>
&lt;p>&lt;strong>Legend for the four observation tables:&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Each row represents an &lt;strong>observation group&lt;/strong> of study units that mixes &lt;strong>both&lt;/strong> treated units in cohort $G = 3$ and units never treated in $G = 0$.&lt;/li>
&lt;li>&lt;code>Observed&lt;/code> means the outcome $Y_{i,t}$ is recorded for units in that observation group at date $t$.&lt;/li>
&lt;li>&lt;code>Missing&lt;/code> means the outcome $Y_{i,t}$ is missing (&lt;code>NA&lt;/code>) for units in that observation group at date $t$.&lt;/li>
&lt;/ul>
&lt;h3 id="layout-1-balanced-complete-panel">Layout 1: Balanced complete panel&lt;/h3>
&lt;p>In a balanced panel, a single observation group covering the entire study population is observed at all five dates.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Observation group (each row mixes cohort &lt;code>G = 3&lt;/code> and never treated controls &lt;code>G = 0&lt;/code>)&lt;/th>
&lt;th>Observed dates&lt;/th>
&lt;th>&lt;code>t = 1&lt;/code>&lt;/th>
&lt;th>&lt;code>t = 2&lt;/code>&lt;/th>
&lt;th>&lt;code>t = 3&lt;/code>&lt;/th>
&lt;th>&lt;code>t = 4&lt;/code>&lt;/th>
&lt;th>&lt;code>t = 5&lt;/code>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Group 1 (&lt;code>G = 3&lt;/code> and &lt;code>G = 0&lt;/code> units)&lt;/td>
&lt;td>&lt;code>{1, 2, 3, 4, 5}&lt;/code>&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Observed&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Every unit is observed at both endpoints of every date pair ${s, t}$. Direct comparisons from the reference period $t = 2$ to $t = 3$, $t = 4$, and $t = 5$ are all directly available on the full study population, alongside every adjacent and multiperiod pair.&lt;/p>
&lt;h3 id="layout-2-rotating-consecutive-windows">Layout 2: Rotating consecutive windows&lt;/h3>
&lt;p>In a two period rotating panel, the study population is partitioned into four observation groups. Each unit is observed for exactly one window of two consecutive dates: ${1, 2}$, ${2, 3}$, ${3, 4}$, or ${4, 5}$.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Observation group (each row mixes cohort &lt;code>G = 3&lt;/code> and never treated controls &lt;code>G = 0&lt;/code>)&lt;/th>
&lt;th>Observed dates&lt;/th>
&lt;th>&lt;code>t = 1&lt;/code>&lt;/th>
&lt;th>&lt;code>t = 2&lt;/code>&lt;/th>
&lt;th>&lt;code>t = 3&lt;/code>&lt;/th>
&lt;th>&lt;code>t = 4&lt;/code>&lt;/th>
&lt;th>&lt;code>t = 5&lt;/code>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Window group 1 (&lt;code>G = 3&lt;/code> and &lt;code>G = 0&lt;/code> units)&lt;/td>
&lt;td>&lt;code>{1, 2}&lt;/code>&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Missing&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Window group 2 (&lt;code>G = 3&lt;/code> and &lt;code>G = 0&lt;/code> units)&lt;/td>
&lt;td>&lt;code>{2, 3}&lt;/code>&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Missing&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Window group 3 (&lt;code>G = 3&lt;/code> and &lt;code>G = 0&lt;/code> units)&lt;/td>
&lt;td>&lt;code>{3, 4}&lt;/code>&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Missing&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Window group 4 (&lt;code>G = 3&lt;/code> and &lt;code>G = 0&lt;/code> units)&lt;/td>
&lt;td>&lt;code>{4, 5}&lt;/code>&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Observed&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>No unit is observed at both $t = 2$ and $t = 4$, and no unit is observed at both $t = 2$ and $t = 5$. Ordinary two period difference in differences between the reference date $t = 2$ and $t = 5$ has zero units observed at both dates. However, Window group 2 observes ${2, 3}$, Window group 3 observes ${3, 4}$, and Window group 4 observes ${4, 5}$, forming a consecutive chain from $t = 2$ to $t = 5$.&lt;/p>
&lt;h3 id="layout-3-general-overlapping-pairs">Layout 3: General overlapping pairs&lt;/h3>
&lt;p>Incomplete panels in practice rarely follow a single consecutive chain. Units may enter early, experience intermittent gaps, and reenter later, generating both adjacent pairs and longer spans.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Observation group (each row mixes cohort &lt;code>G = 3&lt;/code> and never treated controls &lt;code>G = 0&lt;/code>)&lt;/th>
&lt;th>Observed dates&lt;/th>
&lt;th>&lt;code>t = 1&lt;/code>&lt;/th>
&lt;th>&lt;code>t = 2&lt;/code>&lt;/th>
&lt;th>&lt;code>t = 3&lt;/code>&lt;/th>
&lt;th>&lt;code>t = 4&lt;/code>&lt;/th>
&lt;th>&lt;code>t = 5&lt;/code>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Pair group 1 (&lt;code>G = 3&lt;/code> and &lt;code>G = 0&lt;/code> units)&lt;/td>
&lt;td>&lt;code>{1, 2}&lt;/code>&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Missing&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Pair group 2 (&lt;code>G = 3&lt;/code> and &lt;code>G = 0&lt;/code> units)&lt;/td>
&lt;td>&lt;code>{1, 4}&lt;/code>&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Missing&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Pair group 3 (&lt;code>G = 3&lt;/code> and &lt;code>G = 0&lt;/code> units)&lt;/td>
&lt;td>&lt;code>{2, 3}&lt;/code>&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Missing&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Pair group 4 (&lt;code>G = 3&lt;/code> and &lt;code>G = 0&lt;/code> units)&lt;/td>
&lt;td>&lt;code>{3, 5}&lt;/code>&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Observed&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Pair group 5 (&lt;code>G = 3&lt;/code> and &lt;code>G = 0&lt;/code> units)&lt;/td>
&lt;td>&lt;code>{4, 5}&lt;/code>&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Observed&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Here multiple routes connect the reference period $t = 2$ to $t = 5$:&lt;/p>
&lt;ul>
&lt;li>A two step posttreatment route combines ${2, 3}$ and ${3, 5}$.&lt;/li>
&lt;li>An alternative route bridges backward from $t = 2$ to $t = 1$ using ${1, 2}$, jumps to $t = 4$ using ${1, 4}$, and steps to $t = 5$ using ${4, 5}$.&lt;/li>
&lt;/ul>
&lt;p>&lt;code>cdid&lt;/code> does not discard observations outside a single handpicked path or collapse the comparison catalog to one chain. Instead, the package retains all valid pair comparisons in the catalog and combines the available routes through generalized method of moments (GMM), accounting for the correlation across comparisons when units or estimated model parameters are shared.&lt;/p>
&lt;h3 id="layout-4-gapped-panel-with-an-earlier-bridge-and-a-missing-link">Layout 4: Gapped panel with an earlier bridge and a missing link&lt;/h3>
&lt;p>In a gapped panel, the adjacent transition ${2, 3}$ from the reference period to the first treatment period may not be directly observed, while earlier pairs ${1, 2}$ and ${1, 3}$ and a later span ${3, 5}$ are observed.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Observation group (each row mixes cohort &lt;code>G = 3&lt;/code> and never treated controls &lt;code>G = 0&lt;/code>)&lt;/th>
&lt;th>Observed dates&lt;/th>
&lt;th>&lt;code>t = 1&lt;/code>&lt;/th>
&lt;th>&lt;code>t = 2&lt;/code>&lt;/th>
&lt;th>&lt;code>t = 3&lt;/code>&lt;/th>
&lt;th>&lt;code>t = 4&lt;/code>&lt;/th>
&lt;th>&lt;code>t = 5&lt;/code>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Pair group 1 (&lt;code>G = 3&lt;/code> and &lt;code>G = 0&lt;/code> units)&lt;/td>
&lt;td>&lt;code>{1, 2}&lt;/code>&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Missing&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Pair group 2 (&lt;code>G = 3&lt;/code> and &lt;code>G = 0&lt;/code> units)&lt;/td>
&lt;td>&lt;code>{1, 3}&lt;/code>&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Missing&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Pair group 3 (&lt;code>G = 3&lt;/code> and &lt;code>G = 0&lt;/code> units)&lt;/td>
&lt;td>&lt;code>{3, 5}&lt;/code>&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Observed&lt;/td>
&lt;td>Missing&lt;/td>
&lt;td>Observed&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>This layout illustrates two important features of chained DiD:&lt;/p>
&lt;ol>
&lt;li>Even though no unit is observed at both $t = 2$ and $t = 3$, the earlier pairs ${1, 2}$ and ${1, 3}$ form a valid bridge that recovers the comparison between $t = 2$ and $t = 3$, which then combines with ${3, 5}$ to identify $\text{ATT}(3, 5)$.&lt;/li>
&lt;li>No observed pair links $t = 4$ to the reference period. These comparisons therefore do not recover $\text{ATT}(3, 4)$ under the stated baseline restrictions. If date 4 is retained in &lt;code>data&lt;/code> with &lt;code>NA&lt;/code> outcomes, the requested cell is unavailable; if every date-4 row is omitted, 4 is absent from the stored calendar and no date-4 cell is returned.&lt;/li>
&lt;/ol>
&lt;h2 id="how-chained-differences-identify-treatment-effects">How chained differences identify treatment effects&lt;/h2>
&lt;h3 id="population-difference-in-mean-changes">Population difference in mean changes&lt;/h3>
&lt;p>For any ordered date pair $s &amp;lt; t$, let $D_{s,t}$ denote the population mean outcome change between dates $s$ and $t$ among treated cohort $G = 3$ minus the population mean outcome change between dates $s$ and $t$ among the same never treated comparison population ($G = 0$):&lt;/p>
&lt;p>$$D_{s,t} = E[Y_t - Y_s \mid G = 3] - E[Y_t - Y_s \mid G = 0]$$&lt;/p>
&lt;p>Notice that $D_{s,t}$ is defined on the entire study population of cohort $G = 3$ and never treated controls $G = 0$, not on changing subpopulations across dates.&lt;/p>
&lt;h3 id="parallel-trends-from-the-reference-period-pt-post">Parallel trends from the reference period (PT-post)&lt;/h3>
&lt;p>Under parallel trends from each cohort&amp;rsquo;s reference period (&lt;code>PT-post&lt;/code>, selected by &lt;code>pt_assumption = &amp;quot;post&amp;quot;&lt;/code>), cohort $G = 3$ with zero anticipation (&lt;code>anticipation = 0&lt;/code>) has reference period $t = 2$. &lt;code>PT-post&lt;/code> restricts untreated potential outcome trends from period $t = 2$ onward:&lt;/p>
&lt;p>$$E[Y_t(0) - Y_2(0) \mid G = 3] = E[Y_t(0) - Y_2(0) \mid G = 0] \quad \text{for } t \in {3, 4, 5}$$&lt;/p>
&lt;p>No parallel trends restriction is assumed before period $t = 2$ under &lt;code>PT-post&lt;/code>. In particular, the untreated trend differential between $t = 1$ and $t = 2$,&lt;/p>
&lt;p>$$D_{1,2} = E[Y_2(0) - Y_1(0) \mid G = 3] - E[Y_2(0) - Y_1(0) \mid G = 0]$$&lt;/p>
&lt;p>is unrestricted and need not equal zero.&lt;/p>
&lt;h3 id="telescoping-consecutive-windows-in-layout-2">Telescoping consecutive windows in Layout 2&lt;/h3>
&lt;p>Under &lt;code>PT-post&lt;/code> and no anticipation before $t = 3$, the adjacent population differences from $t = 2$ onward satisfy three population identities:&lt;/p>
&lt;ol>
&lt;li>Between $t = 2$ and $t = 3$, parallel trends between $t = 2$ and $t = 3$ implies that untreated changes cancel, so&lt;/li>
&lt;/ol>
&lt;p>$$D_{2,3} = \text{ATT}(3, 3)$$&lt;/p>
&lt;ol start="2">
&lt;li>Between $t = 3$ and $t = 4$, writing $Y_4(0) - Y_3(0) = \bigl(Y_4(0) - Y_2(0)\bigr) - \bigl(Y_3(0) - Y_2(0)\bigr)$ shows that &lt;code>PT-post&lt;/code> implies $E[Y_4(0) - Y_3(0) \mid G = 3] = E[Y_4(0) - Y_3(0) \mid G = 0]$. The untreated change between $t = 3$ and $t = 4$ cancels, leaving the increment in treatment effects:&lt;/li>
&lt;/ol>
&lt;p>$$D_{3,4} = \text{ATT}(3, 4) - \text{ATT}(3, 3)$$&lt;/p>
&lt;ol start="3">
&lt;li>Between $t = 4$ and $t = 5$, by the same logic,&lt;/li>
&lt;/ol>
&lt;p>$$D_{4,5} = \text{ATT}(3, 5) - \text{ATT}(3, 4)$$&lt;/p>
&lt;p>Summing the consecutive population differences telescopes the intermediate effects:&lt;/p>
&lt;p>$$\text{ATT}(3, 4) = D_{2,3} + D_{3,4}$$&lt;/p>
&lt;p>$$\text{ATT}(3, 5) = D_{2,3} + D_{3,4} + D_{4,5}$$&lt;/p>
&lt;p>Under baseline mean missingness restrictions (&lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>), within each cohort the units observed in each of Window groups 2 (${2, 3}$), 3 (${3, 4}$), and 4 (${4, 5}$) must be representative of that cohort with respect to its mean change over that pair. The comparisons then reconstruct $D_{2,3}$, $D_{3,4}$, and $D_{4,5}$ for the &lt;strong>same&lt;/strong> cohort $G = 3$ and never treated $G = 0$ populations. Changing composition that changes these means can invalidate that reconstruction. These equations equate population expectations. They require neither identical unit-level changes nor exact cancellation among estimated sample comparisons, and they promise neither finite sample unbiasedness nor exact nominal coverage.&lt;/p>
&lt;h3 id="earlier-bridge-cancellation-in-layout-4-without-pt-all">Earlier bridge cancellation in Layout 4 without PT-all&lt;/h3>
&lt;p>Now consider Layout 4, where only ${1, 2}$, ${1, 3}$, and ${3, 5}$ are observed. Because ${2, 3}$ is not observed directly, can we still identify $\text{ATT}(3, 5)$ under &lt;code>PT-post&lt;/code> without assuming parallel trends between $t = 1$ and $t = 2$?&lt;/p>
&lt;p>Yes. In the study population, the identity $Y_3 - Y_1 = (Y_3 - Y_2) + (Y_2 - Y_1)$ holds for every unit. Because $D_{1,3}$ and $D_{1,2}$ are defined as expectations over the &lt;strong>exact same&lt;/strong> cohort $G = 3$ and never treated $G = 0$ populations, linearity of expectation over that fixed population gives&lt;/p>
&lt;p>$$D_{1,3} - D_{1,2} = \bigl(E[Y_3 - Y_1 \mid G = 3] - E[Y_3 - Y_1 \mid G = 0]\bigr) - \bigl(E[Y_2 - Y_1 \mid G = 3] - E[Y_2 - Y_1 \mid G = 0]\bigr)$$&lt;/p>
&lt;p>$$= E[Y_3 - Y_2 \mid G = 3] - E[Y_3 - Y_2 \mid G = 0] = D_{2,3}$$&lt;/p>
&lt;p>In terms of potential outcomes, $D_{1,3} = \text{ATT}(3, 3) + D_{1,2}$ under &lt;code>PT-post&lt;/code> (since the untreated trend between $t = 2$ and $t = 3$ is zero while the earlier trend differential $D_{1,2}$ between $t = 1$ and $t = 2$ is unrestricted). Subtracting $D_{1,2}$ removes the unrestricted prebaseline trend differential $D_{1,2}$ exactly:&lt;/p>
&lt;p>$$D_{1,3} - D_{1,2} = \text{ATT}(3, 3)$$&lt;/p>
&lt;p>Combining this bridge with $D_{3,5} = \text{ATT}(3, 5) - \text{ATT}(3, 3)$ (which holds under &lt;code>PT-post&lt;/code> from $t = 2$ onward) yields&lt;/p>
&lt;p>$$D_{1,3} - D_{1,2} + D_{3,5} = \text{ATT}(3, 5)$$&lt;/p>
&lt;p>This cancellation works because both $D_{1,3}$ and $D_{1,2}$ represent the &lt;strong>same&lt;/strong> cohort $G = 3$ and control $G = 0$ study populations. &lt;code>cdid&lt;/code> under &lt;code>PT-post&lt;/code> does not impose an artificial endpoint cutoff at $t = 2$ that throws away pairs touching $t = 1$, and using the bridge $D_{1,3} - D_{1,2}$ does not invoke additional parallel trends restrictions (&lt;code>PT-all&lt;/code>, &lt;code>pt_assumption = &amp;quot;all&amp;quot;&lt;/code>). Instead, &lt;code>PT-post&lt;/code> retains earlier bridges whenever their prebaseline trend differentials cancel across comparisons representing the same population. By contrast, if ${1, 2}$ were also missing so only ${1, 3}$ and ${3, 5}$ were observed, $D_{1,2}$ would not cancel under &lt;code>PT-post&lt;/code>; identifying $\text{ATT}(3, 5)$ from ${1, 3}$ and ${3, 5}$ alone needs an additional identifying restriction. One sufficient option is &lt;code>PT-all&lt;/code> starting at $t = 1$ (&lt;code>pt_assumption = &amp;quot;all&amp;quot;, pt_start = 1&lt;/code>), which restricts $D_{1,2} = 0$. For a complete comparison of &lt;code>PT-post&lt;/code> and &lt;code>PT-all&lt;/code>, see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends assumptions&lt;/a>.&lt;/p>
&lt;h3 id="missing-links-necessary-support-and-unavailable-effects">Missing links, necessary support, and unavailable effects&lt;/h3>
&lt;p>Under the baseline model illustrated here, a target needs catalog comparisons whose unrestricted trend terms cancel. If a requested cell cannot be recovered, &lt;code>cdid&lt;/code> records catalog-relative unavailability and its reason in &lt;code>result$chained&lt;/code>; this is not a blanket population nonidentification verdict.&lt;/p>
&lt;p>In Layout 4, the observed pairs do not recover date 4. If &lt;code>{3, 5}&lt;/code> is also removed, the earlier bridge still recovers the date-3 effect, but these remaining pairs do not recover dates 4 or 5. A date is reported only if it remains in the stored calendar: keep its rows with &lt;code>y = NA&lt;/code> when it is part of the intended study calendar, rather than assuming an omitted date will appear as an &lt;code>NA&lt;/code> result.&lt;/p>
&lt;p>Keep two practical distinctions in mind when inspecting unavailable effects or fit errors:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Observation graph connectivity alone is not sufficient.&lt;/strong> For the baseline comparisons here, a path must connect the target and reference dates, but connectivity by itself does not guarantee identification or estimation. Each used pair ${s, t}$ must also have sufficient sample support (both cohort $G = 3$ units and eligible control units observed at both $s$ and $t$), covariate overlap, and valid observation selection and parallel trends assumptions so that the observed pair represents the target and control populations.&lt;/li>
&lt;li>&lt;strong>Not every model or solver refusal means lack of population identification.&lt;/strong> When a fit stops because a treatment propensity logit or observation probability logit encounters separation or boundary probabilities, or when an outcome regression design is rank deficient on the realized sample, &lt;code>cdid&lt;/code> raises a typed error describing the failed model component. That failure reflects the fitted model and sample support, not a mathematical proof that the population effect is unidentified.&lt;/li>
&lt;/ol>
&lt;h2 id="assumptions-for-the-rotating-panel-example">Assumptions for the rotating panel example&lt;/h2>
&lt;p>Before running the code below, review the assumptions required for this baseline rotating panel analysis:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Study population and unit table:&lt;/strong> The target parameter is $\text{ATT}(3, t)$ for $t \in {3, 4, 5}$ in the study population represented by the 1,000 units in &lt;code>units&lt;/code> (&lt;code>frame&lt;/code>).&lt;/li>
&lt;li>&lt;strong>Comparison group and no anticipation:&lt;/strong> Units never treated (&lt;code>g == 0&lt;/code>, &lt;code>control_group = &amp;quot;nevertreated&amp;quot;&lt;/code>) serve as the comparison group, and treatment has no effect before period $G = 3$ (&lt;code>anticipation = 0&lt;/code>), placing the reference period for cohort $G = 3$ at $t = 2$.&lt;/li>
&lt;li>&lt;strong>Parallel trends from the reference period (&lt;code>PT-post&lt;/code>):&lt;/strong> From $t = 2$ onward, mean untreated potential outcome changes for cohort $G = 3$ equal those of the never treated population (&lt;code>pt_assumption = &amp;quot;post&amp;quot;&lt;/code>).&lt;/li>
&lt;li>&lt;strong>Representative pair observation (&lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>):&lt;/strong> In this simulation, each unit is assigned to one consecutive two period window ${1, 2}$, ${2, 3}$, ${3, 4}$, or ${4, 5}$ uniformly at random, independent of cohort membership and potential outcomes. Consequently, within both $G = 3$ and $G = 0$, the units observed in each window ${s, t}$ have the same mean outcome change $E[Y_t - Y_s \mid G]$ as the full cohort population. When observation patterns depend on measured covariates, see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>.&lt;/li>
&lt;li>&lt;strong>Positive support:&lt;/strong> Each window has positive population probability in both cohorts. The realized sample must also contain treated and never treated units in every required window; the script checks this and stops if it fails, without redrawing.&lt;/li>
&lt;/ul>
&lt;h2 id="worked-example-rotating-consecutive-panel-in-base-r">Worked example: rotating consecutive panel in base R&lt;/h2>
&lt;h3 id="simulated-truth-in-the-data-generating-process">Simulated truth in the data generating process&lt;/h3>
&lt;p>In the simulation script below:&lt;/p>
&lt;ul>
&lt;li>There are $N = 1000$ units in the study population and $T = 5$ calendar dates ($t = 1, 2, 3, 4, 5$).&lt;/li>
&lt;li>Each unit belongs either to treatment cohort $G = 3$ or to the never treated comparison group $G = 0$.&lt;/li>
&lt;li>Untreated outcomes equal an individual normal fixed effect $\alpha_i \sim \mathcal{N}(0, 1)$, a common calendar trend, plus normal noise $\varepsilon_{i,t} \sim \mathcal{N}(0, 0.5^2)$.&lt;/li>
&lt;li>For units in cohort $G = 3$, the treatment effect at posttreatment dates $t \ge 3$ follows the formula&lt;/li>
&lt;/ul>
&lt;p>$$\tau(3, t) = 1 + 0.25 \times (t - 3)$$&lt;/p>
&lt;p>This formula implies the following true population effects:&lt;/p>
&lt;ul>
&lt;li>At $t = 3$ (event time $e = t - G = 0$): $\text{ATT}(3, 3) = 1 + 0.25 \times (3 - 3) = 1.00$.&lt;/li>
&lt;li>At $t = 4$ (event time $e = t - G = 1$): $\text{ATT}(3, 4) = 1 + 0.25 \times (4 - 3) = 1.25$.&lt;/li>
&lt;li>At $t = 5$ (event time $e = t - G = 2$): $\text{ATT}(3, 5) = 1 + 0.25 \times (5 - 3) = 1.50$.&lt;/li>
&lt;li>Dynamic average across the three posttreatment event times ($e \in {0, 1, 2}$): $(1.00 + 1.25 + 1.50) / 3 = 1.25$.&lt;/li>
&lt;li>At $t = 1$ (preperiod comparison between $t = 1$ and $t = 2$): true pretrend differential equals $0.00$.&lt;/li>
&lt;/ul>
&lt;h3 id="r-code">R code&lt;/h3>
&lt;pre>&lt;code class="language-r">set.seed(2026)
# 1. Create the table of study units (one row per unit in the study population).
N &amp;lt;- 1000L
T_dates &amp;lt;- 5L
units &amp;lt;- data.frame(
id = seq_len(N),
g = ifelse(stats::runif(N) &amp;lt; 0.5, 3, 0)
)
# 2. Allocate each unit independently and uniformly to one consecutive two date
# window: {1, 2}, {2, 3}, {3, 4}, or {4, 5}.
window_start &amp;lt;- sample.int(4L, size = N, replace = TRUE)
stopifnot(all(table(factor(units$g, levels = c(0, 3)),
factor(window_start, levels = 1:4)) &amp;gt; 0))
alpha_i &amp;lt;- stats::rnorm(N, mean = 0, sd = 1)
# 3. Expand to full long panel rows (N * T rows) and mask outcomes outside each
# unit's assigned two consecutive dates with NA.
panel_data &amp;lt;- expand.grid(
time = seq_len(T_dates),
id = units$id
)
panel_data &amp;lt;- panel_data[order(panel_data$id, panel_data$time), c(&amp;quot;id&amp;quot;, &amp;quot;time&amp;quot;)]
rownames(panel_data) &amp;lt;- NULL
panel_data$g &amp;lt;- units$g[panel_data$id]
# Generate full potential outcomes with normal individual effect and normal noise.
eps_it &amp;lt;- stats::rnorm(nrow(panel_data), mean = 0, sd = 0.5)
treat_effect &amp;lt;- ifelse(
panel_data$g == 3 &amp;amp; panel_data$time &amp;gt;= 3,
1 + 0.25 * (panel_data$time - panel_data$g),
0
)
y_full &amp;lt;- alpha_i[panel_data$id] + 0.2 * panel_data$time + treat_effect + eps_it
# Retain y only on the two consecutive dates {w, w + 1}; set y = NA elsewhere.
in_window &amp;lt;- (panel_data$time == window_start[panel_data$id]) |
(panel_data$time == window_start[panel_data$id] + 1L)
panel_data$y &amp;lt;- ifelse(in_window, y_full, NA_real_)
# 4. Fit chained DiD with inverse probability weighting (IPW), PT-post,
# never treated controls, no covariate formula, and analytic standard errors.
fit_rot &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;,
tname = &amp;quot;time&amp;quot;,
idname = &amp;quot;id&amp;quot;,
gname = &amp;quot;g&amp;quot;,
xformla = NULL,
data = panel_data,
panel = TRUE,
allow_unbalanced_panel = TRUE,
control_group = &amp;quot;nevertreated&amp;quot;,
est_method = &amp;quot;ipw&amp;quot;,
selection = &amp;quot;none&amp;quot;,
pt_assumption = &amp;quot;post&amp;quot;,
bstrap = FALSE,
cband = FALSE,
frame = units
)
# 5. Inspect group and time effects and dynamic event time aggregation.
summary(fit_rot)
agg_dyn &amp;lt;- cdid::aggte(fit_rot, type = &amp;quot;dynamic&amp;quot;)
summary(agg_dyn)
&lt;/code>&lt;/pre>
&lt;details>
&lt;summary>Console output&lt;/summary>
&lt;pre>&lt;code class="language-text">cdid chained difference-in-differences (chained IPW-GMM): cdid_MP
cdid 1.1.0.0 result built on did 2.5.1 (tested: did 2.5.1); did's MP methods tabulate the estimates below.
Chained estimators: Bellego C., Benatia D. and V. Dortet-Bernadet (2025). &amp;quot;The Chained Difference-in-Differences.&amp;quot; Journal of Econometrics 248, 105783. doi:10.1016/j.jeconom.2024.105783.
Ordinary estimators: Callaway B. and P. H. C. Sant'Anna (2021). &amp;quot;Difference-in-Differences with Multiple Time Periods.&amp;quot; Journal of Econometrics 225(2), 200-230. doi:10.1016/j.jeconom.2020.12.001.
Call:
cdid::att_gt(yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
xformla = NULL, data = panel_data, panel = TRUE, allow_unbalanced_panel = TRUE,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;ipw&amp;quot;, selection = &amp;quot;none&amp;quot;,
pt_assumption = &amp;quot;post&amp;quot;, bstrap = FALSE, cband = FALSE, frame = units)
Group-Time Average Treatment Effects:
Group Time ATT(g,t) Std. Error [95% Pointwise Conf. Band]
3 2 0.0469 0.0823 -0.1143 0.2081
3 3 0.8946 0.0922 0.7139 1.0753 *
3 4 1.2016 0.1247 0.9573 1.4460 *
3 5 1.3501 0.1573 1.0419 1.6583 *
---
Signif. codes: `*' confidence band does not cover 0
P-value for pre-test of parallel trends assumption: 0.568617658368036
Control Group: Never Treated, Anticipation Periods: 0
Estimation Method: Inverse Probability Weighting
Chained support: 4 of 4 requested cells available.
Units: 1000 in the unit table, 0 observed at all 5 dates, 1000 with at least two observed outcomes.
Observation correction: none (selection = &amp;quot;none&amp;quot;).
Parallel trends: PT-post; base_period = &amp;quot;varying&amp;quot;.
GMM weighting: optimal (two-step); covariance regularization: not applied (moment covariance well conditioned).
Inference: analytic standard errors, unit-level; pointwise intervals.
Parallel-trends pre-test: W = 0.325001, df = 1, p = 0.5686 (Wald test of the pretrend cell).
cdid chained difference-in-differences (chained IPW-GMM): cdid_AGGTEobj
cdid 1.1.0.0 result built on did 2.5.1 (tested: did 2.5.1); did's AGGTEobj methods tabulate the estimates below.
Chained estimators: Bellego C., Benatia D. and V. Dortet-Bernadet (2025). &amp;quot;The Chained Difference-in-Differences.&amp;quot; Journal of Econometrics 248, 105783. doi:10.1016/j.jeconom.2024.105783.
Ordinary estimators: Callaway B. and P. H. C. Sant'Anna (2021). &amp;quot;Difference-in-Differences with Multiple Time Periods.&amp;quot; Journal of Econometrics 225(2), 200-230. doi:10.1016/j.jeconom.2020.12.001.
Call:
cdid::aggte(fit_rot, type = &amp;quot;dynamic&amp;quot;)
Overall summary of ATT's based on event-study/dynamic aggregation:
ATT Std. Error [ 95% Conf. Int.]
1.1488 0.1125 0.9283 1.3692 *
Dynamic Effects:
Event time Estimate Std. Error [95% Pointwise Conf. Band]
-1 0.0469 0.0823 -0.1143 0.2081
0 0.8946 0.0922 0.7139 1.0753 *
1 1.2016 0.1247 0.9573 1.4460 *
2 1.3501 0.1573 1.0419 1.6583 *
---
Signif. codes: `*' confidence band does not cover 0
Control Group: Never Treated, Anticipation Periods: 0
Estimation Method: Inverse Probability Weighting
Chained dynamic aggregation: 4 of 4 intended aggregate(s) available; na.rm = FALSE.
Overall summary: available over its 3 intended bins; pointwise interval.
Parallel trends: PT-post; base_period = &amp;quot;varying&amp;quot;.
Inference: analytic standard errors, unit-level; pointwise intervals.
&lt;/code>&lt;/pre>
&lt;/details>
&lt;h3 id="key-options-used-in-this-call">Key options used in this call&lt;/h3>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Parameter&lt;/th>
&lt;th>Setting used&lt;/th>
&lt;th>Purpose and reference link&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>panel&lt;/code>, &lt;code>allow_unbalanced_panel&lt;/code>&lt;/td>
&lt;td>&lt;code>TRUE&lt;/code>, &lt;code>TRUE&lt;/code>&lt;/td>
&lt;td>Selects chained mode for panel data and retains all units with repeated observations across incomplete windows (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Option reference&lt;/a>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>control_group&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;nevertreated&amp;quot;&lt;/code>&lt;/td>
&lt;td>Uses units never treated (&lt;code>g == 0&lt;/code>) as the comparison group (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Option reference&lt;/a>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>est_method&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;ipw&amp;quot;&lt;/code>&lt;/td>
&lt;td>Uses treatment weighting (inverse probability weighting, IPW) for treatment adjustment (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>selection&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;none&amp;quot;&lt;/code>&lt;/td>
&lt;td>Uses baseline mean missingness assumptions without fitting an observation probability or change imputation model (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>pt_assumption&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;post&amp;quot;&lt;/code>&lt;/td>
&lt;td>Imposes parallel trends from each cohort&amp;rsquo;s reference period (&lt;code>PT-post&lt;/code>) without restricting trends before $t = 2$ (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>bstrap&lt;/code>, &lt;code>cband&lt;/code>&lt;/td>
&lt;td>&lt;code>FALSE&lt;/code>, &lt;code>FALSE&lt;/code>&lt;/td>
&lt;td>Computes analytical standard errors and pointwise normal confidence intervals for &lt;code>att_gt()&lt;/code> (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results and uncertainty&lt;/a>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>frame&lt;/code>&lt;/td>
&lt;td>&lt;code>units&lt;/code>&lt;/td>
&lt;td>Supplies the complete unit table (&lt;code>N = 1000&lt;/code> units) representing the study population (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your data&lt;/a>).&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="interpretation">Interpretation&lt;/h2>
&lt;p>Even though every unit in &lt;code>panel_data&lt;/code> has three missing outcomes (&lt;code>y = NA&lt;/code>) and no unit is observed at both $t = 2$ and $t = 4$ or at both $t = 2$ and $t = 5$, &lt;code>cdid::att_gt()&lt;/code> chains the consecutive window comparisons ${2, 3}$, ${3, 4}$, and ${4, 5}$ to estimate $\text{ATT}(3, 3)$, $\text{ATT}(3, 4)$, and $\text{ATT}(3, 5)$, while using ${1, 2}$ to report the preperiod comparison before treatment. Passing &lt;code>fit_rot&lt;/code> to &lt;code>cdid::aggte(fit_rot, type = &amp;quot;dynamic&amp;quot;)&lt;/code> aggregates these effects by event time $e = t - G$ without refitting the underlying models, using the full unit table influence functions stored in &lt;code>fit_rot&lt;/code> to account for the covariance across chained links. You can inspect the recorded method settings and support details in &lt;code>fit_rot$chained&lt;/code> (see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results reference&lt;/a>).&lt;/p>
&lt;h2 id="next-steps">Next steps&lt;/h2>
&lt;ul>
&lt;li>To check your own longitudinal dataset, structure the unit table (&lt;code>frame&lt;/code>), and handle reference dates for covariates or weights that change over time, read &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>.&lt;/li>
&lt;li>When observation patterns depend on measured characteristics, see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a> to adjust via observation weighting (&lt;code>selection_est_method = &amp;quot;ipw&amp;quot;&lt;/code>), change imputation (&lt;code>selection_est_method = &amp;quot;imputation&amp;quot;&lt;/code>), or doubly robust adjustment for missing outcomes (&lt;code>selection_est_method = &amp;quot;dr&amp;quot;&lt;/code>).&lt;/li>
&lt;li>To compare treatment weighting (&lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code>), outcome regression (&lt;code>est_method = &amp;quot;reg&amp;quot;&lt;/code>), and doubly robust treatment estimation (&lt;code>est_method = &amp;quot;dr&amp;quot;&lt;/code>), see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>.&lt;/li>
&lt;/ul>
&lt;h2 id="returned-effects">Returned effects&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>target.id&lt;/th>
&lt;th>estimate&lt;/th>
&lt;th>std.error&lt;/th>
&lt;th>conf.low&lt;/th>
&lt;th>conf.high&lt;/th>
&lt;th>available&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>pre(g=3,t=2)&lt;/td>
&lt;td>0.0469&lt;/td>
&lt;td>0.0823&lt;/td>
&lt;td>-0.1143&lt;/td>
&lt;td>0.2081&lt;/td>
&lt;td>TRUE&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>ATT(g=3,t=3)&lt;/td>
&lt;td>0.8946&lt;/td>
&lt;td>0.0922&lt;/td>
&lt;td>0.7139&lt;/td>
&lt;td>1.0753&lt;/td>
&lt;td>TRUE&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>ATT(g=3,t=4)&lt;/td>
&lt;td>1.2016&lt;/td>
&lt;td>0.1247&lt;/td>
&lt;td>0.9573&lt;/td>
&lt;td>1.4460&lt;/td>
&lt;td>TRUE&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>ATT(g=3,t=5)&lt;/td>
&lt;td>1.3501&lt;/td>
&lt;td>0.1573&lt;/td>
&lt;td>1.0419&lt;/td>
&lt;td>1.6583&lt;/td>
&lt;td>TRUE&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 3 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;strong>Incomplete panels&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>Familiar difference-in-differences models, with incomplete panels</title><link>https://www.davidbenatia.com/tools/cdid/guide/comparisons/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/comparisons/</guid><description>&lt;p>A survey follows households for three years. Some households are interviewed in years 1 and 2, others in years 2 and 3. Few are interviewed in both years 1 and 3. The two shorter changes still tell us something about the longer interval. Chained difference-in-differences uses those changes to estimate treatment effects when the observation patterns and parallel trends assumptions support the comparisons. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Worked example&lt;/a> · &lt;a href="https://doi.org/10.1016/j.jeconom.2024.105783" target="_blank" rel="noopener">Original chained DiD paper&lt;/a>&lt;/p>
&lt;p>&lt;code>cdid&lt;/code> 1.3.0.0 puts several familiar estimators in the same R interface. It runs the Callaway–Sant&amp;rsquo;Anna estimator through &lt;code>did&lt;/code>, fits the linear cohort-by-date model available in R&amp;rsquo;s &lt;code>etwfe&lt;/code> and Stata&amp;rsquo;s &lt;code>jwdid&lt;/code>, and recovers binary static switcher effects from &lt;code>did_multiplegt_stat&lt;/code>. On matched complete panels, the fixed-effects option also recovers post-treatment estimates from Sun–Abraham, Gardner, and Borusyak–Jaravel–Spiess. The guide shows the unit-and-date fixed-effects match for Gardner and Borusyak–Jaravel–Spiess with and without baseline covariates. The package also recovers Harmon&amp;rsquo;s consecutive stepwise comparisons and the cohort-chained regression of Balla-Elliott and Norwich in their corresponding settings. A single-adoption design with never-treated controls gives the clean-control long differences used in LP-DiD. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-other-packages/">Commands and matched cases&lt;/a>&lt;/p>
&lt;h2 id="what-missing-trends-at-random-means">What missing trends at random means&lt;/h2>
&lt;p>Taking changes within households removes persistent differences in their outcome levels. The original chained DiD paper asks whether households observed at both ends of a pair are representative of their cohort with respect to the &lt;strong>mean change&lt;/strong> over that interval. We call this baseline missing trends completely at random (MTCAR). It is weaker than assuming that outcomes are missing completely at random (MCAR). Households with persistently low income can respond less often while their income changes remain representative. If response depends on a characteristic that also predicts income growth, those changes can be selective. &lt;a href="https://doi.org/10.1016/j.jeconom.2024.105783" target="_blank" rel="noopener">Chained DiD paper, Assumptions 2 and 6&lt;/a>&lt;/p>
&lt;p>Repeated-cross-section DiD compares levels in the samples observed at different dates. Pair-balanced DiD compares changes for units observed at both dates of each comparison. Each needs its own assumption about representativeness. Chaining can use additional observed changes, and the observation correction addresses selection into those changes. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-other-packages/#how-software-uses-incomplete-panels">How the commands use incomplete panels&lt;/a>&lt;/p>
&lt;p>When representativeness holds &lt;strong>conditional on measured characteristics&lt;/strong>, &lt;code>cdid&lt;/code> can weight changes by their probability of observation, predict missing actual changes, or combine both. This choice is separate from using outcome regression, treatment weighting, or doubly robust estimation to construct the treatment comparison. For example, you can fit the cohort-by-date model with a doubly robust treatment adjustment and an augmented correction for missing outcomes. Among the R and Stata implementations in the guide, &lt;code>cdid&lt;/code> brings these observation corrections to chained estimates of the study population&amp;rsquo;s effects. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a> · &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cohort-time-fe/#adjust-for-selective-observation">Cohort-by-date example&lt;/a>&lt;/p>
&lt;p>The matched fits are fast on the tested panels. In a linear cohort-by-date benchmark with 10,000 units, 20 dates, missing outcomes and not-yet-treated controls, the fit including analytical inference took 0.036 seconds in &lt;code>cdid&lt;/code>, 0.842 seconds in R&amp;rsquo;s &lt;code>etwfe&lt;/code>, and 2.385 seconds in Stata&amp;rsquo;s &lt;code>jwdid&lt;/code>. These are medians for the same intercept-only model and observed sample. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cohort-time-fe/#verified-comparisons">Benchmark and comparison conditions&lt;/a>&lt;/p>
&lt;p>The static switching estimator is for settings where past treatment has no lingering effect. Future extensions include dynamic treatment histories and nonlinear cohort-by-date fits. To try the supported specifications, start with the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-other-packages/">matched commands&lt;/a> and use &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/investigate-missingness/">the data guide&lt;/a> to see which changes your panel can supply.&lt;/p>
&lt;p>See the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-other-packages/#references">references for the matched methods&lt;/a>.&lt;/p></description></item><item><title>Get started: estimate effects in a balanced panel</title><link>https://www.davidbenatia.com/tools/cdid/guide/get-started/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/get-started/</guid><description>&lt;p>Results below were produced on October 29, 2026 with &lt;code>cdid&lt;/code> 1.1.0.0, &lt;code>did&lt;/code> 2.5.1 and &lt;code>DRDID&lt;/code> 1.3.0 under R 4.5.2, using the displayed seeds where applicable. These are individual examples; they do not establish repeated-sample coverage.&lt;/p>
&lt;p>This article simulates a small panel in which every unit is observed at every date, estimates the treatment effects in chained mode and then uses each main results function: &lt;code>print()&lt;/code>, &lt;code>summary()&lt;/code>, &lt;code>tidy()&lt;/code>, &lt;code>glance()&lt;/code>, the four types of &lt;code>aggte()&lt;/code>, &lt;code>ggdid()&lt;/code> and export to files. Panels with missing outcomes come later in the guide.&lt;/p>
&lt;h2 id="the-question">The question&lt;/h2>
&lt;p>About half of 2000 units start a treatment in period 3 and stay treated. What is the average effect of the treatment on these units in each of periods 3 to 6, and how do the effects summarize?&lt;/p>
&lt;h2 id="prepare-the-panel">Prepare the panel&lt;/h2>
&lt;p>The simulation uses base R only. All objects are created here.&lt;/p>
&lt;pre>&lt;code class="language-r">set.seed(20261024)
n_units &amp;lt;- 2000
n_periods &amp;lt;- 6
# Each unit is either never treated (coded 0) or first treated in period 3.
# Cohort membership and the fixed individual effect are drawn independently.
first_treat &amp;lt;- sample(c(0, 3), size = n_units, replace = TRUE)
unit_effect &amp;lt;- rnorm(n_units)
sim_panel &amp;lt;- data.frame(
id = rep(seq_len(n_units), each = n_periods),
period = rep(seq_len(n_periods), times = n_units),
first_treat = rep(first_treat, each = n_periods)
)
# True effect: 1 + 0.25 * (period - first_treat) once treated, zero before.
treated_now &amp;lt;- sim_panel$first_treat &amp;gt; 0 &amp;amp;
sim_panel$period &amp;gt;= sim_panel$first_treat
sim_panel$true_effect &amp;lt;- ifelse(
treated_now,
1 + 0.25 * (sim_panel$period - sim_panel$first_treat),
0
)
# Outcome: fixed individual effect, a trend shared by all units,
# the treatment effect and independent normal noise.
sim_panel$y &amp;lt;- rep(unit_effect, each = n_periods) +
0.5 * sim_panel$period +
sim_panel$true_effect +
rnorm(nrow(sim_panel))
head(sim_panel)
table(first_treat)
stopifnot(all(table(sim_panel$id) == n_periods))
&lt;/code>&lt;/pre>
&lt;p>Output:&lt;/p>
&lt;pre>&lt;code class="language-text">id period first_treat true_effect y
1 1 1 0 0 0.8292915
2 1 2 0 0 0.2361102
3 1 3 0 0 0.2348822
4 1 4 0 0 1.2642344
5 1 5 0 0 1.2470521
6 1 6 0 0 4.4757543
first_treat
0 3
990 1010
&lt;/code>&lt;/pre>
&lt;p>&lt;code>sim_panel&lt;/code> is one data frame with one row per unit and period, 12000 rows in total. The last line checks that every unit appears in all six periods.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Column&lt;/th>
&lt;th>Meaning&lt;/th>
&lt;th>Argument&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>y&lt;/code>&lt;/td>
&lt;td>outcome&lt;/td>
&lt;td>&lt;code>yname&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>period&lt;/code>&lt;/td>
&lt;td>date, 1 to 6&lt;/td>
&lt;td>&lt;code>tname&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>id&lt;/code>&lt;/td>
&lt;td>unit identifier&lt;/td>
&lt;td>&lt;code>idname&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>first_treat&lt;/code>&lt;/td>
&lt;td>first treatment period, 0 for units never treated&lt;/td>
&lt;td>&lt;code>gname&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>true_effect&lt;/code>&lt;/td>
&lt;td>simulated effect, kept only for checking&lt;/td>
&lt;td>not used&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The study population is the 2000 simulated units. Because every unit is observed at every date, the units in &lt;code>sim_panel&lt;/code> define it and no unit table (&lt;code>frame&lt;/code>) is needed.&lt;/p>
&lt;p>The simulated truth follows directly from the design. The effect is the same for every treated unit, so each average effect equals the effect in the formula.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Quantity&lt;/th>
&lt;th>Simulated truth&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Cohort 3, period 2 compared with period 1 (before treatment)&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>ATT(3,3)&lt;/td>
&lt;td>1.00&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>ATT(3,4)&lt;/td>
&lt;td>1.25&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>ATT(3,5)&lt;/td>
&lt;td>1.50&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>ATT(3,6)&lt;/td>
&lt;td>1.75&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Average over periods 3 to 6&lt;/td>
&lt;td>1.375&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="assumptions-for-this-example">Assumptions for this example&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Comparison group.&lt;/strong> Units never treated (&lt;code>control_group = &amp;quot;nevertreated&amp;quot;&lt;/code>).&lt;/li>
&lt;li>&lt;strong>No anticipation.&lt;/strong> Units do not react before period 3 (&lt;code>anticipation = 0&lt;/code>). The reference period of cohort 3 is therefore period 2.&lt;/li>
&lt;li>&lt;strong>Parallel trends from the reference period (PT-post).&lt;/strong> Without treatment, the average outcome of cohort 3 would have changed from period 2 to each later period by the same amount as the average outcome of the units never treated. The simulation satisfies this by construction, because the only trend is shared by all units.&lt;/li>
&lt;li>&lt;strong>No covariates and equal weights.&lt;/strong> Treatment does not depend on any characteristic, so no covariate adjustment is needed, and every unit has the same weight.&lt;/li>
&lt;li>&lt;strong>Overlap.&lt;/strong> Both groups contain many units.&lt;/li>
&lt;/ul>
&lt;p>The fixed individual effect differs across units, but it cancels from every change within a unit.&lt;/p>
&lt;h2 id="estimate-the-effects">Estimate the effects&lt;/h2>
&lt;pre>&lt;code class="language-r">set.seed(1)
fit &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;,
tname = &amp;quot;period&amp;quot;,
idname = &amp;quot;id&amp;quot;,
gname = &amp;quot;first_treat&amp;quot;,
data = sim_panel,
control_group = &amp;quot;nevertreated&amp;quot;,
est_method = &amp;quot;ipw&amp;quot;,
mode = &amp;quot;chained&amp;quot;,
pt_assumption = &amp;quot;post&amp;quot;
)
&lt;/code>&lt;/pre>
&lt;p>Calls are qualified with &lt;code>cdid::&lt;/code> so that loading &lt;code>did&lt;/code> later in the session cannot change which function runs. &lt;code>mode = &amp;quot;chained&amp;quot;&lt;/code> is already the default for panel data; it is written here so that the comparison with &lt;code>did&lt;/code> at the end of this article is easy to read. &lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code> selects treatment weighting (the package default is &lt;code>&amp;quot;dr&amp;quot;&lt;/code>). Without covariates, the treatment propensity model contains only an intercept. &lt;code>pt_assumption = &amp;quot;post&amp;quot;&lt;/code> is the default and is written for clarity.&lt;/p>
&lt;p>The inference settings keep their defaults: &lt;code>bstrap = TRUE&lt;/code>, &lt;code>cband = TRUE&lt;/code>, &lt;code>biters = 1000&lt;/code> and &lt;code>alp = 0.05&lt;/code>. The standard errors therefore come from 1000 multiplier bootstrap draws, and the band is a 95% simultaneous band over the reported cells. The draws use your session&amp;rsquo;s random number stream, so &lt;code>set.seed(1)&lt;/code> makes them reproducible.&lt;/p>
&lt;h3 id="settings-used">Settings used&lt;/h3>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Argument&lt;/th>
&lt;th>Value in this example&lt;/th>
&lt;th>Definition&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>yname&lt;/code>, &lt;code>tname&lt;/code>, &lt;code>idname&lt;/code>, &lt;code>gname&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;y&amp;quot;&lt;/code>, &lt;code>&amp;quot;period&amp;quot;&lt;/code>, &lt;code>&amp;quot;id&amp;quot;&lt;/code>, &lt;code>&amp;quot;first_treat&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#data-timing-and-comparison-group">Data, timing and comparison group&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>control_group&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;nevertreated&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#data-timing-and-comparison-group">Data, timing and comparison group&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>est_method&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;ipw&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#treatment-adjustment">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>mode&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;chained&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#chained-arguments">Chained arguments&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>pt_assumption&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;post&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#parallel-trends-and-reporting">Parallel trends and reporting&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>bstrap&lt;/code>, &lt;code>cband&lt;/code>, &lt;code>biters&lt;/code>, &lt;code>alp&lt;/code>&lt;/td>
&lt;td>defaults&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#inference-and-computation">Inference and computation&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The result records these choices: &lt;code>fit$DIDparams&lt;/code> holds the familiar &lt;code>did&lt;/code> settings (for example &lt;code>fit$DIDparams$est_method&lt;/code> and &lt;code>fit$DIDparams$control_group&lt;/code>), &lt;code>fit$chained$pt&lt;/code> holds the parallel trends choice and &lt;code>fit$chained$inference&lt;/code> describes the uncertainty calculation that was actually performed.&lt;/p>
&lt;h2 id="read-the-result">Read the result&lt;/h2>
&lt;pre>&lt;code class="language-r">summary(fit)
&lt;/code>&lt;/pre>
&lt;details>
&lt;summary>Console output&lt;/summary>
&lt;pre>&lt;code class="language-text">cdid chained difference-in-differences (chained IPW-GMM): cdid_MP
cdid 1.1.0.0 result built on did 2.5.1 (tested: did 2.5.1); did's MP methods tabulate the estimates below.
Chained estimators: Bellego C., Benatia D. and V. Dortet-Bernadet (2025). &amp;quot;The Chained Difference-in-Differences.&amp;quot; Journal of Econometrics 248, 105783. doi:10.1016/j.jeconom.2024.105783.
Ordinary estimators: Callaway B. and P. H. C. Sant'Anna (2021). &amp;quot;Difference-in-Differences with Multiple Time Periods.&amp;quot; Journal of Econometrics 225(2), 200-230. doi:10.1016/j.jeconom.2020.12.001.
Call:
cdid::att_gt(yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
data = sim_panel, control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;ipw&amp;quot;,
mode = &amp;quot;chained&amp;quot;, pt_assumption = &amp;quot;post&amp;quot;)
Group-Time Average Treatment Effects:
Group Time ATT(g,t) Std. Error [95% Simult. Conf. Band]
3 2 -0.0583 0.0644 -0.2217 0.1051
3 3 1.0096 0.0619 0.8527 1.1666 *
3 4 1.3274 0.0596 1.1763 1.4785 *
3 5 1.4837 0.0630 1.3239 1.6436 *
3 6 1.8478 0.0629 1.6882 2.0074 *
---
Signif. codes: `*' confidence band does not cover 0
P-value for pre-test of parallel trends assumption: 0.359889309273502
Control Group: Never Treated, Anticipation Periods: 0
Estimation Method: Inverse Probability Weighting
Chained support: 5 of 5 requested cells available.
Units: 2000 in the unit table, 2000 observed at all 6 dates, 2000 with at least two observed outcomes.
Observation correction: none (selection = &amp;quot;none&amp;quot;).
Parallel trends: PT-post; base_period = &amp;quot;varying&amp;quot;.
GMM weighting: optimal (two-step); covariance regularization: not applied (moment covariance well conditioned).
Inference: multiplier-bootstrap IQR standard errors (1000 draws), unit-level; simultaneous band over the available cells.
Parallel-trends pre-test: W = 0.838279, df = 1, p = 0.3599 (Wald test of the pretrend cell).
&lt;/code>&lt;/pre>
&lt;/details>
&lt;p>Typing &lt;code>fit&lt;/code> gives the same display as &lt;code>summary(fit)&lt;/code>. It has three parts.&lt;/p>
&lt;ol>
&lt;li>A heading line names the chained estimator.&lt;/li>
&lt;li>The &lt;code>did&lt;/code> summary follows: the call, the table of group time effects with standard errors and confidence limits, the p value of the pretrend test when that test is available, and the comparison group, anticipation and estimation method.&lt;/li>
&lt;li>A short chained record closes the display: how many requested cells are available and why any are unavailable; the units of the unit table, how many are observed at every date and how many have at least two observed outcomes; the correction for missing outcomes; the parallel trends assumption and &lt;code>base_period&lt;/code>; the GMM weighting and whether covariance regularization was applied; the inference actually performed; and the pretrend test, or the reason it is unavailable.&lt;/li>
&lt;/ol>
&lt;p>The heading gives the package versions and both paper references once, followed by the call and results. Detailed technical records remain accessible in the result, for example in &lt;code>fit$chained$references&lt;/code>, &lt;code>fit$chained$versions&lt;/code> and &lt;code>fit$chained$covariance_handling&lt;/code>.&lt;/p>
&lt;p>With the default &lt;code>base_period = &amp;quot;varying&amp;quot;&lt;/code>, the table for cohort 3 should contain one comparison before treatment (period 2 relative to period 1) and four effects after treatment (periods 3 to 6, each relative to period 2). When you run the code, compare the estimates with the simulated truth above. With 2000 units the estimates will not equal the truth exactly, and a 95% band can miss in a particular draw. Every requested cell should be reported as available, and the pretrend test should cover the single comparison before treatment. A test that does not reject is consistent with parallel trends but does not establish them.&lt;/p>
&lt;h3 id="tables-of-cells-and-fit-summary">Tables of cells and fit summary&lt;/h3>
&lt;pre>&lt;code class="language-r">cells &amp;lt;- cdid::tidy(fit)
cells[, c(&amp;quot;target.id&amp;quot;, &amp;quot;role&amp;quot;, &amp;quot;estimate&amp;quot;, &amp;quot;std.error&amp;quot;,
&amp;quot;conf.low&amp;quot;, &amp;quot;conf.high&amp;quot;, &amp;quot;available&amp;quot;)]
cdid::glance(fit)
&lt;/code>&lt;/pre>
&lt;p>Output:&lt;/p>
&lt;pre>&lt;code class="language-text">target.id role estimate std.error conf.low conf.high available
1 pre(g=3,t=2) pre -0.05831968 0.06442666 -0.2217344 0.1050951 TRUE
2 ATT(g=3,t=3) post 1.00962257 0.06188506 0.8526545 1.1665907 TRUE
3 ATT(g=3,t=4) post 1.32743963 0.05956931 1.1763453 1.4785340 TRUE
4 ATT(g=3,t=5) post 1.48374276 0.06300654 1.3239301 1.6435554 TRUE
5 ATT(g=3,t=6) post 1.84780436 0.06292532 1.6881977 2.0074110 TRUE
nobs ngroup ntime control.group est.method estimator n.requested n.available
1 2000 1 6 nevertreated ipw chained IPW-GMM 5 5
band.family inference clustered
1 simultaneous_multiplier_sup_t_over_supported_ids multiplier_bootstrap_iqr_se FALSE
&lt;/code>&lt;/pre>
&lt;p>&lt;code>tidy()&lt;/code> returns one row per reported cell. It retains &lt;code>did&lt;/code>&amp;rsquo;s columns, including &lt;code>estimate&lt;/code>, &lt;code>std.error&lt;/code> and the interval limits &lt;code>conf.low&lt;/code> and &lt;code>conf.high&lt;/code>, updates &lt;code>statistic&lt;/code> and &lt;code>p.value&lt;/code> from the chained inference record, and adds &lt;code>target.id&lt;/code>, &lt;code>role&lt;/code> (&lt;code>&amp;quot;pre&amp;quot;&lt;/code>, &lt;code>&amp;quot;post&amp;quot;&lt;/code> or &lt;code>&amp;quot;reference&amp;quot;&lt;/code>), &lt;code>available&lt;/code>, &lt;code>support.status&lt;/code>, &lt;code>support.reason&lt;/code>, &lt;code>certified&lt;/code> and &lt;code>band.family&lt;/code>. The p-values are pointwise even when the interval limits use a simultaneous critical value. &lt;code>glance()&lt;/code> returns one row that adds &lt;code>estimator&lt;/code>, &lt;code>n.requested&lt;/code>, &lt;code>n.available&lt;/code>, &lt;code>band.family&lt;/code>, &lt;code>inference&lt;/code> and &lt;code>clustered&lt;/code> to the columns of &lt;code>did&lt;/code>&amp;rsquo;s method. The &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#tables-from-tidy-and-glance">results reference&lt;/a> defines every added column.&lt;/p>
&lt;p>In the run described at the top of this article, all five requested cells were reported as available. This table compares them with the simulated truth, rounded to three decimals:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;code>target.id&lt;/code>&lt;/th>
&lt;th>Simulated truth&lt;/th>
&lt;th>&lt;code>estimate&lt;/code>&lt;/th>
&lt;th>Bootstrap &lt;code>std.error&lt;/code>&lt;/th>
&lt;th>95% simultaneous band (&lt;code>conf.low&lt;/code> to &lt;code>conf.high&lt;/code>)&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>pre(g=3,t=2)&lt;/code>&lt;/td>
&lt;td>0&lt;/td>
&lt;td>-0.058&lt;/td>
&lt;td>0.064&lt;/td>
&lt;td>-0.222 to 0.105&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>ATT(g=3,t=3)&lt;/code>&lt;/td>
&lt;td>1.00&lt;/td>
&lt;td>1.010&lt;/td>
&lt;td>0.062&lt;/td>
&lt;td>0.853 to 1.167&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>ATT(g=3,t=4)&lt;/code>&lt;/td>
&lt;td>1.25&lt;/td>
&lt;td>1.327&lt;/td>
&lt;td>0.060&lt;/td>
&lt;td>1.176 to 1.479&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>ATT(g=3,t=5)&lt;/code>&lt;/td>
&lt;td>1.50&lt;/td>
&lt;td>1.484&lt;/td>
&lt;td>0.063&lt;/td>
&lt;td>1.324 to 1.644&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>ATT(g=3,t=6)&lt;/code>&lt;/td>
&lt;td>1.75&lt;/td>
&lt;td>1.848&lt;/td>
&lt;td>0.063&lt;/td>
&lt;td>1.688 to 2.007&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The band uses one critical value for all five cells, so each of its intervals is wider than the pointwise interval in &lt;code>point.conf.low&lt;/code> and &lt;code>point.conf.high&lt;/code>. In this draw every band interval contains the simulated truth. That describes one draw; it is not evidence that the band attains its nominal 95% coverage.&lt;/p>
&lt;h2 id="aggregate-the-effects">Aggregate the effects&lt;/h2>
&lt;pre>&lt;code class="language-r">set.seed(2)
agg_simple &amp;lt;- cdid::aggte(fit, type = &amp;quot;simple&amp;quot;)
agg_group &amp;lt;- cdid::aggte(fit, type = &amp;quot;group&amp;quot;)
agg_dynamic &amp;lt;- cdid::aggte(fit, type = &amp;quot;dynamic&amp;quot;)
agg_calendar &amp;lt;- cdid::aggte(fit, type = &amp;quot;calendar&amp;quot;)
summary(agg_dynamic)
&lt;/code>&lt;/pre>
&lt;details>
&lt;summary>Console output&lt;/summary>
&lt;pre>&lt;code class="language-text">cdid chained difference-in-differences (chained IPW-GMM): cdid_AGGTEobj
cdid 1.1.0.0 result built on did 2.5.1 (tested: did 2.5.1); did's AGGTEobj methods tabulate the estimates below.
Chained estimators: Bellego C., Benatia D. and V. Dortet-Bernadet (2025). &amp;quot;The Chained Difference-in-Differences.&amp;quot; Journal of Econometrics 248, 105783. doi:10.1016/j.jeconom.2024.105783.
Ordinary estimators: Callaway B. and P. H. C. Sant'Anna (2021). &amp;quot;Difference-in-Differences with Multiple Time Periods.&amp;quot; Journal of Econometrics 225(2), 200-230. doi:10.1016/j.jeconom.2020.12.001.
Call:
cdid::aggte(fit, type = &amp;quot;dynamic&amp;quot;)
Overall summary of ATT's based on event-study/dynamic aggregation:
ATT Std. Error [ 95% Conf. Int.]
1.4172 0.0486 1.3218 1.5125 *
Dynamic Effects:
Event time Estimate Std. Error [95% Simult. Conf. Band]
-1 -0.0583 0.0586 -0.2026 0.0860
0 1.0096 0.0669 0.8450 1.1743 *
1 1.3274 0.0622 1.1744 1.4804 *
2 1.4837 0.0596 1.3371 1.6304 *
3 1.8478 0.0598 1.7005 1.9951 *
---
Signif. codes: `*' confidence band does not cover 0
Control Group: Never Treated, Anticipation Periods: 0
Estimation Method: Inverse Probability Weighting
Chained dynamic aggregation: 5 of 5 intended aggregate(s) available; na.rm = FALSE.
Overall summary: available over its 4 intended bins; pointwise interval.
Parallel trends: PT-post; base_period = &amp;quot;varying&amp;quot;.
Inference: multiplier-bootstrap IQR standard errors (1000 draws), unit-level; simultaneous band over the available estimates.
&lt;/code>&lt;/pre>
&lt;/details>
`aggte()` works from the stored chained result and does not refit the estimator. Its inference arguments default to `NULL`, which inherits `bstrap`, `cband`, `biters`, `alp` and `clustervars` from `fit`. The aggregates use new multiplier draws from the session's random number stream; setting the seed once before the four calls reproduces them when the calls run in the same order.
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Type&lt;/th>
&lt;th>Separate estimates&lt;/th>
&lt;th>Overall summary&lt;/th>
&lt;th>Simulated truth&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>&amp;quot;simple&amp;quot;&lt;/code>&lt;/td>
&lt;td>none&lt;/td>
&lt;td>average of all effects after treatment, weighted by cohort shares&lt;/td>
&lt;td>1.375&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;group&amp;quot;&lt;/code>&lt;/td>
&lt;td>one per cohort: the average of its effects after treatment&lt;/td>
&lt;td>average of the cohort estimates, weighted by cohort shares&lt;/td>
&lt;td>1.375 for cohort 3 and overall&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;dynamic&amp;quot;&lt;/code>&lt;/td>
&lt;td>one per event time &lt;code>e = t - g&lt;/code>, here from &lt;code>-1&lt;/code> to &lt;code>3&lt;/code>&lt;/td>
&lt;td>average of the estimates for event times 0 and later&lt;/td>
&lt;td>0 at &lt;code>e = -1&lt;/code>, then 1, 1.25, 1.5, 1.75; overall 1.375&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;calendar&amp;quot;&lt;/code>&lt;/td>
&lt;td>one per calendar period after treatment starts, here 3 to 6&lt;/td>
&lt;td>average of the calendar period estimates&lt;/td>
&lt;td>1, 1.25, 1.5, 1.75; overall 1.375&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>With a single treated cohort, the four overall summaries share the same truth. With several cohorts they answer different questions, as the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#four-aggregation-types">results reference&lt;/a> explains.&lt;/p>
&lt;p>The overall summary of each type is stored in &lt;code>overall.att&lt;/code> and &lt;code>overall.se&lt;/code>. This table collects them:&lt;/p>
&lt;pre>&lt;code class="language-r">aggregates &amp;lt;- list(
simple = agg_simple,
group = agg_group,
dynamic = agg_dynamic,
calendar = agg_calendar
)
overall &amp;lt;- data.frame(
type = names(aggregates),
estimate = vapply(aggregates, function(a) a$overall.att, numeric(1)),
std.error = vapply(aggregates, function(a) a$overall.se, numeric(1))
)
overall
agg_tables &amp;lt;- lapply(aggregates, cdid::tidy)
agg_tables$dynamic
cdid::glance(agg_dynamic)
&lt;/code>&lt;/pre>
&lt;details>
&lt;summary>Console output&lt;/summary>
&lt;pre>&lt;code class="language-text">type estimate std.error
simple simple 1.417152 0.04910689
group group 1.417152 0.05076659
dynamic dynamic 1.417152 0.04863678
calendar calendar 1.417152 0.05154004
type term event.time estimate std.error statistic p.value conf.low conf.high
1 dynamic ATT(-1) -1 -0.05831968 0.05862304 -0.9948252 3.198213e-01 -0.2026070 0.08596765
2 dynamic ATT(0) 0 1.00962257 0.06688741 15.0943593 1.763929e-51 0.8449944 1.17425077
3 dynamic ATT(1) 1 1.32743963 0.06216002 21.3552000 3.488752e-101 1.1744468 1.48043243
4 dynamic ATT(2) 2 1.48374276 0.05959328 24.8978196 7.855929e-137 1.3370674 1.63041813
5 dynamic ATT(3) 3 1.84780436 0.05983890 30.8796509 2.241017e-209 1.7005245 1.99508426
point.conf.low point.conf.high label available restricted n.intended n.used excluded.ids
1 -0.1732187 0.05657937 event_-1 TRUE FALSE 1 1
2 0.8785257 1.14071948 event_0 TRUE FALSE 1 1
3 1.2056082 1.44927103 event_1 TRUE FALSE 1 1
4 1.3669421 1.60054345 event_2 TRUE FALSE 1 1
5 1.7305223 1.96508645 event_3 TRUE FALSE 1 1
reason certified band.family
1 intended_target NA simultaneous_multiplier_sup_t_over_supported_ids
2 intended_target NA simultaneous_multiplier_sup_t_over_supported_ids
3 intended_target NA simultaneous_multiplier_sup_t_over_supported_ids
4 intended_target NA simultaneous_multiplier_sup_t_over_supported_ids
5 intended_target NA simultaneous_multiplier_sup_t_over_supported_ids
type nobs ngroup ntime control.group est.method estimator status na.rm n.bins
1 dynamic 2000 1 6 nevertreated ipw chained IPW-GMM available FALSE 5
n.bins.available overall.status band.family
1 5 available simultaneous_multiplier_sup_t_over_supported_ids
inference
1 multiplier_bootstrap_iqr_se
&lt;/code>&lt;/pre>
&lt;/details>
The tidy table of the group type begins with a row for the overall summary (with `label` equal to `"overall"`), followed by one row per cohort. The simple type has one row. The dynamic and calendar tables contain only their separate estimates, so the `overall` table above is the place to find their overall summaries.
&lt;h2 id="plot-the-effects">Plot the effects&lt;/h2>
&lt;pre>&lt;code class="language-r">p_cells &amp;lt;- cdid::ggdid(fit)
p_dynamic &amp;lt;- cdid::ggdid(agg_dynamic)
p_group &amp;lt;- cdid::ggdid(agg_group)
p_calendar &amp;lt;- cdid::ggdid(agg_calendar)
p_cells
p_dynamic
&lt;/code>&lt;/pre>
&lt;p>
&lt;figure >
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img src="https://www.davidbenatia.com/tools/cdid/assets/r/docs/outputs/get-started-cells.png" alt="Group-time effects and simultaneous bands" loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/p>
&lt;p>
&lt;figure >
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img src="https://www.davidbenatia.com/tools/cdid/assets/r/docs/outputs/get-started-dynamic.png" alt="Dynamic aggregation and simultaneous bands" loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/p>
&lt;p>&lt;code>ggdid()&lt;/code> uses &lt;code>did&lt;/code>&amp;rsquo;s plots and returns &lt;code>ggplot2&lt;/code> objects, which you can modify with the usual &lt;code>ggplot2&lt;/code> functions. The intervals use the same critical values as the tables. As in &lt;code>did&lt;/code>, the simple type has no plot. Each plot also carries a small table of the plotted points and their status, &lt;code>attr(p_cells, &amp;quot;cdid_presentation_grid&amp;quot;)&lt;/code> for the cell plot and &lt;code>attr(p_dynamic, &amp;quot;cdid_presentation_bins&amp;quot;)&lt;/code> for an aggregate plot, so you can see which points are available.&lt;/p>
&lt;h2 id="export-tables-plots-and-fitted-objects">Export tables, plots and fitted objects&lt;/h2>
&lt;pre>&lt;code class="language-r">out_dir &amp;lt;- file.path(tempdir(), &amp;quot;cdid_get_started&amp;quot;)
dir.create(out_dir, showWarnings = FALSE)
write.csv(cells, file.path(out_dir, &amp;quot;att_gt_cells.csv&amp;quot;), row.names = FALSE)
for (type in names(agg_tables)) {
write.csv(agg_tables[[type]],
file.path(out_dir, paste0(&amp;quot;aggte_&amp;quot;, type, &amp;quot;.csv&amp;quot;)),
row.names = FALSE)
}
write.csv(overall, file.path(out_dir, &amp;quot;overall_summaries.csv&amp;quot;), row.names = FALSE)
ggplot2::ggsave(file.path(out_dir, &amp;quot;event_study.pdf&amp;quot;), p_dynamic,
width = 7, height = 4)
saveRDS(fit, file.path(out_dir, &amp;quot;att_gt_fit.rds&amp;quot;))
saveRDS(agg_dynamic, file.path(out_dir, &amp;quot;aggte_dynamic.rds&amp;quot;))
&lt;/code>&lt;/pre>
&lt;p>The tidy tables are ordinary data frames, so &lt;code>write.csv()&lt;/code> exports them with unavailable values written as &lt;code>NA&lt;/code>. Saved result objects can be reloaded with &lt;code>readRDS()&lt;/code> in a session that uses the same package versions. A chained result does not contain the panel data, so keep the data and the code that produced the fit alongside it.&lt;/p>
&lt;h2 id="optional-compare-with-did">Optional: compare with did&lt;/h2>
&lt;p>The following call matches the chained fit except for &lt;code>mode&lt;/code>. &lt;code>pt_assumption&lt;/code> is left out because &lt;code>did&lt;/code> has no such argument; ordinary mode would ignore it in any case.&lt;/p>
&lt;pre>&lt;code class="language-r">fit_did &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;,
tname = &amp;quot;period&amp;quot;,
idname = &amp;quot;id&amp;quot;,
gname = &amp;quot;first_treat&amp;quot;,
data = sim_panel,
control_group = &amp;quot;nevertreated&amp;quot;,
est_method = &amp;quot;ipw&amp;quot;,
mode = &amp;quot;ordinary&amp;quot;
)
comparison &amp;lt;- merge(
data.frame(group = fit$group, time = fit$t, chained = fit$att),
data.frame(group = fit_did$group, time = fit_did$t, ordinary = fit_did$att),
by = c(&amp;quot;group&amp;quot;, &amp;quot;time&amp;quot;)
)
comparison$difference &amp;lt;- comparison$chained - comparison$ordinary
comparison
&lt;/code>&lt;/pre>
&lt;p>Output:&lt;/p>
&lt;pre>&lt;code class="language-text">group time chained ordinary difference
1 3 2 -0.05831968 -0.05831968 -5.995204e-15
2 3 3 1.00962257 1.00962257 -1.776357e-15
3 3 4 1.32743963 1.32743963 1.376677e-14
4 3 5 1.48374276 1.48374276 -5.018208e-14
5 3 6 1.84780436 1.84780436 5.107026e-15
&lt;/code>&lt;/pre>
&lt;p>Ordinary mode passes the call to &lt;code>did::att_gt()&lt;/code> and returns &lt;code>did&lt;/code>&amp;rsquo;s own result object.&lt;/p>
&lt;p>&lt;strong>What to expect.&lt;/strong> This design meets the conditions of a known algebraic reduction: a complete panel, units never treated as controls, no covariates, the same weight for each unit in every comparison, PT-post, and the same anticipation and &lt;code>base_period&lt;/code> in both calls. Under these conditions each chained comparison is the difference between the mean change of cohort 3 and the mean change of the units never treated between its two dates, and the changes over consecutive dates add up to the change over the whole span. The chained combination therefore reduces to the long comparisons that &lt;code>did&lt;/code> computes, and the &lt;code>difference&lt;/code> column is expected to be zero up to floating point rounding.&lt;/p>
&lt;p>That expectation comes from the algebra of this common case. In the run described at the top of this article, the largest absolute value in the &lt;code>difference&lt;/code> column over the five cells was 5.02e-14, consistent with floating point rounding. Standard errors and bands are a separate comparison, and this article makes no claim about them. Outside this reduction, differences require an actual difference in the fitted specification/procedure, the retained moment system or the analysis sample. Covariates alone, or the OR/DR label alone, are not an explanation. Fixed-horizon NYT reuse and the additional PT-all restrictions are distinct reasons, as the migration page explains. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/#when-chained-and-did-estimates-should-agree">Moving from did&lt;/a> explains each case.&lt;/p>
&lt;h2 id="next-steps">Next steps&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a> for the differences between the two modes.&lt;/li>
&lt;li>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a> for panels with missing outcomes.&lt;/li>
&lt;li>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results reference&lt;/a> for every field and the uncertainty rules.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 1 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;strong>Get started&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>Handling missing outcomes</title><link>https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/</guid><description>&lt;p>Results below were produced on October 29, 2026 with &lt;code>cdid&lt;/code> 1.1.0.0, &lt;code>did&lt;/code> 2.5.1 and &lt;code>DRDID&lt;/code> 1.3.0 under R 4.5.2, using the displayed seeds where applicable. These are individual examples; they do not establish repeated-sample coverage. OR/DR calls shown here explicitly retain the historical pooled specification; the current default uses separate comparison regressions.&lt;/p>
&lt;p>An observed outcome change is available only when the same unit is observed at both dates. Imputation and augmented correction also reconstruct changes on the full study population. The choices on this page decide what must be true for those observed changes to stand in for the study population, and which models adjust for differences between the units observed and the population. The arguments involved begin with &lt;code>selection&lt;/code>, together with &lt;code>imputation_pooling&lt;/code> and the unit table &lt;code>frame&lt;/code>.&lt;/p>
&lt;p>The choice is separate from treatment adjustment (&lt;code>est_method&lt;/code>, see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>). Every combination below keeps the same target: the average treatment effects of the original study population.&lt;/p>
&lt;h2 id="the-study-population-and-the-unit-table">The study population and the unit table&lt;/h2>
&lt;p>The study population is the set of units whose effects the analysis describes. The unit table, supplied as &lt;code>frame&lt;/code>, lists it: one row per study unit, matched to &lt;code>data&lt;/code> by &lt;code>idname&lt;/code>, including units observed once or never. Give it the same column names as &lt;code>data&lt;/code> for the identifier, the cohort and the covariates, and for the weights and cluster labels when you use them.&lt;/p>
&lt;p>Supply positive sampling weights and covariates wherever the chosen route reads them, and cluster labels for every study unit if inference is clustered. Static attributes may be supplied in the unit table; changing values belong in dated &lt;code>data&lt;/code> rows, with an explicit &lt;code>fix_weights&lt;/code> reference rule for changing weights. Do not place a conflicting static copy in &lt;code>frame&lt;/code>. Under &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code> every row also needs a known cohort. Where a setting allows an unknown cohort for a row present only in the unit table, aggregates that depend on cohort shares are reported as unavailable. Rows that appear only in the unit table keep their cohort, weight and cluster label, so they count in the cohort shares and in the standard errors. No row of the unit table is ever dropped.&lt;/p>
&lt;p>When you omit &lt;code>frame&lt;/code>, the units present in &lt;code>data&lt;/code> form the study population, including units with a single observed outcome. A unit with no row in &lt;code>data&lt;/code> is then outside the study population. If part of your population was never observed, supply it through &lt;code>frame&lt;/code>. The package reads a missing outcome at a date as nonresponse at that date, which is correct only if your data record every observation that exists.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Kind of unit&lt;/th>
&lt;th>What it contributes&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Observed at two or more dates&lt;/td>
&lt;td>changes for usable catalog pairs whose endpoints are observed, plus its cohort, required covariates and observation pattern&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Observed at one date&lt;/td>
&lt;td>no observed change; retained population information and every active model/rate influence remain in the calculation across all study units&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Present only in the unit table&lt;/td>
&lt;td>the same as a unit observed at one date&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>When inference is requested, the influence function retains every row of the unit table. The reported number of units &lt;code>n&lt;/code> counts them all. Inactive models are not fitted, and &lt;code>compute_inffunc = FALSE&lt;/code> returns no standard errors.&lt;/p>
&lt;h2 id="which-changes-are-available">Which changes are available&lt;/h2>
&lt;p>A change is available for a unit when the unit is observed at both of its dates, and the dates need not be adjacent. This table shows four observation groups over three periods:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Observation group&lt;/th>
&lt;th>Period 1&lt;/th>
&lt;th>Period 2&lt;/th>
&lt;th>Period 3&lt;/th>
&lt;th>Changes it supplies&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Complete observations&lt;/td>
&lt;td>observed&lt;/td>
&lt;td>observed&lt;/td>
&lt;td>observed&lt;/td>
&lt;td>1 to 2, 2 to 3, 1 to 3&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>First two dates&lt;/td>
&lt;td>observed&lt;/td>
&lt;td>observed&lt;/td>
&lt;td>missing&lt;/td>
&lt;td>1 to 2&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Last two dates&lt;/td>
&lt;td>missing&lt;/td>
&lt;td>observed&lt;/td>
&lt;td>observed&lt;/td>
&lt;td>2 to 3&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>A gap between dates&lt;/td>
&lt;td>observed&lt;/td>
&lt;td>missing&lt;/td>
&lt;td>observed&lt;/td>
&lt;td>1 to 3&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Under the assumptions below, the average change from period 1 to period 3 can be estimated directly from the units observed at periods 1 and 3, or by adding the estimated changes from 1 to 2 and from 2 to 3, each from its own observed units. Chained DiD combines the usable catalog comparisons by GMM, accounting for shared units and fitted nuisance parameters. Graph connectivity alone is insufficient: control support, valid observation reconstruction and cancellation of unrestricted trends also matter. A requested cell unsupported by the retained catalog is unavailable with a reason; model and numerical failures instead raise explicit errors.&lt;/p>
&lt;h2 id="the-assumption-about-missing-outcomes">The assumption about missing outcomes&lt;/h2>
&lt;p>&lt;code>selection&lt;/code> states the assumption.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;code>selection&lt;/code>&lt;/th>
&lt;th>Meaning&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>&amp;quot;none&amp;quot;&lt;/code> (default)&lt;/td>
&lt;td>No observation model. Within a cohort, the units observed in a given pair are assumed representative of that cohort with respect to the mean outcome change over that pair.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;conditional_mtar&amp;quot;&lt;/code>&lt;/td>
&lt;td>Conditional mean trends missing at random, with an explicit adjustment for observation that depends on covariates.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;corollary1&amp;quot;&lt;/code>&lt;/td>
&lt;td>Legacy name for &lt;code>&amp;quot;conditional_mtar&amp;quot;&lt;/code> with &lt;code>selection_model = &amp;quot;pair_logit&amp;quot;&lt;/code>.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="without-a-correction">Without a correction&lt;/h3>
&lt;p>With &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>, within a cohort the units observed in a given pair must be representative of that cohort with respect to the mean outcome change over that pair. The estimator scales the observed changes by the cohort&amp;rsquo;s response rate for the pair. The population restriction is&lt;/p>
&lt;pre>&lt;code class="language-text">E[ Y(t) - Y(s) | cohort, observed at s and t ] = E[ Y(t) - Y(s) | cohort ]
&lt;/code>&lt;/pre>
&lt;p>This is equality of population expectations, not a requirement that each unit have the same change or that realized sample means agree exactly. The distributions of changes may differ. Observation may depend on a unit fixed effect removed by differencing, provided that dependence does not select the mean change. If the fixed effect predicts trends or heterogeneous treatment effects, selecting on it can also select changes. Independence is sufficient for the displayed mean restriction but is stronger than required. No observation model is fitted, and a nondefault &lt;code>selection_model&lt;/code> is refused under this setting.&lt;/p>
&lt;h3 id="conditional-mean-trends-missing-at-random">Conditional mean trends missing at random&lt;/h3>
&lt;p>With &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, the package assumes that for every cohort, including the units never treated, and for every pair of dates (s, t) that the estimator actually uses, including the comparisons reported before treatment,&lt;/p>
&lt;pre>&lt;code>E[ Y(t) - Y(s) | X, cohort, observed at s and t ] = E[ Y(t) - Y(s) | X, cohort ]
&lt;/code>&lt;/pre>
&lt;p>and, for observation weighting and augmented correction, that the probability of observing both dates conditional on X and cohort is positive. Pure imputation instead needs observed training units and sufficient model/prediction support in each needed cell. The expectations refer to the study population described by the unit table and its weights.&lt;/p>
&lt;p>Several points follow from this statement.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Actual changes of treated units are covered.&lt;/strong> For a treated cohort, &lt;code>Y(t) - Y(s)&lt;/code> is the actual change, which includes the treatment effect. An assumption about untreated outcomes alone does not cover these changes.&lt;/li>
&lt;li>&lt;strong>Every pair actually used is covered.&lt;/strong> The restriction must hold for each date pair the estimator uses; holding it for adjacent dates alone is not enough.&lt;/li>
&lt;li>&lt;strong>Means, not distributions.&lt;/strong> Only the conditional mean change of observed units must equal that of the population; the full distributions may differ.&lt;/li>
&lt;li>&lt;strong>What observation may depend on.&lt;/strong> Observation may depend on covariates and a fixed unit component removed by differencing. Any further dependence is admissible only if the displayed conditional-mean equality remains valid; full conditional independence is a stronger sufficient condition.&lt;/li>
&lt;li>&lt;strong>The conditioning set needs justification.&lt;/strong> For the augmented sufficient conditions below, W includes the &lt;code>xformla&lt;/code> covariates and any variables only in &lt;code>selection_xformla&lt;/code>. Observation weighting likewise needs valid selection and treatment restrictions for the scientific conditioning variables; different predictor lists require separately sufficient restrictions. Supplying formulas does not establish their sufficiency.&lt;/li>
&lt;/ul>
&lt;p>These are population conditional expectations, not exact finite-sample equalities or restrictions on each unit&amp;rsquo;s change. Conditional representativeness still needs a scientifically sufficient conditioning set, the relevant models and positivity or prediction support for the selected adjustment. It is a substantive identification assumption. A well fitting observation model, balanced covariates or a plot of observed missingness cannot establish it. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/investigate-missingness/">Investigate missingness and data structure&lt;/a> separates useful observable checks from these untestable conditions.&lt;/p>
&lt;h2 id="how-to-adjust">How to adjust&lt;/h2>
&lt;p>With &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, &lt;code>selection_est_method&lt;/code> chooses the adjustment.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;code>selection_est_method&lt;/code>&lt;/th>
&lt;th>Name in this guide&lt;/th>
&lt;th>Models fitted for missing outcomes&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>&amp;quot;ipw&amp;quot;&lt;/code> (default)&lt;/td>
&lt;td>observation weighting&lt;/td>
&lt;td>probability of observing both dates&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;imputation&amp;quot;&lt;/code>&lt;/td>
&lt;td>change imputation&lt;/td>
&lt;td>the actual change of each cohort and date pair&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;dr&amp;quot;&lt;/code>&lt;/td>
&lt;td>augmented correction&lt;/td>
&lt;td>both; treatment IPW, OR or DR is chosen separately&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="observation-weighting">Observation weighting&lt;/h3>
&lt;p>Observation weighting weights each observed change by the inverse of its fitted probability of being observed at both dates, combined with the cohort&amp;rsquo;s repeat rate as the sampling adjustment. It is distinct from treatment weighting, which concerns membership in the cohort. &lt;code>selection_model&lt;/code> chooses the probability model:&lt;/p>
&lt;ul>
&lt;li>&lt;code>&amp;quot;pair_logit&amp;quot;&lt;/code> (default) models the probability of observing both dates directly: one logit per cohort and pair of dates for the event that both are observed. Because it models the pair as a whole, it allows observation at the two dates to be dependent, as with dropout.&lt;/li>
&lt;li>&lt;code>&amp;quot;independent_period_logit&amp;quot;&lt;/code> models observation at each date separately and multiplies the two date probabilities. This requires an additional assumption: given the cohort and the covariates, observation at one date must be independent of observation at the other. The assumption fails, for example, when units that leave the panel do not return. This model requires &lt;code>selection_universe = &amp;quot;F&amp;quot;&lt;/code>.&lt;/li>
&lt;/ul>
&lt;p>Both models are logits. A fit with separation, a boundary solution or deficient rank is refused. Since version 1.1.0.0, inverse observation denominators use the fixed &lt;code>1e-6&lt;/code> floor described under &lt;a href="#probability-safeguards">Probability safeguards&lt;/a>; no units or rows are trimmed.&lt;/p>
&lt;h3 id="change-imputation">Change imputation&lt;/h3>
&lt;p>Change imputation predicts actual changes and averages the predictions over the study population. For each cohort k and each date pair e that the estimator needs (for the effects and for both &lt;code>base_period&lt;/code> reporting families), a linear model of the actual change is fitted by weighted least squares to the units of cohort k observed at both dates, with their fixed weights:&lt;/p>
&lt;pre>&lt;code>j(k, e)(X) = alpha(k, e) + L(e) * z(X)' beta(r)
&lt;/code>&lt;/pre>
&lt;p>Here &lt;code>L(e)&lt;/code> is the number of steps between the two dates in the stored calendar, &lt;code>alpha(k, e)&lt;/code> is a local intercept for the cell when &lt;code>xformla&lt;/code> has an intercept, and the slope vector &lt;code>beta(r)&lt;/code> belongs to the pooling group r that &lt;code>imputation_pooling&lt;/code> defines. Each fitted model is then evaluated for every unit of cohort k in the unit table, including the units whose change was observed, and the average of these predictions replaces the observed mean. No observation probability is modeled, so &lt;code>selection_model&lt;/code>, &lt;code>selection_pooling&lt;/code> and &lt;code>selection_xformla&lt;/code> are inactive and never evaluated.&lt;/p>
&lt;p>Change imputation requires &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, &lt;code>selection_universe = &amp;quot;F&amp;quot;&lt;/code>, &lt;code>selection_rho = NULL&lt;/code>, known cohorts and complete &lt;code>xformla&lt;/code> covariates on every row of the unit table, and &lt;code>est_method&lt;/code> equal to &lt;code>&amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>&amp;quot;reg&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>. It also runs on complete panels, where an all-success observation logit with a free cell intercept has no finite interior root.&lt;/p>
&lt;p>This model is different from the counterfactual outcome regression of treatment OR. It predicts the actual change of each cohort, treatment effects included, while the counterfactual regression predicts untreated changes from controls.&lt;/p>
&lt;h3 id="augmented-correction">Augmented correction&lt;/h3>
&lt;p>The augmented correction combines both models in one estimator. For each needed cell c, a cohort and date pair, every unit of the cohort receives the reconstructed change&lt;/p>
&lt;pre>&lt;code>Z(c) = j(c)(X) + S(e) * { change(e) - j(c)(X) } / max(q(c)(W), 1e-6)
&lt;/code>&lt;/pre>
&lt;p>where &lt;code>j(c)&lt;/code> is the change imputation model, &lt;code>q(c)&lt;/code> is the fitted probability of observing both dates, &lt;code>S(e)&lt;/code> is 1 for units observed at both dates and 0 otherwise, and W contains the covariates of both formulas. In words, the package imputes each unit&amp;rsquo;s change and then adds back the prediction errors of the observed units, weighted by their inverse observation probabilities. The correction term is not renormalized; version 1.1.0.0 floors its inverse observation denominator at &lt;code>1e-6&lt;/code>. The result is a single estimator: in finite samples it generally differs from both the weighting and the imputation estimates, and it is not their average.&lt;/p>
&lt;p>It works with built-in &lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>&amp;quot;reg&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>. Treatment IPW fits the treatment propensity but no counterfactual regression; treatment OR fits the counterfactual regression but no treatment propensity; treatment DR fits both. Every choice also fits the observation model and the actual-change imputer. Custom functions remain unavailable. The declaration requirements of change imputation apply, and complete covariates of both formulas are needed on every row of the unit table.&lt;/p>
&lt;p>Each model must be estimable. An active pair cell, or endpoint-date cell for a date model, that is all observed or all unobserved cannot fit a logit with its own free intercept and is refused. Pooling slopes does not remove those cell intercepts. Pure imputation avoids that unused observation-logit obstruction but must still satisfy its own model/support checks. Failures of the imputation, treatment or counterfactual models are refused as well. Nothing falls back to change imputation or to observation weighting.&lt;/p>
&lt;h2 id="probability-safeguards">Probability safeguards&lt;/h2>
&lt;p>Version 1.1.0.0 caps package-owned treatment propensities at &lt;code>1 - 1e-6&lt;/code> and floors inverse observation denominators at &lt;code>1e-6&lt;/code>, without trimming units, rows or comparisons. For independent date logits the floor applies to the final pair product, not to each endpoint. Positive empirical pair-rate denominators use the same floor. Raw probabilities remain in likelihood scores and information matrices; influence functions differentiate the weights actually used. Rank, separation, convergence, boundary and support refusals still apply.&lt;/p>
&lt;p>When a safeguard binds with positive population probability, the clipped functional can differ from the original full-population ATT and can alter the usual robustness branches. The original-target consistency statements below require inactive clipping in population or additional conditions preserving the target; ordinary influence-function inference also needs negligible threshold-crossing remainder. Clipping does not establish identification or nominal coverage. See the probability-clipping section of &lt;code>?cdid::att_gt&lt;/code> for diagnostics and the exact cutoff convention.&lt;/p>
&lt;h2 id="which-models-must-be-correct">Which models must be correct&lt;/h2>
&lt;p>All three adjustments need conditional mean trends missing at random for every needed cell, parallel trends and no anticipation, and the condition of the treatment adjustment: a correct treatment propensity model for &lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code>, a correct counterfactual regression under the chosen &lt;code>outcome_pooling&lt;/code> for &lt;code>&amp;quot;reg&amp;quot;&lt;/code>, and either of the two for &lt;code>&amp;quot;dr&amp;quot;&lt;/code>. Observation weighting and augmented correction also require positive observation probabilities; pure imputation needs observed training mass and sufficient prediction support rather than a fitted probability model. In addition:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Adjustment&lt;/th>
&lt;th>What must also be correct&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Observation weighting&lt;/td>
&lt;td>the observation model for every needed cell; with &lt;code>&amp;quot;independent_period_logit&amp;quot;&lt;/code>, also the independence of the two dates given cohort and covariates&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Change imputation&lt;/td>
&lt;td>the linear mean of the actual change within each pooling group&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Augmented correction&lt;/td>
&lt;td>for each needed cell, either the imputation model or the observation model&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The augmented correction with treatment IPW needs a correct treatment propensity model; with treatment OR it needs a correct counterfactual regression. In either case, every needed cell also needs a correct observation model or a correct actual-change imputer. Augmentation protects the missing-outcome layer; it does not give treatment IPW or OR the treatment-DR guarantee.&lt;/p>
&lt;p>For the augmented correction combined with treatment DR, the sufficient condition is therefore: (treatment propensity model correct or counterfactual regression correct) and, for every needed cell, (observation model correct or imputation model correct). The correct alternative may differ from one cell to another. These are sufficient conditions for the primitive links with several qualifications. ATT/GMM recovery additionally needs valid moments for every used catalog link and the accepted identification and regularity conditions; incompatible link pseudo-targets can make the limit depend on the GMM weights.&lt;/p>
&lt;ul>
&lt;li>Shared coefficients in the chosen observation, imputation or outcome model, and the two endpoints of a date model, link cells together. An error elsewhere in a shared group can affect its other predictions.&lt;/li>
&lt;li>If variables that appear only in &lt;code>selection_xformla&lt;/code> shift the mean change, an imputation model built from &lt;code>xformla&lt;/code> cannot be correct on its own, and the observation model must be. Adding observation covariates is therefore not automatically harmless.&lt;/li>
&lt;li>When both reconstruction alternatives of a needed cell are wrong, or the chosen treatment adjustment lacks its required correct model, the estimate is generally biased.&lt;/li>
&lt;li>The results are large sample properties. There is no finite sample unbiasedness, and small fitted probabilities inflate the variance.&lt;/li>
&lt;/ul>
&lt;h2 id="pooling-how-much-the-models-share">Pooling: how much the models share&lt;/h2>
&lt;p>&lt;code>selection_pooling&lt;/code> applies to the observation models and &lt;code>imputation_pooling&lt;/code> to the change imputation models. Both take the same three values.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Value&lt;/th>
&lt;th>Observation models (&lt;code>selection_pooling&lt;/code>)&lt;/th>
&lt;th>Change imputation (&lt;code>imputation_pooling&lt;/code>)&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>&amp;quot;separate&amp;quot;&lt;/code> (default)&lt;/td>
&lt;td>separate slopes for each cell, a date pair or a date&lt;/td>
&lt;td>separate slopes for each cohort and date pair&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;within_cohort&amp;quot;&lt;/code>&lt;/td>
&lt;td>slopes shared within each cohort, across its pairs or dates&lt;/td>
&lt;td>slopes shared within each cohort, across its pairs&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;across_cohorts&amp;quot;&lt;/code>&lt;/td>
&lt;td>one slope vector shared by all cells&lt;/td>
&lt;td>one slope vector shared by all cells&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Intercepts&lt;/td>
&lt;td>separate for each cell when &lt;code>selection_xformla&lt;/code> has an intercept&lt;/td>
&lt;td>separate for each cohort and pair when &lt;code>xformla&lt;/code> has an intercept&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Shared slopes are an explicit model restriction that you choose. They can be wrong, for example when the changes of a treated cohort respond to covariates differently across date pairs. The package never pools automatically, and a pooling group whose design is rank deficient is refused. &lt;code>selection_pooling&lt;/code> changes only the observation models. &lt;code>imputation_pooling&lt;/code> controls actual-change imputation, and &lt;code>outcome_pooling&lt;/code> controls the counterfactual untreated-change regression used by treatment OR and DR. These three choices act independently, including under the augmented correction. The outcome choice has two values: &lt;code>&amp;quot;separate&amp;quot;&lt;/code> (default) for comparison-specific coefficients, or &lt;code>&amp;quot;pooled&amp;quot;&lt;/code> for shared per-step slopes and local intercepts. The &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/#outcome-regression-or">treatment adjustment guide&lt;/a> explains that choice.&lt;/p>
&lt;h2 id="two-covariate-formulas">Two covariate formulas&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;/th>
&lt;th>&lt;code>xformla&lt;/code>&lt;/th>
&lt;th>&lt;code>selection_xformla&lt;/code>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Used by&lt;/td>
&lt;td>the treatment logit, the counterfactual regression and change imputation&lt;/td>
&lt;td>the observation probability model only&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Default&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>, an intercept only&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>, which inherits &lt;code>xformla&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Under change imputation&lt;/td>
&lt;td>used&lt;/td>
&lt;td>inactive and never evaluated&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Under the augmented correction&lt;/td>
&lt;td>used&lt;/td>
&lt;td>defines the observation design; its additional variables never enter the outcome or treatment models&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Both are one sided formulas of covariates that are fixed within units or read at a reference date. Intercept only and no intercept forms are supported. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#handling-missing-outcomes">Options&lt;/a> lists the remaining details.&lt;/p>
&lt;h2 id="supported-combinations">Supported combinations&lt;/h2>
&lt;p>With &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, all nine built-in combinations of treatment adjustment and adjustment for missing outcomes are supported:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;code>est_method&lt;/code>&lt;/th>
&lt;th>Observation weighting&lt;/th>
&lt;th>Change imputation&lt;/th>
&lt;th>Augmented correction&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>&amp;quot;ipw&amp;quot;&lt;/code>&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;reg&amp;quot;&lt;/code>&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;dr&amp;quot;&lt;/code>&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;code>selection = &amp;quot;none&amp;quot;&lt;/code> works with all three methods and with a custom IPW function. A custom function also works with observation weighting when it returns &lt;code>log_weight_gradient&lt;/code>; it is refused with change imputation and the augmented correction.&lt;/p>
&lt;h2 id="advanced-fitting-the-observation-model-on-part-of-the-unit-table">Advanced: fitting the observation model on part of the unit table&lt;/h2>
&lt;p>By default the observation model is fitted on the whole unit table (&lt;code>selection_universe = &amp;quot;F&amp;quot;&lt;/code>). For observation weighting with &lt;code>selection_model = &amp;quot;pair_logit&amp;quot;&lt;/code>, it can instead be fitted on the units observed at least once (&lt;code>&amp;quot;B&amp;quot;&lt;/code>) or at least twice (&lt;code>&amp;quot;A&amp;quot;&lt;/code>). These counts describe outcome observations only; they do not define structural observation windows. The study population and the standard errors still use the whole unit table.&lt;/p>
&lt;p>Fitting on a subset requires a stated justification in &lt;code>selection_justification&lt;/code>. With &lt;code>selection_rho = NULL&lt;/code>, the justification asserts that, within each cohort, the fitting subset has the same covariate distribution as the cohort&amp;rsquo;s study population. Otherwise &lt;code>selection_rho&lt;/code> names a column of fixed, known, positive, normalized density ratios &lt;code>rho = f(X | G, U) / f(X | G)&lt;/code> under the declared weighted population law, with the fitting-subset density in the numerator; the package neither estimates nor renormalizes it. The package records the justification, and no fit diagnostic can confirm it. A correct logit on the whole unit table does not imply a correct logit on a subset; the two are different modeling assumptions with no ranking of efficiency. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a> explains these fitting sets and known transport declarations.&lt;/p>
&lt;h2 id="example-observation-that-depends-on-a-covariate">Example: observation that depends on a covariate&lt;/h2>
&lt;p>In this simulated design, a fixed covariate &lt;code>x&lt;/code> shifts the untreated trend and the treatment effect, and outcomes with larger &lt;code>x&lt;/code> are observed more often. Observation at each date is independent of observation at the other dates given &lt;code>x&lt;/code>.&lt;/p>
&lt;pre>&lt;code class="language-r">set.seed(20261026)
n_units &amp;lt;- 2000
n_periods &amp;lt;- 6
x &amp;lt;- rnorm(n_units)
first_treat &amp;lt;- sample(c(0, 3), size = n_units, replace = TRUE)
unit_effect &amp;lt;- rnorm(n_units)
full_panel &amp;lt;- data.frame(
id = rep(seq_len(n_units), each = n_periods),
period = rep(seq_len(n_periods), times = n_units),
first_treat = rep(first_treat, each = n_periods),
x = rep(x, each = n_periods)
)
treated_now &amp;lt;- full_panel$first_treat &amp;gt; 0 &amp;amp;
full_panel$period &amp;gt;= full_panel$first_treat
# The effect is larger for units with larger x.
effect &amp;lt;- ifelse(
treated_now,
1 + 0.25 * (full_panel$period - full_panel$first_treat) + 0.5 * full_panel$x,
0
)
full_panel$y &amp;lt;- rep(unit_effect, each = n_periods) +
(0.5 + 0.3 * full_panel$x) * full_panel$period +
effect +
rnorm(nrow(full_panel))
# Each outcome is observed independently across dates given x,
# more often for larger x.
observed &amp;lt;- runif(nrow(full_panel)) &amp;lt; plogis(1.5 + full_panel$x)
obs_panel &amp;lt;- full_panel[observed, ]
# Unit table: every study unit, including units observed once or never.
units &amp;lt;- data.frame(id = seq_len(n_units), first_treat = first_treat, x = x)
# Number of units by number of observed outcomes (0 to 6).
table(table(factor(obs_panel$id, levels = units$id)))
&lt;/code>&lt;/pre>
&lt;p>Output:&lt;/p>
&lt;pre>&lt;code class="language-text">0 1 2 3 4 5 6
13 56 109 213 393 540 676
&lt;/code>&lt;/pre>
&lt;p>The four fits below hold the data, the unit table, the covariate formula and the treatment adjustment (&lt;code>est_method = &amp;quot;dr&amp;quot;&lt;/code>) fixed and change only the handling of missing outcomes.&lt;/p>
&lt;pre>&lt;code class="language-r">fit_none &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
xformla = ~ x, data = obs_panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
selection = &amp;quot;none&amp;quot;,
bstrap = FALSE, cband = FALSE
)
fit_weighting &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
xformla = ~ x, data = obs_panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
selection = &amp;quot;conditional_mtar&amp;quot;,
selection_est_method = &amp;quot;ipw&amp;quot;,
selection_model = &amp;quot;independent_period_logit&amp;quot;,
selection_pooling = &amp;quot;separate&amp;quot;,
bstrap = FALSE, cband = FALSE
)
fit_imputation &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
xformla = ~ x, data = obs_panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
selection = &amp;quot;conditional_mtar&amp;quot;,
selection_est_method = &amp;quot;imputation&amp;quot;,
imputation_pooling = &amp;quot;separate&amp;quot;,
bstrap = FALSE, cband = FALSE
)
fit_augmented &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
xformla = ~ x, data = obs_panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
selection = &amp;quot;conditional_mtar&amp;quot;,
selection_est_method = &amp;quot;dr&amp;quot;,
selection_model = &amp;quot;independent_period_logit&amp;quot;,
selection_pooling = &amp;quot;separate&amp;quot;,
imputation_pooling = &amp;quot;separate&amp;quot;,
bstrap = FALSE, cband = FALSE
)
fits &amp;lt;- list(none = fit_none, weighting = fit_weighting,
imputation = fit_imputation, augmented = fit_augmented)
simple &amp;lt;- lapply(fits, cdid::aggte, type = &amp;quot;simple&amp;quot;)
data.frame(
handling = names(simple),
estimate = vapply(simple, function(a) a$overall.att, numeric(1)),
std.error = vapply(simple, function(a) a$overall.se, numeric(1))
)
# Value of the simple aggregate for these 2000 simulated units.
1.375 + 0.5 * mean(units$x[units$first_treat == 3])
fit_augmented$chained$selection[c(&amp;quot;method&amp;quot;, &amp;quot;selection_model&amp;quot;, &amp;quot;selection_pooling&amp;quot;,
&amp;quot;imputation_pooling&amp;quot;, &amp;quot;selection_formula_inherited&amp;quot;)]
&lt;/code>&lt;/pre>
&lt;p>Output:&lt;/p>
&lt;pre>&lt;code class="language-text">handling estimate std.error
none none 1.545866 0.06311893
weighting weighting 1.272803 0.06791702
imputation imputation 1.314577 0.06505744
augmented augmented 1.271517 0.06743981
[1] 1.344878
$method
[1] &amp;quot;augmented&amp;quot;
$selection_model
[1] &amp;quot;independent_period_logit&amp;quot;
$selection_pooling
[1] &amp;quot;separate&amp;quot;
$imputation_pooling
[1] &amp;quot;separate&amp;quot;
$selection_formula_inherited
[1] TRUE
&lt;/code>&lt;/pre>
&lt;p>&lt;strong>What the design implies.&lt;/strong> In the population, the simple aggregate equals 1.375, because &lt;code>x&lt;/code> has mean zero in cohort 3; the last calculation gives its value for these 2000 units. Both treatment models are correct here, since treatment is assigned at random and untreated changes are linear in &lt;code>L(e) * x&lt;/code>. The four fits differ only in their handling of missing outcomes.&lt;/p>
&lt;ul>
&lt;li>&lt;code>fit_none&lt;/code>: the assumption of &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code> fails, because observation depends on &lt;code>x&lt;/code>, which also shifts the treated changes. Its estimates are generally biased for the population effects.&lt;/li>
&lt;li>&lt;code>fit_weighting&lt;/code>: the date model is correctly specified, because each date&amp;rsquo;s observation is a logit in &lt;code>x&lt;/code> and dates are independent given &lt;code>x&lt;/code>. A pair logit linear in &lt;code>x&lt;/code> is generally misspecified here: the product of the two date logits is generally not itself logit-linear in &lt;code>x&lt;/code>.&lt;/li>
&lt;li>&lt;code>fit_imputation&lt;/code>: with &lt;code>&amp;quot;separate&amp;quot;&lt;/code>, each cohort and pair has its own slope, which this design needs: for cohort 3, the change over a pair that spans the start of treatment depends on &lt;code>x&lt;/code> differently from other pairs. Slopes shared within the cohort, &lt;code>&amp;quot;within_cohort&amp;quot;&lt;/code> or &lt;code>&amp;quot;across_cohorts&amp;quot;&lt;/code>, would be misspecified.&lt;/li>
&lt;li>&lt;code>fit_augmented&lt;/code>: both alternatives are correct in every cell.&lt;/li>
&lt;/ul>
&lt;p>The last three fits are therefore expected to target the effects, with different finite sample estimates and standard errors.&lt;/p>
&lt;h2 id="where-the-result-records-the-choice">Where the result records the choice&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Location&lt;/th>
&lt;th>Contents&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>fit$chained$selection&lt;/code>&lt;/td>
&lt;td>the adjustment: &lt;code>method&lt;/code> is &lt;code>&amp;quot;none&amp;quot;&lt;/code>, &lt;code>&amp;quot;corollary1&amp;quot;&lt;/code> for observation weighting (its legacy record name, with &lt;code>canonical_assumption = &amp;quot;conditional_mtar&amp;quot;&lt;/code>), &lt;code>&amp;quot;imputation&amp;quot;&lt;/code> or &lt;code>&amp;quot;augmented&amp;quot;&lt;/code>; for the corrections, also the observation model, the pooling choices, the fitting set, the transport, the justification, the assumptions and counts of fitted models; for the augmented correction, &lt;code>selection_formula_inherited&lt;/code> reports whether &lt;code>selection_xformla&lt;/code> was inherited&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>fit$chained$nuisance_diagnostics&lt;/code>&lt;/td>
&lt;td>the fitted cells, the pooling groups with their ranks, slopes and removed columns, the observation probability blocks (&lt;code>records$selection$blocks&lt;/code> for the augmented correction), the counterfactual regression, the treatment logits and the support of each cell&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>fit$chained$outcome_design&lt;/code>&lt;/td>
&lt;td>the outcome design, and for the augmented correction both designs&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>summary(fit)&lt;/code>&lt;/td>
&lt;td>an &lt;code>Observation correction&lt;/code> line naming the adjustment and its model and pooling choices&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 9 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;strong>Handling missing outcomes&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>How to compare precision</title><link>https://www.davidbenatia.com/tools/cdid/guide/examples/precision/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/examples/precision/</guid><description>&lt;p>A smaller standard error does not by itself establish a better estimator. Before comparing chained and ordinary mode, control groups, parallel trends choices or corrections for missing outcomes, match the target population and parameter, then state the assumptions that justify each fit. Balance alone decides neither validity nor a precision ranking. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/#why-can-balanced-results-differ-and-which-should-i-use">Moving from did&lt;/a> explains how to choose between the two estimation modes.&lt;/p>
&lt;p>This page explains covariance and the package&amp;rsquo;s precision diagnostics. It reports no simulation results, executed examples or timing measurements. Executed walkthroughs elsewhere in this guide show individual fits; they are not repeated-sample precision comparisons.&lt;/p>
&lt;h2 id="more-comparisons-do-not-mean-independent-information">More comparisons do not mean independent information&lt;/h2>
&lt;p>Chained estimation combines two-date comparisons. If a vector of link estimates has covariance matrix $\Sigma$ and its coefficients $a$ are fixed, the variance of the linear combination is $a'\Sigma a$. The off-diagonal covariances matter as much as the individual link variances. This is an exact identity for fixed coefficients. Feasible GMM estimates its weights from the same data: inserting fitted, data-dependent coefficients does not give an exact unconditional finite-sample variance identity. Under the appropriate GMM regularity conditions, a first-order calculation uses the limiting combination and complete influence functions. The package&amp;rsquo;s inference follows its complete influence functions, rather than treating fitted weights as an exact finite-sample variance formula.&lt;/p>
&lt;p>For the same unit, consecutive changes telescope:&lt;/p>
&lt;p>$$
(Y_{i,4}-Y_{i,3})+(Y_{i,3}-Y_{i,2})=Y_{i,4}-Y_{i,2}.
$$&lt;/p>
&lt;p>The shared intermediate outcome cancels. If time-specific measurement errors are mutually independent, their contribution to the covariance of these adjacent changes is minus the variance of the shared error. The total covariance need not be negative: serial dependence, heterogeneous trends and other shared components also matter. With different observed units or weights at each link, estimated link averages need not telescope.&lt;/p>
&lt;p>In the balanced common reduction case, chained cell estimates agree with &lt;code>did&lt;/code> up to rounding: built-in IPW, no covariates, no correction for missing outcomes, never treated controls, weights fixed across comparisons, PT-post, and matching anticipation and reporting settings. Splitting the same units' long changes into consecutive steps adds comparison rows without independent information. This point-estimate reduction does not establish agreement of every standard error, band or aggregate. See &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/#when-chained-and-did-estimates-should-agree">the precise comparison&lt;/a>.&lt;/p>
&lt;h2 id="what-gmm-weighting-and-standard-errors-measure">What GMM weighting and standard errors measure&lt;/h2>
&lt;p>Overlapping comparison paths can make the moment covariance singular even when an ATT is supported. Lack of support is a different issue: if the available comparisons and trend restrictions cannot recover a cell, weighting cannot make it available. Read &lt;code>fit$chained$support_status&lt;/code> and &lt;code>support_reason&lt;/code>, or the corresponding columns of &lt;code>cdid::tidy(fit)&lt;/code>.&lt;/p>
&lt;p>With &lt;code>gmm_weighting = &amp;quot;optimal&amp;quot;&lt;/code>, feasible two-step GMM uses an estimated moment covariance. The package removes proven exact redundancies before checking that covariance. The selected &lt;code>gmm_covariance = &amp;quot;tikhonov&amp;quot;&lt;/code> handler adds a trace-proportional ridge when the reduced covariance needs regularization; exactly zero covariance has a separate least-squares rule. Regularization affects weighting, supplies no identifying information and guarantees no finite-sample precision improvement. &lt;code>fit$chained$covariance_handling&lt;/code> records what happened; the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#gmm-weighting-and-covariance-regularization">options reference&lt;/a> gives the rules.&lt;/p>
&lt;p>The inverse weighting matrix is not the reported estimator covariance. With influence functions computed:&lt;/p>
&lt;ul>
&lt;li>&lt;code>fit$inffunc&lt;/code> has one row per unit in the unit table, including units without an observed change, and one column per reported cell.&lt;/li>
&lt;li>&lt;code>fit$V_analytical&lt;/code> estimates the covariance of &lt;code>sqrt(n) * (estimate - target)&lt;/code>: it is &lt;strong>n times&lt;/strong> the estimated covariance of the cell estimates. Analytical standard errors are &lt;code>sqrt(diag(fit$V_analytical) / fit$n)&lt;/code>, also recorded in &lt;code>fit$chained$analytical_se&lt;/code>.&lt;/li>
&lt;li>&lt;code>fit$se&lt;/code> and &lt;code>std.error&lt;/code> in &lt;code>cdid::tidy(fit)&lt;/code> use analytical or multiplier standard errors according to the inference actually performed. They need not equal the analytical values when &lt;code>bstrap = TRUE&lt;/code>.&lt;/li>
&lt;/ul>
&lt;p>The complete influence functions account for fitted nuisances and, in aggregation, estimated cohort shares. Clustering sums their rows within clusters for inference; it does not change the unit-based GMM weights or point estimates. Read the effective flags and draws in &lt;code>fit$chained$inference&lt;/code>, and compare matching pointwise intervals or matching simultaneous families. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a> and the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#uncertainty">results reference&lt;/a> explain the endpoints and &lt;code>cdid::aggte()&lt;/code> outputs.&lt;/p>
&lt;h2 id="incomplete-panels-match-the-population-and-sampling-conditions">Incomplete panels: match the population and sampling conditions&lt;/h2>
&lt;p>Complete-case analysis, repeated cross sections and chained changes each have settings where they are valid. Their standard errors answer a common precision question only when their targets and assumptions align.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Approach&lt;/th>
&lt;th>What to check before comparing precision&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Complete-case balancing&lt;/td>
&lt;td>It uses units observed at every date. Their ATT can differ from the full population ATT when observation relates to heterogeneous effects. The targets can coincide under suitable representativeness conditions; a rotating panel may contain no complete cases.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Outcome-level RCS comparisons&lt;/td>
&lt;td>Each date&amp;rsquo;s sample must satisfy the level-sampling conditions. Changing composition in an unobserved fixed component can invalidate that comparison even when observed within-unit changes remain representative. Fixed differences alone do not invalidate representative RCS sampling.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Chained changes&lt;/td>
&lt;td>The observed or reconstructed pair changes must represent the declared population under the chosen assumptions. Overlapping pairs can identify effects without any complete unit; scarce bridges can still make estimates imprecise.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>In &lt;code>did&lt;/code> 2.5.1, a genuinely unbalanced &lt;code>panel = TRUE, allow_unbalanced_panel = TRUE&lt;/code> call uses RCS estimation routines internally while retaining its distinction from true repeated cross sections through unit identities. Ordinary mode forwards this behavior. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/#incomplete-panels-in-did-and-in-chained-mode">Moving from did&lt;/a> describes the routes, and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a> states the chained conditions.&lt;/p>
&lt;h2 id="restrictions-can-change-information-and-robustness">Restrictions can change information and robustness&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Choice&lt;/th>
&lt;th>What can change, holding the population target fixed&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Never treated versus not yet treated controls&lt;/td>
&lt;td>Under full NYT parallel trends and overlap, the chained catalog can retain additional fixed-horizon control-pool moments for the same pair. Joint GMM can change estimates and uncertainty even with complete outcomes. More valid moments do not establish a universal finite-sample gain.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>PT-post versus PT-all&lt;/td>
&lt;td>Credible extra untreated-trend restrictions from the chosen &lt;code>pt_start&lt;/code> can add identification or precision. False restrictions can bias estimates; neither bias nor a gain follows from the option label alone. PT-all may add no restriction in a particular calendar. &lt;code>base_period&lt;/code> separately controls preperiod reporting.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Treatment OR or DR&lt;/td>
&lt;td>A shared counterfactual change slope is a restriction across comparison blocks. Credible pooling can share information; unjustified pooling can invalidate the OR branch. DR retains its treatment-propensity correctness alternative under the other required conditions.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Observation or imputation pooling&lt;/td>
&lt;td>&lt;code>selection_pooling&lt;/code> shares coefficients of observation-probability models; &lt;code>imputation_pooling&lt;/code> shares regressions of actual cohort changes, including treatment effects. Neither argument controls the shared counterfactual slope of treatment OR/DR. Their distinct restrictions require justification.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Small pair probabilities can amplify observation weights; rare links and weak covariate support can worsen uncertainty. Neither a large unit table nor a short chain alone determines precision. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a> separates the model-correctness alternatives, and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a> explains which restrictions are active.&lt;/p>
&lt;h2 id="read-a-fit-before-making-a-ranking">Read a fit before making a ranking&lt;/h2>
&lt;p>Use &lt;code>fit$n&lt;/code>, &lt;code>fit$chained$frame&lt;/code>, &lt;code>fit$group&lt;/code> and &lt;code>fit$t&lt;/code> to check the population and cells. Inspect availability through &lt;code>cdid::tidy(fit)&lt;/code> and &lt;code>n.requested&lt;/code>/&lt;code>n.available&lt;/code> in &lt;code>cdid::glance(fit)&lt;/code>. Compare &lt;code>DIDparams&lt;/code>, &lt;code>fit$chained$pt&lt;/code>, &lt;code>selection&lt;/code>, &lt;code>covariance_handling&lt;/code> and &lt;code>inference&lt;/code> for the restrictions and uncertainty actually used. An unavailable effect has no precision ranking.&lt;/p>
&lt;p>A single fit&amp;rsquo;s estimated standard error differs from the empirical standard deviation across repeated samples. Bias, RMSE and interval coverage additionally compare estimates with the population truth. A fair repeated-sample evaluation pairs the same inputs and observation masks, matches interval families, retains failed and unavailable attempts, and reports denominators and Monte Carlo uncertainty. A result in one setting cannot establish a universal ranking.&lt;/p>
&lt;p>Resource diagnostics are separate. The admitted workspace is recorded in &lt;code>fit$chained$public$profile$numeric_workspace_bytes&lt;/code>, in bytes. &lt;code>fit$chained$public$counted_work_limit&lt;/code> is an optional cap on conservative counted-work estimates, default &lt;code>Inf&lt;/code>; these work units are not memory bytes or measured seconds. Neither is a process-RSS, CPU-time or whole-call resource guarantee. Measured runtime and memory require measurements, with timeouts reported as censored attempts.&lt;/p>
&lt;p>The &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md#roadmap" target="_blank" rel="noopener">roadmap&lt;/a> states the planned efficiency direction.&lt;/p>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 5 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;strong>How to compare precision&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>Identify effects when the observed units change composition</title><link>https://www.davidbenatia.com/tools/cdid/guide/examples/identification/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/examples/identification/</guid><description>&lt;p>Results below were produced on October 29, 2026 with &lt;code>cdid&lt;/code> 1.1.0.0, &lt;code>did&lt;/code> 2.5.1 and &lt;code>DRDID&lt;/code> 1.3.0 under R 4.5.2, using the displayed seeds where applicable. These are individual examples; they do not establish repeated-sample coverage.&lt;/p>
&lt;p>This example builds a small rotating panel in which the treated units observed at each date have a different mix of a fixed, unobserved unit component. Outcome changes within the same unit still identify the treatment effects, while comparisons of mean outcome levels across dates do not. The reasoning is the argument about mean pair changes in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/#telescoping-consecutive-windows-in-layout-2">Estimate treatment effects from incomplete panels&lt;/a>, applied to one concrete design. The example introduces no new estimator, option or assumption.&lt;/p>
&lt;h2 id="question">Question&lt;/h2>
&lt;p>A study follows units over five dates. Units in cohort 3 are first treated at date 3, and the others are never treated. Each unit is observed at exactly two consecutive dates. Among treated units, those with a high fixed component tend to be observed early and those with a low one late. Write ATT(3,t) for the average treatment effect of cohort 3 at date t. Can the changes observed within units identify ATT(3,3), ATT(3,4) and ATT(3,5) when the observed treated units differ in composition from date to date?&lt;/p>
&lt;h2 id="the-design">The design&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Cohort.&lt;/strong> $G$ is 0 or 3, each with probability 1/2.&lt;/li>
&lt;li>&lt;strong>Fixed component.&lt;/strong> $\alpha$ is $-1$ or $+1$, each with probability 1/2, independently of $G$. The estimators never see $\alpha$, and no covariate is supplied.&lt;/li>
&lt;li>&lt;strong>Untreated outcomes.&lt;/strong> $Y_t(0) = \alpha + 0.1,t + \varepsilon_t$. The $\varepsilon_t$ have mean zero, are independent across dates and are independent of $G$, $\alpha$ and observation.&lt;/li>
&lt;li>&lt;strong>Effect.&lt;/strong> Let $\tau_t = 1$ when $G = 3$ and $t \ge 3$, and $\tau_t = 0$ otherwise. The actual outcome is $Y_t = Y_t(0) + \tau_t$, so every treated unit gains exactly 1 from date 3 onward and nothing earlier. ATT(3,3), ATT(3,4) and ATT(3,5) all equal 1, for the simulated units and for the population the design describes.&lt;/li>
&lt;li>&lt;strong>Observation.&lt;/strong> Each unit is observed in one window $W$ of two consecutive dates, (1,2), (2,3), (3,4) or (4,5), drawn given $G$ and $\alpha$ with the probabilities in Table 1.&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Table 1. Window probabilities given cohort and fixed component (population algebra)&lt;/strong>&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Units&lt;/th>
&lt;th>Share of units&lt;/th>
&lt;th>(1,2)&lt;/th>
&lt;th>(2,3)&lt;/th>
&lt;th>(3,4)&lt;/th>
&lt;th>(4,5)&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>$G = 0$, either value of $\alpha$&lt;/td>
&lt;td>1/2&lt;/td>
&lt;td>0.25&lt;/td>
&lt;td>0.25&lt;/td>
&lt;td>0.25&lt;/td>
&lt;td>0.25&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>$G = 3$, $\alpha = +1$&lt;/td>
&lt;td>1/4&lt;/td>
&lt;td>0.40&lt;/td>
&lt;td>0.30&lt;/td>
&lt;td>0.20&lt;/td>
&lt;td>0.10&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>$G = 3$, $\alpha = -1$&lt;/td>
&lt;td>1/4&lt;/td>
&lt;td>0.10&lt;/td>
&lt;td>0.20&lt;/td>
&lt;td>0.30&lt;/td>
&lt;td>0.40&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>$G = 3$, both values together&lt;/td>
&lt;td>1/2&lt;/td>
&lt;td>0.25&lt;/td>
&lt;td>0.25&lt;/td>
&lt;td>0.25&lt;/td>
&lt;td>0.25&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Each window contains treated and never treated units with both values of $\alpha$ with positive probability, and each window holds a quarter of each cohort. No unit is observed at all five dates: every unit has exactly two observed outcomes.&lt;/p>
&lt;p>Let $R_t = 1$ when date $t$ lies in the unit&amp;rsquo;s window. Write $p_t^{+}$ and $p_t^{-}$ for the probability that $R_t = 1$ in cohort 3 when $\alpha = +1$ and when $\alpha = -1$; each is the sum of the probabilities of the windows that contain $t$. Because the two values of $\alpha$ have equal mass in cohort 3,&lt;/p>
&lt;p>$$m_t = E[\alpha \mid G = 3, R_t = 1] = \frac{p_t^{+} - p_t^{-}}{p_t^{+} + p_t^{-}}.$$&lt;/p>
&lt;p>&lt;strong>Table 2. Observation and the mean fixed component by date (population algebra)&lt;/strong>&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Quantity&lt;/th>
&lt;th>$t = 1$&lt;/th>
&lt;th>$t = 2$&lt;/th>
&lt;th>$t = 3$&lt;/th>
&lt;th>$t = 4$&lt;/th>
&lt;th>$t = 5$&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>$p_t^{+}$&lt;/td>
&lt;td>0.4&lt;/td>
&lt;td>0.7&lt;/td>
&lt;td>0.5&lt;/td>
&lt;td>0.3&lt;/td>
&lt;td>0.1&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>$p_t^{-}$&lt;/td>
&lt;td>0.1&lt;/td>
&lt;td>0.3&lt;/td>
&lt;td>0.5&lt;/td>
&lt;td>0.7&lt;/td>
&lt;td>0.4&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>$P(R_t = 1 \mid G = 3) = P(R_t = 1 \mid G = 0)$&lt;/td>
&lt;td>0.25&lt;/td>
&lt;td>0.5&lt;/td>
&lt;td>0.5&lt;/td>
&lt;td>0.5&lt;/td>
&lt;td>0.25&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>$m_t = E[\alpha \mid G = 3, R_t = 1]$&lt;/td>
&lt;td>0.6&lt;/td>
&lt;td>0.4&lt;/td>
&lt;td>0&lt;/td>
&lt;td>$-0.4$&lt;/td>
&lt;td>$-0.6$&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>$E[\alpha \mid G = 0, R_t = 1]$&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The two cohorts are observed with the same probability at every date, so cohort 3 makes up half of the observed units at each date. What changes is the mix within cohort 3: its observed units have a mean $\alpha$ of 0.4 at date 2 and $-0.4$ at date 4.&lt;/p>
&lt;h2 id="why-changes-within-units-identify-the-effects">Why changes within units identify the effects&lt;/h2>
&lt;p>For a unit observed in window $(s, s+1)$, the fixed component cancels from its change:&lt;/p>
&lt;p>$$Y_{s+1} - Y_s = 0.1 + (\tau_{s+1} - \tau_s) + \varepsilon_{s+1} - \varepsilon_s.$$&lt;/p>
&lt;p>The change depends on the cohort, the dates and the noise, while the window depends only on the cohort and $\alpha$. Within each cohort, the units observed at both dates of a pair therefore have the cohort&amp;rsquo;s mean change,&lt;/p>
&lt;p>$$E[Y_{s+1} - Y_s \mid G, W = (s, s+1)] = E[Y_{s+1} - Y_s \mid G],$$&lt;/p>
&lt;p>even though they do not represent the cohort in levels. This mean condition is what &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code> requires, as described in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#without-a-correction">Handling missing outcomes&lt;/a>. Observation depends on $\alpha$, but $\alpha$ never enters a change, so no model of observation is needed.&lt;/p>
&lt;p>Write $D_{s,s+1}$ for the mean change of cohort 3 minus the mean change of the never treated units. Every mean change equals 0.1, except the change of cohort 3 from date 2 to date 3, which is 1.1. Hence $D_{1,2} = 0$, $D_{2,3} = 1$, $D_{3,4} = 0$ and $D_{4,5} = 0$.&lt;/p>
&lt;p>Untreated outcomes satisfy $Y_t(0) - Y_2(0) = 0.1,(t - 2) + \varepsilon_t - \varepsilon_2$ in both cohorts, so PT-post from reference date 2 holds, and there is no anticipation. The first link then identifies the effect, and the later links identify its increments:&lt;/p>
&lt;p>$$D_{2,3} = \text{ATT}(3,3) = 1, \qquad D_{3,4} = \text{ATT}(3,4) - \text{ATT}(3,3) = 0, \qquad D_{4,5} = \text{ATT}(3,5) - \text{ATT}(3,4) = 0.$$&lt;/p>
&lt;p>Summing the links gives $\text{ATT}(3,4) = D_{2,3} + D_{3,4} = 1$ and $\text{ATT}(3,5) = D_{2,3} + D_{3,4} + D_{4,5} = 1$. The four windows are the only pairs anyone is observed at, so chained difference in differences (chained DiD) can only combine these consecutive comparisons. The cell at date 2, reported before treatment, uses $D_{1,2}$.&lt;/p>
&lt;h2 id="why-comparisons-of-levels-do-not">Why comparisons of levels do not&lt;/h2>
&lt;p>The intercept-only repeated cross section (RCS) IPW estimator used below compares normalized means of outcome levels in each cohort and date arm. Its constant propensity odds cancel within each normalized control mean. In this design the population propensity is 1/2, away from the trimming threshold, so the population comparison for cell (3,t) with reference date 2 is&lt;/p>
&lt;p>$$\bigl(E[Y_t \mid G = 3, R_t = 1] - E[Y_2 \mid G = 3, R_2 = 1]\bigr) - \bigl(E[Y_t \mid G = 0, R_t = 1] - E[Y_2 \mid G = 0, R_2 = 1]\bigr).$$&lt;/p>
&lt;p>The common trend cancels, and the observed never treated units have a mean $\alpha$ of zero at every date, so for $t \ge 3$ this contrast equals $1 + m_t - m_2$, with $m_2 = 0.4$.&lt;/p>
&lt;p>&lt;strong>Table 3. What each comparison targets (population algebra)&lt;/strong>&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Cell&lt;/th>
&lt;th>Known value&lt;/th>
&lt;th>Chained links&lt;/th>
&lt;th>Comparison of observed levels&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Date 2, before treatment (dates 1 and 2)&lt;/td>
&lt;td>0&lt;/td>
&lt;td>$D_{1,2} = 0$&lt;/td>
&lt;td>$m_2 - m_1 = 0.4 - 0.6 = -0.2$&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>ATT(3,3)&lt;/td>
&lt;td>1&lt;/td>
&lt;td>$D_{2,3} = 1$&lt;/td>
&lt;td>$1 + (0 - 0.4) = 0.6$&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>ATT(3,4)&lt;/td>
&lt;td>1&lt;/td>
&lt;td>$1 + 0 = 1$&lt;/td>
&lt;td>$1 + (-0.4 - 0.4) = 0.2$&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>ATT(3,5)&lt;/td>
&lt;td>1&lt;/td>
&lt;td>$1 + 0 + 0 = 1$&lt;/td>
&lt;td>$1 + (-0.6 - 0.4) = 0$&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Callaway and Sant&amp;rsquo;Anna&amp;rsquo;s repeated cross section setting assumes that the sample at each date represents the population at that date and that the distribution of cohorts and covariates is stable across dates. Here population parallel trends hold and the cohort shares are stable, but the first condition fails for cohort 3. Its observed units come mostly from $\alpha = +1$ at early dates and mostly from $\alpha = -1$ at late dates, so each level contrast adds a change in composition to the effect.&lt;/p>
&lt;p>Fixed differences between units do not cause this on their own. The never treated units take the same two values of $\alpha$, but their windows do not depend on it, so their observed levels represent their cohort at every date. If the windows of cohort 3 were also drawn independently of $\alpha$, as in the rotating example of &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Estimate treatment effects from incomplete panels&lt;/a>, the observed levels would represent both cohorts, and the RCS approach would target the same effects under its assumptions. &lt;code>did&lt;/code> handles unbalanced panels with that approach; whether it answers the question depends on its sampling conditions.&lt;/p>
&lt;h2 id="assumptions-in-this-example">Assumptions in this example&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Item&lt;/th>
&lt;th>In this example&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Whose effect&lt;/td>
&lt;td>ATT(3,t) for t = 3, 4, 5 in the study population of 2000 simulated units listed in the unit table &lt;code>units&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Comparison group&lt;/td>
&lt;td>Units never treated, &lt;code>g == 0&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Anticipation&lt;/td>
&lt;td>None, so the reference period of cohort 3 is date 2&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Parallel trends&lt;/td>
&lt;td>PT-post from date 2, true in the design&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Observed changes&lt;/td>
&lt;td>&lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>: within each cohort, units observed at both dates of a pair have the cohort&amp;rsquo;s mean change; true because observation depends only on the cohort and $\alpha$&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Treatment adjustment&lt;/td>
&lt;td>Treatment weighting by inverse probability weighting (IPW) with an intercept only, &lt;code>xformla = ~ 1&lt;/code>; adequate because parallel trends hold without covariates&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Overlap and support&lt;/td>
&lt;td>Every window has positive probability in both cohorts; the script stops if a realized window lacks either cohort&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Unit table&lt;/td>
&lt;td>One row per unit with &lt;code>id&lt;/code> and &lt;code>g&lt;/code>; no covariates or weights&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="code">Code&lt;/h2>
&lt;p>The script simulates the design, fits chained DiD and fits &lt;code>did&lt;/code> with the same upstream arguments. For this genuinely unbalanced panel, with &lt;code>panel = TRUE&lt;/code> and &lt;code>allow_unbalanced_panel = TRUE&lt;/code>, &lt;code>did&lt;/code> 2.5.1 keeps rows with complete values of the variables it uses and applies its RCS point estimator, comparing levels among the units observed at each date. It retains the unit identity distinction for unbalanced-panel inference; using an RCS point construction does not mean it discards identities (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/#incomplete-panels-in-did-and-in-chained-mode">Moving from did&lt;/a>). That is the route compared here. In chained mode, &lt;code>allow_unbalanced_panel = TRUE&lt;/code> has the same meaning as the default &lt;code>NULL&lt;/code>.&lt;/p>
&lt;pre>&lt;code class="language-r">set.seed(20261024)
N &amp;lt;- 2000L
T_dates &amp;lt;- 5L
# Cohort and fixed component: independent draws, each value with probability 1/2.
# alpha only generates the data; neither estimator receives it.
g &amp;lt;- sample(c(0, 3), size = N, replace = TRUE)
alpha &amp;lt;- sample(c(-1, 1), size = N, replace = TRUE)
# Window probabilities of Table 1; window k covers dates k and k + 1.
p_window &amp;lt;- rbind(
never = c(0.25, 0.25, 0.25, 0.25),
treat_high = c(0.40, 0.30, 0.20, 0.10),
treat_low = c(0.10, 0.20, 0.30, 0.40)
)
type &amp;lt;- ifelse(g == 0, &amp;quot;never&amp;quot;, ifelse(alpha &amp;gt; 0, &amp;quot;treat_high&amp;quot;, &amp;quot;treat_low&amp;quot;))
window_start &amp;lt;- integer(N)
for (k in rownames(p_window)) {
in_k &amp;lt;- which(type == k)
window_start[in_k] &amp;lt;- sample.int(4L, size = length(in_k), replace = TRUE,
prob = p_window[k, ])
}
# Stop, without redrawing, if a realized window lacks either cohort.
stopifnot(all(table(factor(g, levels = c(0, 3)),
factor(window_start, levels = 1:4)) &amp;gt; 0))
# Full grid of potential outcomes for every unit and date, with independent noise.
full_grid &amp;lt;- data.frame(
id = rep(seq_len(N), each = T_dates),
time = rep(seq_len(T_dates), times = N)
)
full_grid$g &amp;lt;- g[full_grid$id]
full_grid$alpha &amp;lt;- alpha[full_grid$id]
full_grid$noise &amp;lt;- stats::rnorm(nrow(full_grid), sd = 0.5)
full_grid$y0 &amp;lt;- full_grid$alpha + 0.1 * full_grid$time + full_grid$noise
full_grid$y1 &amp;lt;- full_grid$y0 + 1
full_grid$y &amp;lt;- full_grid$alpha + 0.1 * full_grid$time +
1 * (full_grid$g &amp;gt; 0 &amp;amp; full_grid$time &amp;gt;= full_grid$g) + full_grid$noise
# Keep every unit and date row; the outcome is NA outside the unit's window.
in_window &amp;lt;- full_grid$time == window_start[full_grid$id] |
full_grid$time == window_start[full_grid$id] + 1L
panel_data &amp;lt;- full_grid[, c(&amp;quot;id&amp;quot;, &amp;quot;time&amp;quot;, &amp;quot;g&amp;quot;)]
panel_data$y &amp;lt;- ifelse(in_window, full_grid$y, NA_real_)
stopifnot(all(tapply(!is.na(panel_data$y), panel_data$id, sum) == 2))
# Unit table: one row per study unit, with its identifier and cohort only.
units &amp;lt;- data.frame(id = seq_len(N), g = g)
# Chained DiD: IPW with an intercept only, never treated controls, PT-post,
# and no model of observation.
fit_chained &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
xformla = ~ 1, data = panel_data,
panel = TRUE, allow_unbalanced_panel = TRUE,
control_group = &amp;quot;nevertreated&amp;quot;, anticipation = 0,
est_method = &amp;quot;ipw&amp;quot;, base_period = &amp;quot;varying&amp;quot;,
bstrap = FALSE, cband = FALSE,
frame = units, selection = &amp;quot;none&amp;quot;, pt_assumption = &amp;quot;post&amp;quot;
)
# did's RCS route: the same upstream arguments, no unit table, no chained arguments.
fit_rcs &amp;lt;- did::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
xformla = ~ 1, data = panel_data,
panel = TRUE, allow_unbalanced_panel = TRUE,
control_group = &amp;quot;nevertreated&amp;quot;, anticipation = 0,
est_method = &amp;quot;ipw&amp;quot;, base_period = &amp;quot;varying&amp;quot;,
bstrap = FALSE, cband = FALSE
)
summary(fit_chained)
cdid::tidy(fit_chained)[, c(&amp;quot;target.id&amp;quot;, &amp;quot;role&amp;quot;, &amp;quot;estimate&amp;quot;, &amp;quot;std.error&amp;quot;,
&amp;quot;available&amp;quot;, &amp;quot;support.status&amp;quot;)]
agg_chained &amp;lt;- cdid::aggte(fit_chained, type = &amp;quot;dynamic&amp;quot;)
summary(agg_chained)
summary(fit_rcs)
&lt;/code>&lt;/pre>
&lt;details>
&lt;summary>Console output&lt;/summary>
&lt;pre>&lt;code class="language-text">cdid chained difference-in-differences (chained IPW-GMM): cdid_MP
cdid 1.1.0.0 result built on did 2.5.1 (tested: did 2.5.1); did's MP methods tabulate the estimates below.
Chained estimators: Bellego C., Benatia D. and V. Dortet-Bernadet (2025). &amp;quot;The Chained Difference-in-Differences.&amp;quot; Journal of Econometrics 248, 105783. doi:10.1016/j.jeconom.2024.105783.
Ordinary estimators: Callaway B. and P. H. C. Sant'Anna (2021). &amp;quot;Difference-in-Differences with Multiple Time Periods.&amp;quot; Journal of Econometrics 225(2), 200-230. doi:10.1016/j.jeconom.2020.12.001.
Call:
cdid::att_gt(yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
xformla = ~1, data = panel_data, panel = TRUE, allow_unbalanced_panel = TRUE,
control_group = &amp;quot;nevertreated&amp;quot;, anticipation = 0, est_method = &amp;quot;ipw&amp;quot;,
base_period = &amp;quot;varying&amp;quot;, bstrap = FALSE, cband = FALSE, frame = units,
selection = &amp;quot;none&amp;quot;, pt_assumption = &amp;quot;post&amp;quot;)
Group-Time Average Treatment Effects:
Group Time ATT(g,t) Std. Error [95% Pointwise Conf. Band]
3 2 0.0129 0.0640 -0.1126 0.1383
3 3 0.8972 0.0656 0.7686 1.0258 *
3 4 0.8883 0.0894 0.7130 1.0635 *
3 5 0.8679 0.1098 0.6527 1.0830 *
---
Signif. codes: `*' confidence band does not cover 0
P-value for pre-test of parallel trends assumption: 0.840754265674953
Control Group: Never Treated, Anticipation Periods: 0
Estimation Method: Inverse Probability Weighting
Chained support: 4 of 4 requested cells available.
Units: 2000 in the unit table, 0 observed at all 5 dates, 2000 with at least two observed outcomes.
Observation correction: none (selection = &amp;quot;none&amp;quot;).
Parallel trends: PT-post; base_period = &amp;quot;varying&amp;quot;.
GMM weighting: optimal (two-step); covariance regularization: not applied (moment covariance well conditioned).
Inference: analytic standard errors, unit-level; pointwise intervals.
Parallel-trends pre-test: W = 0.0403724, df = 1, p = 0.8408 (Wald test of the pretrend cell).
target.id role estimate std.error available support.status
1 pre(g=3,t=2) pre 0.01286068 0.06400615 TRUE supported_direct_pretrend
2 ATT(g=3,t=3) post 0.89721369 0.06559575 TRUE estimable
3 ATT(g=3,t=4) post 0.88827272 0.08942485 TRUE estimable
4 ATT(g=3,t=5) post 0.86786563 0.10978623 TRUE estimable
cdid chained difference-in-differences (chained IPW-GMM): cdid_AGGTEobj
cdid 1.1.0.0 result built on did 2.5.1 (tested: did 2.5.1); did's AGGTEobj methods tabulate the estimates below.
Chained estimators: Bellego C., Benatia D. and V. Dortet-Bernadet (2025). &amp;quot;The Chained Difference-in-Differences.&amp;quot; Journal of Econometrics 248, 105783. doi:10.1016/j.jeconom.2024.105783.
Ordinary estimators: Callaway B. and P. H. C. Sant'Anna (2021). &amp;quot;Difference-in-Differences with Multiple Time Periods.&amp;quot; Journal of Econometrics 225(2), 200-230. doi:10.1016/j.jeconom.2020.12.001.
Call:
cdid::aggte(fit_chained, type = &amp;quot;dynamic&amp;quot;)
Overall summary of ATT's based on event-study/dynamic aggregation:
ATT Std. Error [ 95% Conf. Int.]
0.8845 0.08 0.7277 1.0412 *
Dynamic Effects:
Event time Estimate Std. Error [95% Pointwise Conf. Band]
-1 0.0129 0.0640 -0.1126 0.1383
0 0.8972 0.0656 0.7686 1.0258 *
1 0.8883 0.0894 0.7130 1.0635 *
2 0.8679 0.1098 0.6527 1.0830 *
---
Signif. codes: `*' confidence band does not cover 0
Control Group: Never Treated, Anticipation Periods: 0
Estimation Method: Inverse Probability Weighting
Chained dynamic aggregation: 4 of 4 intended aggregate(s) available; na.rm = FALSE.
Overall summary: available over its 3 intended bins; pointwise interval.
Parallel trends: PT-post; base_period = &amp;quot;varying&amp;quot;.
Inference: analytic standard errors, unit-level; pointwise intervals.
Call:
did::att_gt(yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
xformla = ~1, data = panel_data, panel = TRUE, allow_unbalanced_panel = TRUE,
control_group = &amp;quot;nevertreated&amp;quot;, anticipation = 0, bstrap = FALSE,
cband = FALSE, est_method = &amp;quot;ipw&amp;quot;, base_period = &amp;quot;varying&amp;quot;)
Reference: Callaway, Brantly and Pedro H.C. Sant'Anna. &amp;quot;Difference-in-Differences with Multiple Time Periods.&amp;quot; Journal of Econometrics, Vol. 225, No. 2, pp. 200-230, 2021. &amp;lt;https://doi.org/10.1016/j.jeconom.2020.12.001&amp;gt;, &amp;lt;https://arxiv.org/abs/1803.09015&amp;gt;
Group-Time Average Treatment Effects:
Group Time ATT(g,t) Std. Error [95% Pointwise Conf. Band]
3 2 -0.1196 0.0819 -0.2801 0.0408
3 3 0.6840 0.0789 0.5293 0.8387 *
3 4 0.2791 0.0962 0.0906 0.4676 *
3 5 -0.0625 0.1148 -0.2875 0.1625
---
Signif. codes: `*' confidence band does not cover 0
P-value for pre-test of parallel trends assumption: 0.14382
Control Group: Never Treated, Anticipation Periods: 0
Estimation Method: Inverse Probability Weighting
&lt;/code>&lt;/pre>
&lt;/details>
&lt;p>The ordinary RCS fit reports that it drops 6,000 rows with missing outcomes. This is expected here: it compares the observed levels, whereas the chained fit uses the available within-unit changes and the supplied unit table.&lt;/p>
&lt;p>Optionally, put both sets of cells beside the known values of Table 3:&lt;/p>
&lt;pre>&lt;code class="language-r">known &amp;lt;- data.frame(
group = 3, time = 2:5,
known_value = c(0, 1, 1, 1),
level_contrast = c(-0.2, 0.6, 0.2, 0)
)
estimates &amp;lt;- merge(
data.frame(group = fit_chained$group, time = fit_chained$t,
chained = fit_chained$att, chained_se = fit_chained$se),
data.frame(group = fit_rcs$group, time = fit_rcs$t,
rcs = fit_rcs$att, rcs_se = fit_rcs$se),
by = c(&amp;quot;group&amp;quot;, &amp;quot;time&amp;quot;)
)
merge(known, estimates, by = c(&amp;quot;group&amp;quot;, &amp;quot;time&amp;quot;))
&lt;/code>&lt;/pre>
&lt;p>Output:&lt;/p>
&lt;pre>&lt;code class="language-text">group time known_value level_contrast chained chained_se rcs rcs_se
1 3 2 0 -0.2 0.01286068 0.06400615 -0.11964856 0.08185521
2 3 3 1 0.6 0.89721369 0.06559575 0.68400574 0.07892854
3 3 4 1 0.2 0.88827272 0.08942485 0.27907751 0.09616598
4 3 5 1 0.0 0.86786563 0.10978623 -0.06246468 0.11479458
&lt;/code>&lt;/pre>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Argument&lt;/th>
&lt;th>Setting&lt;/th>
&lt;th>Definition&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>est_method&lt;/code>, &lt;code>xformla&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>~ 1&lt;/code>&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#treatment-adjustment">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>control_group&lt;/code>, &lt;code>anticipation&lt;/code>, &lt;code>panel&lt;/code>, &lt;code>allow_unbalanced_panel&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;nevertreated&amp;quot;&lt;/code>, 0, &lt;code>TRUE&lt;/code>, &lt;code>TRUE&lt;/code>&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#data-timing-and-comparison-group">Data, timing and comparison group&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>base_period&lt;/code>, &lt;code>pt_assumption&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;varying&amp;quot;&lt;/code>, &lt;code>&amp;quot;post&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#parallel-trends-and-reporting">Parallel trends and reporting&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>frame&lt;/code>, &lt;code>selection&lt;/code>&lt;/td>
&lt;td>&lt;code>units&lt;/code>, &lt;code>&amp;quot;none&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#chained-arguments">Chained arguments&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>bstrap&lt;/code>, &lt;code>cband&lt;/code>&lt;/td>
&lt;td>&lt;code>FALSE&lt;/code>, &lt;code>FALSE&lt;/code>&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#inference-and-computation">Inference and computation&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The fitted result records these choices: &lt;code>fit_chained$chained$selection$method&lt;/code> for the handling of missing outcomes and &lt;code>fit_chained$chained$pt&lt;/code> for the parallel trends choice.&lt;/p>
&lt;h2 id="known-values-and-future-estimates">Known values and future estimates&lt;/h2>
&lt;p>The design fixes the known values in Table 3: 1 for each effect and 0 for the comparison before treatment. Under the assumptions above, the cells of &lt;code>fit_chained&lt;/code> target these values. With one treated cohort, &lt;code>agg_chained&lt;/code> reports the same cells by event time, so event times 0, 1 and 2 have known value 1 and so does their overall average. The cells of &lt;code>fit_rcs&lt;/code> target the level contrasts 0.6, 0.2 and 0 after treatment and $-0.2$ before it.&lt;/p>
&lt;p>Estimates from a future run need not equal these population values. The algebra does not establish fit completion or the validity of reported uncertainty; &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#what-the-uncertainty-assumes">What the uncertainty assumes&lt;/a> states its separate large sample requirements. In particular, an RCS standard error cannot repair the composition shift relative to the causal ATT. One draw does not measure bias or coverage, and a comparison of precision for a common target would not be justified by these two outputs alone.&lt;/p>
&lt;p>A fit can still fail in a particular sample, for example when a model has no finite solution, and a cell can be unavailable, reported as &lt;code>NA&lt;/code> with a reason (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#unavailable-effects">Unavailable effects&lt;/a>). Keep any such error or status as it is: the script does not retry with other settings, redraw the sample or drop units. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a> describes the checks.&lt;/p>
&lt;h2 id="why-there-is-no-complete-case-comparison">Why there is no complete case comparison&lt;/h2>
&lt;p>&lt;code>did&lt;/code>&amp;rsquo;s default, &lt;code>allow_unbalanced_panel = FALSE&lt;/code>, keeps only units observed at every date. Every unit here has exactly two observed outcomes, so that subset is empty and no complete case estimate exists. The script therefore contains no such call. In chained mode, an explicit &lt;code>allow_unbalanced_panel = FALSE&lt;/code> is refused with class &lt;code>cdid_chained_balanced&lt;/code>.&lt;/p>
&lt;h2 id="what-the-example-shows">What the example shows&lt;/h2>
&lt;p>The construction shows one way in which the two routes can target different quantities from the same data. It does not show that chained DiD is preferable in general. In other designs both routes can be valid, and either can be more precise. Chained DiD with &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code> can fail when observation changes the cohort mean of an observed pair change, for example through selection on noise or heterogeneous effects. Dependence alone does not establish that failure: the required mean representativeness may still hold. If $\alpha$ were measured and supplied as a covariate, models that condition on it would become available, each with its own conditions, and the comparison could come out differently. Here $\alpha$ is unobserved and the formula is &lt;code>~ 1&lt;/code>.&lt;/p>
&lt;h2 id="next-step">Next step&lt;/h2>
&lt;p>When observation depends on measured characteristics that also shift the changes, &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a> explains the conditional assumption and the three ways to adjust for it.&lt;/p>
&lt;h2 id="output-from-the-example">Output from the example&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Period&lt;/th>
&lt;th>Target truth&lt;/th>
&lt;th>Chained estimate&lt;/th>
&lt;th>SE&lt;/th>
&lt;th>RCS estimate&lt;/th>
&lt;th>SE&lt;/th>
&lt;th>RCS population contrast&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>0.000&lt;/td>
&lt;td>0.013&lt;/td>
&lt;td>0.064&lt;/td>
&lt;td>-0.120&lt;/td>
&lt;td>0.082&lt;/td>
&lt;td>-0.200&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>1.000&lt;/td>
&lt;td>0.897&lt;/td>
&lt;td>0.066&lt;/td>
&lt;td>0.684&lt;/td>
&lt;td>0.079&lt;/td>
&lt;td>0.600&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>1.000&lt;/td>
&lt;td>0.888&lt;/td>
&lt;td>0.089&lt;/td>
&lt;td>0.279&lt;/td>
&lt;td>0.096&lt;/td>
&lt;td>0.200&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>1.000&lt;/td>
&lt;td>0.868&lt;/td>
&lt;td>0.110&lt;/td>
&lt;td>-0.062&lt;/td>
&lt;td>0.115&lt;/td>
&lt;td>0.000&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Each unit has exactly two observed outcomes. The post-treatment truth is 1 at every date; the RCS population contrasts are 0.6, 0.2 and 0.0. The estimates above are one draw. &lt;code>did&lt;/code> warned that it removed 6000 rows with missing outcomes; that warning is expected for this RCS call and was retained.&lt;/p>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 4 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;strong>Identify effects when the observed units change composition&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>Impute actual changes for missing outcomes</title><link>https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/</guid><description>&lt;p>Results below were produced on October 29, 2026 with &lt;code>cdid&lt;/code> 1.1.0.0, &lt;code>did&lt;/code> 2.5.1 and &lt;code>DRDID&lt;/code> 1.3.0 under R 4.5.2, using the displayed seeds where applicable. These are individual examples; they do not establish repeated-sample coverage. OR/DR calls shown here explicitly retain pooled slopes; the current default uses separate comparison regressions.&lt;/p>
&lt;p>Observation weighting reweights the changes of units observed at both dates. Change imputation instead predicts the actual change of every unit from its covariates, and the augmented correction combines prediction with weighting. This example compares the three corrections on the panel of &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model for missing outcomes&lt;/a>, where every model they need is correctly specified by construction. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#change-imputation">Handling missing outcomes&lt;/a> defines the methods.&lt;/p>
&lt;h2 id="prerequisite">Prerequisite&lt;/h2>
&lt;p>Run the code under &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/#generate-the-panel">Generate the panel&lt;/a> first. This page uses its &lt;code>sim&lt;/code>, &lt;code>panel&lt;/code> and &lt;code>units&lt;/code> exactly as generated there, with the same missing outcomes, and draws no new data. The fit &lt;code>fit_none&lt;/code> from that page is an optional baseline only when fitted to these same objects: its assumption fails in this design, so it offers no protection.&lt;/p>
&lt;pre>&lt;code class="language-r"># Objects from the first example; this page draws no new data.
stopifnot(
is.data.frame(sim), is.data.frame(panel), is.data.frame(units),
nrow(units) == 2000, nrow(panel) == 2000 * 6,
identical(!is.na(panel$y), sim$observed)
)
&lt;/code>&lt;/pre>
&lt;h2 id="two-outcome-regressions">Two outcome regressions&lt;/h2>
&lt;p>Change imputation fits a model &lt;code>j&lt;/code> of actual changes. It is not the counterfactual regression &lt;code>m&lt;/code> of treatment OR and DR.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;/th>
&lt;th>Actual change model &lt;code>j&lt;/code>&lt;/th>
&lt;th>Counterfactual regression &lt;code>m&lt;/code>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Layer&lt;/td>
&lt;td>handling missing outcomes: &lt;code>selection_est_method = &amp;quot;imputation&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>&lt;/td>
&lt;td>treatment adjustment: &lt;code>est_method = &amp;quot;reg&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Predicts&lt;/td>
&lt;td>the actual change of a cohort over a pair of dates, effects included&lt;/td>
&lt;td>the untreated change&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Fitted to&lt;/td>
&lt;td>units of the cohort observed at both dates&lt;/td>
&lt;td>control changes, reconstructed under imputation and the augmented correction&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Slopes&lt;/td>
&lt;td>shared as &lt;code>imputation_pooling&lt;/code> declares&lt;/td>
&lt;td>separate by comparison by default, or shared across blocks with &lt;code>outcome_pooling = &amp;quot;pooled&amp;quot;&lt;/code>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Both read &lt;code>xformla&lt;/code>. Here &lt;code>~ x&lt;/code> defines &lt;code>j&lt;/code> and both treatment models of &lt;code>est_method = &amp;quot;dr&amp;quot;&lt;/code>, the treatment logit &lt;code>p&lt;/code> and &lt;code>m&lt;/code>. &lt;code>selection_xformla&lt;/code> defines only the observation model &lt;code>q&lt;/code>.&lt;/p>
&lt;h2 id="how-change-imputation-works">How change imputation works&lt;/h2>
&lt;p>For each cohort k and each pair of dates e that the estimator needs, &lt;code>j&lt;/code> is fitted by weighted least squares to the units of cohort k observed at both dates:&lt;/p>
&lt;pre>&lt;code>j(k, e)(x) = alpha(k, e) + L(e) * x * beta(r)
&lt;/code>&lt;/pre>
&lt;p>&lt;code>L(e)&lt;/code> counts the steps between the two dates in the stored calendar, so &lt;code>L(e) = t - s&lt;/code> for dates 1 to 6. &lt;code>alpha(k, e)&lt;/code> is an intercept for each cohort and pair, present because &lt;code>~ x&lt;/code> has one, and &lt;code>beta(r)&lt;/code> is the slope of pooling group r. The default &lt;code>imputation_pooling = &amp;quot;separate&amp;quot;&lt;/code> gives each cohort and pair its own intercept and slope.&lt;/p>
&lt;p>The fitted model is evaluated for every unit of cohort k in &lt;code>units&lt;/code>, including units whose change was observed, and the average of these predictions replaces the observed mean. You fill in nothing; &lt;code>y&lt;/code> stays &lt;code>NA&lt;/code>. A unit observed at one date supplies no change. Its prediction is the whole change predicted from &lt;code>x&lt;/code>; the method does not condition on its one observed outcome or impute a missing level from it. This is one imputation strategy, prediction and averaging of changes, not imputation of missing outcomes in general.&lt;/p>
&lt;p>Because &lt;code>j&lt;/code> predicts actual changes, it must represent how the effect varies with &lt;code>x&lt;/code>. For a pair that spans the start of treatment, the mean change of cohort 3 has slope &lt;code>0.3 * L(e) + 0.5&lt;/code> on &lt;code>x&lt;/code>; for every other pair of either cohort the slope is &lt;code>0.3 * L(e)&lt;/code>. Thus the duration scaled coefficient &lt;code>beta(r)&lt;/code> must be &lt;code>0.3 + 0.5 / L(e)&lt;/code> for treatment crossing pairs of cohort 3 and &lt;code>0.3&lt;/code> otherwise. With binary &lt;code>x&lt;/code> and separate cells, &lt;code>j&lt;/code> is correct. The mean untreated change, &lt;code>0.1 * L(e) + 0.3 * L(e) * x&lt;/code>, makes &lt;code>m&lt;/code> correct with a block intercept and one slope on &lt;code>L(e) * x&lt;/code>, and &lt;code>p&lt;/code> is correct because the cohort is drawn independently of &lt;code>x&lt;/code>. These are algebraic properties of the design, not fit results or guarantees.&lt;/p>
&lt;h2 id="three-corrected-fits">Three corrected fits&lt;/h2>
&lt;p>The three fits keep treatment DR and every setting of the first example; only the correction changes.&lt;/p>
&lt;pre>&lt;code class="language-r">fit_weighting &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
xformla = ~ x, data = panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
pt_assumption = &amp;quot;post&amp;quot;, base_period = &amp;quot;varying&amp;quot;,
selection = &amp;quot;conditional_mtar&amp;quot;,
selection_est_method = &amp;quot;ipw&amp;quot;,
selection_model = &amp;quot;independent_period_logit&amp;quot;,
selection_pooling = &amp;quot;separate&amp;quot;,
selection_universe = &amp;quot;F&amp;quot;,
bstrap = FALSE, cband = FALSE
)
fit_imputation &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
xformla = ~ x, data = panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
pt_assumption = &amp;quot;post&amp;quot;, base_period = &amp;quot;varying&amp;quot;,
selection = &amp;quot;conditional_mtar&amp;quot;,
selection_est_method = &amp;quot;imputation&amp;quot;,
selection_universe = &amp;quot;F&amp;quot;,
imputation_pooling = &amp;quot;separate&amp;quot;,
bstrap = FALSE, cband = FALSE
)
fit_augmented &amp;lt;- cdid::att_gt(
outcome_pooling = &amp;quot;pooled&amp;quot;,
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
xformla = ~ x, data = panel, frame = units,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;dr&amp;quot;,
pt_assumption = &amp;quot;post&amp;quot;, base_period = &amp;quot;varying&amp;quot;,
selection = &amp;quot;conditional_mtar&amp;quot;,
selection_est_method = &amp;quot;dr&amp;quot;,
selection_model = &amp;quot;independent_period_logit&amp;quot;,
selection_pooling = &amp;quot;separate&amp;quot;,
selection_universe = &amp;quot;F&amp;quot;,
imputation_pooling = &amp;quot;separate&amp;quot;,
bstrap = FALSE, cband = FALSE
)
&lt;/code>&lt;/pre>
&lt;p>&lt;code>fit_weighting&lt;/code> repeats the specification of &lt;code>fit_date&lt;/code>. &lt;code>fit_imputation&lt;/code> passes no &lt;code>selection_model&lt;/code>, &lt;code>selection_pooling&lt;/code> or &lt;code>selection_xformla&lt;/code>: under pure imputation they are inactive and never evaluated, and no observation probability is fitted. &lt;code>fit_augmented&lt;/code> uses both groups of arguments, and both models are active.&lt;/p>
&lt;h2 id="the-augmented-correction">The augmented correction&lt;/h2>
&lt;p>For each needed cell c, a cohort and pair, every unit of the cohort receives the reconstructed change&lt;/p>
&lt;pre>&lt;code>Z(c) = j(c)(x) + S(e) * { change(e) - j(c)(x) } / max(q(c)(x), 1e-6)
&lt;/code>&lt;/pre>
&lt;p>where &lt;code>S(e)&lt;/code> is 1 for units observed at both dates and 0 otherwise, and &lt;code>q(c)&lt;/code> is the fitted probability of observing both dates, here a product of two fitted date probabilities. For cohort 3, &lt;code>j(c)&lt;/code> is the model of its actual change, effects included, not the counterfactual regression &lt;code>m&lt;/code>; &lt;code>m&lt;/code> is fitted afterward to the reconstructed changes of the controls. The correction term is not renormalized. Since version 1.1.0.0 its inverse observation denominator is floored at &lt;code>1e-6&lt;/code> (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#probability-safeguards">Probability safeguards&lt;/a>). The result is one estimator, not an average of the other two.&lt;/p>
&lt;p>The examples keep &lt;code>est_method = &amp;quot;dr&amp;quot;&lt;/code> so only the missing-outcome adjustment changes. You can instead combine any of the three adjustments with treatment &lt;code>&amp;quot;ipw&amp;quot;&lt;/code> or &lt;code>&amp;quot;reg&amp;quot;&lt;/code>. The augmented correction still fits both &lt;code>q&lt;/code> and &lt;code>j&lt;/code>; treatment IPW additionally fits only &lt;code>p&lt;/code>, and treatment OR only &lt;code>m&lt;/code>. Their treatment-model requirements differ as shown in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/#correctness-conditions-across-both-layers">Correctness conditions across both layers&lt;/a>.&lt;/p>
&lt;h2 id="which-models-must-be-correct">Which models must be correct&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Fit&lt;/th>
&lt;th>Missing outcome layer&lt;/th>
&lt;th>Treatment layer&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>fit_weighting&lt;/code>&lt;/td>
&lt;td>&lt;code>q&lt;/code> correct in every needed cell, with independence of the two dates&lt;/td>
&lt;td>&lt;code>p&lt;/code> or &lt;code>m&lt;/code> correct&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>fit_imputation&lt;/code>&lt;/td>
&lt;td>&lt;code>j&lt;/code> correct in every needed cell&lt;/td>
&lt;td>&lt;code>p&lt;/code> or &lt;code>m&lt;/code> correct&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>fit_augmented&lt;/code>&lt;/td>
&lt;td>for each needed cell, &lt;code>q&lt;/code> or &lt;code>j&lt;/code> correct, possibly different across cells&lt;/td>
&lt;td>&lt;code>p&lt;/code> or &lt;code>m&lt;/code> correct&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Every fit also needs conditional mean trends missing at random given a scientifically sufficient conditioning set W, here &lt;code>x&lt;/code>; PT-post and no anticipation; positive cohort masses, positive observation probabilities where &lt;code>q&lt;/code> is fitted and positive training mass with prediction support where &lt;code>j&lt;/code> is; valid moments for every comparison used; and regular finite fits of every active model, alongside the usual large sample regularity conditions. For the augmented route, W includes the covariates in &lt;code>xformla&lt;/code> and any variables only in &lt;code>selection_xformla&lt;/code>; a correct &lt;code>j&lt;/code> must represent the actual-change mean on that W. Correctness must hold across the cells sharing the relevant slopes, both endpoints of an active date model and all blocks of a shared counterfactual regression. Different predictor lists need separately sufficient treatment and observation restrictions. Pure imputation needs a correct &lt;code>j&lt;/code> even when &lt;code>p&lt;/code> and &lt;code>m&lt;/code> are both correct: treatment DR does not generally repair a wrong imputer. These conditions are sufficient, not necessary, and they concern large sample behavior. There is no general finite sample unbiasedness guarantee, and no fit is guaranteed the lowest standard error. Here every model is correct, so all three fits are expected to target the effects. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/#correctness-conditions-across-both-layers">Compare model robustness&lt;/a> gives the complete conditions.&lt;/p>
&lt;h2 id="three-kinds-of-slope-sharing">Three kinds of slope sharing&lt;/h2>
&lt;p>&lt;code>imputation_pooling&lt;/code> shares slopes of &lt;code>j&lt;/code>, and &lt;code>selection_pooling&lt;/code> shares slopes of &lt;code>q&lt;/code>; under the augmented correction they act independently. The counterfactual regression &lt;code>m&lt;/code> uses separate comparison slopes by default; &lt;code>outcome_pooling = &amp;quot;pooled&amp;quot;&lt;/code> shares them across blocks. Its pooling choice is independent of the other two.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;code>imputation_pooling&lt;/code>&lt;/th>
&lt;th>Slopes of &lt;code>j&lt;/code>&lt;/th>
&lt;th>Here&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>&amp;quot;separate&amp;quot;&lt;/code> (default)&lt;/td>
&lt;td>one per cohort and pair&lt;/td>
&lt;td>correct&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;within_cohort&amp;quot;&lt;/code>&lt;/td>
&lt;td>one per cohort across its pairs&lt;/td>
&lt;td>misspecified: pairs of cohort 3 that span the start of treatment have the extra slope 0.5 on &lt;code>x&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;across_cohorts&amp;quot;&lt;/code>&lt;/td>
&lt;td>one for all cells&lt;/td>
&lt;td>misspecified for the same reason&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Each cohort and pair keeps its intercept whenever &lt;code>xformla&lt;/code> has one. Shared slopes are a restriction you choose, and they can be wrong, for example when the effect varies with covariates, as here. Pooling is not changed automatically after a failure. A pooling group whose reduced design remains rank deficient is refused; exact aliases may first be removed only when the required predictions are preserved.&lt;/p>
&lt;h2 id="read-the-results">Read the results&lt;/h2>
&lt;pre>&lt;code class="language-r">fits &amp;lt;- list(weighting = fit_weighting, imputation = fit_imputation,
augmented = fit_augmented)
# Optional: add this baseline only if fit_none was fitted to these same
# panel/units objects in the preceding page, not an unrelated session object.
# fits &amp;lt;- c(list(none = fit_none), fits)
simple &amp;lt;- lapply(fits, cdid::aggte, type = &amp;quot;simple&amp;quot;)
data.frame(
handling = names(simple),
estimate = vapply(simple, function(a) a$overall.att, numeric(1)),
std.error = vapply(simple, function(a) a$overall.se, numeric(1))
)
# Known value of the simple aggregate for these generated units.
1.375 + 0.5 * mean(units$x[units$g == 3])
fit_imputation$chained$selection[c(&amp;quot;method&amp;quot;, &amp;quot;imputation_pooling&amp;quot;)]
fit_augmented$chained$selection[c(&amp;quot;method&amp;quot;, &amp;quot;selection_model&amp;quot;, &amp;quot;selection_pooling&amp;quot;,
&amp;quot;imputation_pooling&amp;quot;, &amp;quot;selection_formula_inherited&amp;quot;)]
&lt;/code>&lt;/pre>
&lt;details>
&lt;summary>Console output&lt;/summary>
&lt;pre>&lt;code class="language-text">handling estimate std.error
weighting weighting 1.623850 0.03817623
imputation imputation 1.628628 0.03800096
augmented augmented 1.628628 0.03800096
[1] 1.626773
$method
[1] &amp;quot;imputation&amp;quot;
$imputation_pooling
[1] &amp;quot;separate&amp;quot;
$method
[1] &amp;quot;augmented&amp;quot;
$selection_model
[1] &amp;quot;independent_period_logit&amp;quot;
$selection_pooling
[1] &amp;quot;separate&amp;quot;
$imputation_pooling
[1] &amp;quot;separate&amp;quot;
$selection_formula_inherited
[1] TRUE
&lt;/code>&lt;/pre>
&lt;/details>
&lt;p>With one treated cohort, the simple aggregate is the average of ATT(3, 3) to ATT(3, 6), &lt;code>1.375 + 0.5 * E[x | g = 3]&lt;/code>, which is 1.625 in the population. The known value uses the generated &lt;code>x&lt;/code> of cohort 3; it is a target, not a fitted aggregate, and it involves no estimated cohort shares. &lt;code>method&lt;/code> names the route; &lt;code>selection_formula_inherited&lt;/code> reports whether &lt;code>selection_xformla&lt;/code> was inherited from &lt;code>xformla&lt;/code>, which these calls leave at &lt;code>NULL&lt;/code>. The nuisance diagnostics of &lt;code>fit_imputation&lt;/code> list the imputation cells and pooling groups, the counterfactual regression and the treatment logits, with no observation probability model. &lt;code>summary()&lt;/code> adds a line describing either route.&lt;/p>
&lt;h2 id="refusals-and-limits">Refusals and limits&lt;/h2>
&lt;ul>
&lt;li>Pure imputation fits no observation logit, so no such logit can cause a refusal, and it can run when every unit of a cell is observed. Its own models must still pass their support and rank checks, and the treatment logits and counterfactual regression keep theirs.&lt;/li>
&lt;li>The augmented correction fits both missing-outcome models and the models active under the chosen treatment method. A failure in any active model is refused, including an active observation cell with its own free intercept in which every unit, or none, is observed. Nothing falls back to another correction.&lt;/li>
&lt;li>A route&amp;rsquo;s label does not make every cell available. A cell that the comparisons cannot support is reported as unavailable with its reason.&lt;/li>
&lt;li>Version 1.1.0.0 applies fixed treatment-propensity caps and inverse-observation floors without dropping observations; binding safeguards can alter the original target and robustness claims (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#probability-safeguards">Probability safeguards&lt;/a>). A multiplier bootstrap, when requested, reuses the influence functions and refits nothing. Missing outcomes or changes are not randomly drawn: this is not multiple imputation and uses no combination by Rubin&amp;rsquo;s rules. The multiplier bootstrap does draw random signs for inference.&lt;/li>
&lt;li>Standard errors come from complete influence functions with one row for every unit of &lt;code>units&lt;/code>, including units observed once or never. They account for the estimated imputation, observation, treatment and counterfactual models, the response rates and the cohort shares used. With &lt;code>compute_inffunc = FALSE&lt;/code> a fit returns point estimates only, and &lt;code>aggte()&lt;/code> refuses it.&lt;/li>
&lt;/ul>
&lt;p>The argument rules are in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#handling-missing-outcomes">Options reference&lt;/a>, the counterfactual regression in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/#change-imputation-uses-a-different-regression">Treatment adjustment&lt;/a>, and the reported uncertainty in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#uncertainty">Results reference&lt;/a>.&lt;/p>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 12 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;strong>Impute actual changes&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>Investigate missingness and data structure</title><link>https://www.davidbenatia.com/tools/cdid/guide/help/investigate-missingness/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/help/investigate-missingness/</guid><description>&lt;p>Results below were produced on October 29, 2026 with &lt;code>cdid&lt;/code> 1.1.0.0, &lt;code>did&lt;/code> 2.5.1 and &lt;code>DRDID&lt;/code> 1.3.0 under R 4.5.2, using the displayed seeds where applicable. These are individual examples; they do not establish repeated-sample coverage.&lt;/p>
&lt;p>Before choosing an adjustment, establish which study units are in your data, when their outcomes are observed and which changes they supply. Then inspect the fitted support and model records. These checks reveal observation patterns and model problems. They cannot prove that missing changes are representative in mean or that untreated trends are parallel.&lt;/p>
&lt;h2 id="what-data-do-i-need">What data do I need?&lt;/h2>
&lt;p>For a simple chained specification, supply long data with these four columns:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Column&lt;/th>
&lt;th>Required information&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Unit ID&lt;/td>
&lt;td>A nonmissing identifier that links repeated observations of the same unit&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Time&lt;/td>
&lt;td>A finite numeric date, on a common scale across units&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Outcome&lt;/td>
&lt;td>A numeric outcome, finite when observed and &lt;code>NA&lt;/code> when missing&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>First treatment cohort&lt;/td>
&lt;td>A known, constant first-treatment date for each unit, with &lt;code>0&lt;/code> for never treated, on the same numeric scale as time&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Each &lt;code>(ID, time)&lt;/code> pair must be unique. The treatment date itself need not appear as an observed row. A balanced panel and an observed baseline outcome for every unit are not required. Keep a date in the stored calendar through rows with &lt;code>y = NA&lt;/code> when you intend it to be part of that calendar. An entirely omitted date is not recovered automatically.&lt;/p>
&lt;p>The optional &lt;code>frame&lt;/code> is a unit table with one row per intended study unit. You can omit it when every intended unit appears somewhere in &lt;code>data&lt;/code>, including units whose outcomes are all &lt;code>NA&lt;/code>. A unit absent from all rows cannot be recovered from the observed panel: a complete unit table is needed to include such zero-observation units. The package cannot infer their number or their attributes from the observed units.&lt;/p>
&lt;p>Additional requirements follow from your request. Covariates, positive sampling weights and cluster labels must be supplied on the units and dates read by the active models. If covariates or weights change over time, actual dated reference rows may be needed even where &lt;code>y = NA&lt;/code>. Values are not carried forward. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a> explains the reference rules, model-specific coverage and the limited baseline handling of unknown frame-only cohorts. Supplying known cohorts for all study units makes population counts and cohort-share aggregation interpretable and is required by conditional observation adjustments.&lt;/p>
&lt;p>Correct columns and two observations per unit are not an identification guarantee. Each needed comparison also requires cohort and eligible-control support, overlap, valid observation reconstruction, parallel trends and the relevant nuisance-model conditions. The target must be estimable from the retained catalog under those assumptions.&lt;/p>
&lt;h2 id="a-small-observation-pattern-example">A small observation-pattern example&lt;/h2>
&lt;p>The next blocks are self-contained base R code. They describe twelve study units in cohorts 0, 3 and 5, including units observed once or never. The artificial outcomes only make the input concrete. This tiny table illustrates checks and is not a recommended estimation sample.&lt;/p>
&lt;pre>&lt;code class="language-r">unit_table &amp;lt;- data.frame(
id = 1:12,
first_treat = rep(c(0, 3, 5), each = 4),
x = rep(c(-1, 0, 1, 2), times = 3)
)
# Within each cohort: one unit with no observed outcome, one singleton,
# one unit observed at {1, 2}, and one observed at {2, 4, 5}.
panel_check &amp;lt;- data.frame(
id = c(2, 3, 3, 4, 4, 4, 6, 7, 7, 8, 8, 8,
10, 11, 11, 12, 12, 12),
period = rep(c(2, 1, 2, 2, 4, 5), times = 3)
)
pos &amp;lt;- match(panel_check$id, unit_table$id)
panel_check$first_treat &amp;lt;- unit_table$first_treat[pos]
panel_check$x &amp;lt;- unit_table$x[pos]
panel_check$y &amp;lt;- panel_check$id / 10 + panel_check$period / 5 +
as.numeric(panel_check$first_treat &amp;gt; 0 &amp;amp;
panel_check$period &amp;gt;= panel_check$first_treat)
# Retain date 3 in the stored calendar, without declaring an observed outcome.
# Units 5 and 9 have no panel rows and are known only through the unit table.
panel_check &amp;lt;- rbind(panel_check, data.frame(
id = 1L, period = 3, first_treat = 0, x = -1, y = NA_real_
))
panel_check &amp;lt;- panel_check[order(panel_check$id, panel_check$period), ]
rownames(panel_check) &amp;lt;- NULL
&lt;/code>&lt;/pre>
&lt;h3 id="validate-identity-dates-and-cohorts">Validate identity, dates and cohorts&lt;/h3>
&lt;p>For your own data, replace &lt;code>panel_check&lt;/code> and &lt;code>unit_table&lt;/code> with your long panel and known unit table using these column names, or adapt the names in the checks. If no separate unit table is needed, first form it from unique unit attributes in the panel and verify that each unit has only one cohort. Do not construct a supposedly complete unit table from observed IDs when the target also includes units absent from the panel.&lt;/p>
&lt;pre>&lt;code class="language-r">stopifnot(
!anyNA(unit_table$id), !anyDuplicated(unit_table$id),
!anyNA(panel_check$id),
!anyDuplicated(panel_check[c(&amp;quot;id&amp;quot;, &amp;quot;period&amp;quot;)]),
is.numeric(panel_check$period), all(is.finite(panel_check$period)),
is.numeric(panel_check$y),
all(is.na(panel_check$y) | is.finite(panel_check$y)),
is.numeric(unit_table$first_treat),
all(is.finite(unit_table$first_treat)),
all(unit_table$first_treat &amp;gt;= 0),
is.numeric(panel_check$first_treat),
all(is.finite(panel_check$first_treat))
)
pos &amp;lt;- match(panel_check$id, unit_table$id)
stopifnot(!anyNA(pos))
stopifnot(all(panel_check$first_treat == unit_table$first_treat[pos]))
sort(unique(panel_check$period))
&lt;/code>&lt;/pre>
&lt;p>Output:&lt;/p>
&lt;pre>&lt;code class="language-text">[1] 1 2 3 4 5
&lt;/code>&lt;/pre>
&lt;p>The last check verifies both constancy of each panel unit&amp;rsquo;s cohort and agreement with the unit table. It does not verify the substantive accuracy of the recorded treatment dates. Check your source records as well.&lt;/p>
&lt;h3 id="count-outcomes-using-all-study-units-as-the-denominator">Count outcomes using all study units as the denominator&lt;/h3>
&lt;pre>&lt;code class="language-r">observed &amp;lt;- !is.na(panel_check$y)
n_outcomes &amp;lt;- tabulate(
match(panel_check$id[observed], unit_table$id),
nbins = nrow(unit_table)
)
cohorts &amp;lt;- sort(unique(unit_table$first_treat))
coverage &amp;lt;- do.call(rbind, lapply(cohorts, function(g) {
take &amp;lt;- unit_table$first_treat == g
z &amp;lt;- n_outcomes[take]
data.frame(cohort = g, n_study_units = sum(take),
n_zero = sum(z == 0), n_singleton = sum(z == 1),
n_repeated = sum(z &amp;gt;= 2),
share_repeated = mean(z &amp;gt;= 2))
}))
coverage
date_coverage &amp;lt;- do.call(rbind, lapply(sort(unique(panel_check$period)), function(t) {
seen &amp;lt;- unit_table$id %in%
panel_check$id[panel_check$period == t &amp;amp; observed]
do.call(rbind, lapply(cohorts, function(g) {
take &amp;lt;- unit_table$first_treat == g
data.frame(cohort = g, period = t, n_study_units = sum(take),
n_observed = sum(seen[take]), share_observed = mean(seen[take]))
}))
}))
date_coverage
&lt;/code>&lt;/pre>
&lt;p>Output:&lt;/p>
&lt;pre>&lt;code class="language-text">cohort n_study_units n_zero n_singleton n_repeated share_repeated
1 0 4 1 1 2 0.5
2 3 4 1 1 2 0.5
3 5 4 1 1 2 0.5
cohort period n_study_units n_observed share_observed
1 0 1 4 1 0.25
2 3 1 4 1 0.25
3 5 1 4 1 0.25
4 0 2 4 3 0.75
5 3 2 4 3 0.75
6 5 2 4 3 0.75
7 0 3 4 0 0.00
8 3 3 4 0 0.00
9 5 3 4 0 0.00
10 0 4 4 1 0.25
11 3 4 4 1 0.25
12 5 4 4 1 0.25
13 0 5 4 1 0.25
14 3 5 4 1 0.25
15 5 5 4 1 0.25
&lt;/code>&lt;/pre>
&lt;p>Zeros and singletons stay in the denominators. Units with two or more observed outcomes supply changes only for the pairs at which both endpoints are observed. A high repeat-observation rate can coexist with no support for a particular pair. If you use sampling weights, distinguish these raw counts from the corresponding weighted population masses under your declared reference-weight rule.&lt;/p>
&lt;h3 id="investigate-selected-pairs">Investigate selected pairs&lt;/h3>
&lt;pre>&lt;code class="language-r">pair_counts &amp;lt;- function(s, t) {
stopifnot(s &amp;lt; t)
at_s &amp;lt;- unit_table$id %in%
panel_check$id[panel_check$period == s &amp;amp; observed]
at_t &amp;lt;- unit_table$id %in%
panel_check$id[panel_check$period == t &amp;amp; observed]
do.call(rbind, lapply(cohorts, function(g) {
take &amp;lt;- unit_table$first_treat == g
data.frame(cohort = g, start = s, end = t, n_study_units = sum(take),
n_start = sum(at_s[take]), n_end = sum(at_t[take]),
n_both = sum(at_s[take] &amp;amp; at_t[take]),
share_both = mean(at_s[take] &amp;amp; at_t[take]))
}))
}
selected_pairs &amp;lt;- rbind(pair_counts(1, 2), pair_counts(2, 4), pair_counts(1, 4))
selected_pairs
&lt;/code>&lt;/pre>
&lt;p>Output:&lt;/p>
&lt;pre>&lt;code class="language-text">cohort start end n_study_units n_start n_end n_both share_both
1 0 1 2 4 1 3 1 0.25
2 3 1 2 4 1 3 1 0.25
3 5 1 2 4 1 3 1 0.25
4 0 2 4 4 3 1 1 0.25
5 3 2 4 4 3 1 1 0.25
6 5 2 4 4 3 1 1 0.25
7 0 1 4 4 1 1 0 0.00
8 3 1 4 4 1 1 0 0.00
9 5 1 4 4 1 1 0 0.00
&lt;/code>&lt;/pre>
&lt;p>This table asks who can supply each change. It does not reproduce the package catalog or select a valid comparison group. For example, for cohort 3 with zero anticipation and reference date 2, cohort 5 remains untreated through date 4 and can be eligible for a not-yet-treated comparison ending at 4. It cannot supply untreated controls at date 5. Never-treated controls are coded 0. Actual catalog retention also depends on the comparison&amp;rsquo;s reference, control pool, pair support and the requested models.&lt;/p>
&lt;p>Start with pairs relevant to your scientific targets and suspected gaps. On large panels, keep the long data and count selected pairs or dates, as above. Do not build a dense units-by-dates matrix or every possible pair merely to explore missingness. The small date-by-cohort output table is distinct from a full unit-calendar expansion. After fitting, use the package&amp;rsquo;s support records to investigate which retained comparisons support each requested target.&lt;/p>
&lt;h3 id="compare-observed-covariate-composition">Compare observed covariate composition&lt;/h3>
&lt;pre>&lt;code class="language-r">at_2 &amp;lt;- unit_table$id %in%
panel_check$id[panel_check$period == 2 &amp;amp; observed]
at_4 &amp;lt;- unit_table$id %in%
panel_check$id[panel_check$period == 4 &amp;amp; observed]
composition &amp;lt;- do.call(rbind, lapply(cohorts, function(g) {
take &amp;lt;- unit_table$first_treat == g
pair &amp;lt;- take &amp;amp; at_2 &amp;amp; at_4
data.frame(cohort = g, mean_x_study = mean(unit_table$x[take]),
n_pair = sum(pair),
mean_x_pair = if (any(pair)) mean(unit_table$x[pair]) else NA_real_)
}))
composition
&lt;/code>&lt;/pre>
&lt;p>Output:&lt;/p>
&lt;pre>&lt;code class="language-text">cohort mean_x_study n_pair mean_x_pair
1 0 0.5 1 2
2 3 0.5 1 2
3 5 0.5 1 2
&lt;/code>&lt;/pre>
&lt;p>Here &lt;code>x&lt;/code> is known for the study population and is constant within unit. In your application, inspect relevant covariates at the reference date actually read by the model, with the intended weights where needed. Compare distributions across all study units and observed pairs, not only a pooled mean. Look for absent factor levels, limited overlap and cells with no observed or no missing units. These can expose implausible specifications or a logit separation problem. Similar observed covariate distributions still do not establish representativeness of the unobserved changes.&lt;/p>
&lt;h2 id="read-the-diagnostics-from-a-fitted-result">Read the diagnostics from a fitted result&lt;/h2>
&lt;p>If the fit warns about missing reference covariates, review
&lt;code>fit$chained$reference_eligibility$targets&lt;/code> before interpreting the effects.
This table identifies the cohorts and reference dates to inspect in your data.
Use a covariate-only row for any independently known reference value.
&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#reference-covariate-exclusions">Reference covariate diagnostics&lt;/a>.&lt;/p>
&lt;p>Run the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/#worked-example-rotating-consecutive-panel-in-base-r">rotating-panel worked example&lt;/a> first to create &lt;code>fit_rot&lt;/code>. The next block inspects that result without fitting anything again. It shows the study units and the support for each reported effect.&lt;/p>
&lt;pre>&lt;code class="language-r">fit &amp;lt;- fit_rot
summary(fit)
cdid::glance(fit)
cells &amp;lt;- cdid::tidy(fit)
cells[, c(&amp;quot;target.id&amp;quot;, &amp;quot;role&amp;quot;, &amp;quot;estimate&amp;quot;, &amp;quot;std.error&amp;quot;, &amp;quot;available&amp;quot;,
&amp;quot;support.status&amp;quot;, &amp;quot;support.reason&amp;quot;)]
head(fit$chained$frame)
with(fit$chained$frame, table(cohort, eligible, useNA = &amp;quot;ifany&amp;quot;))
&lt;/code>&lt;/pre>
&lt;details>
&lt;summary>Console output&lt;/summary>
&lt;pre>&lt;code class="language-text">cdid chained difference-in-differences (chained IPW-GMM): cdid_MP
cdid 1.1.0.0 result built on did 2.5.1 (tested: did 2.5.1); did's MP methods tabulate the estimates below.
Chained estimators: Bellego C., Benatia D. and V. Dortet-Bernadet (2025). &amp;quot;The Chained Difference-in-Differences.&amp;quot; Journal of Econometrics 248, 105783. doi:10.1016/j.jeconom.2024.105783.
Ordinary estimators: Callaway B. and P. H. C. Sant'Anna (2021). &amp;quot;Difference-in-Differences with Multiple Time Periods.&amp;quot; Journal of Econometrics 225(2), 200-230. doi:10.1016/j.jeconom.2020.12.001.
Call:
cdid::att_gt(yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;g&amp;quot;,
xformla = NULL, data = panel_data, panel = TRUE, allow_unbalanced_panel = TRUE,
control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;ipw&amp;quot;, selection = &amp;quot;none&amp;quot;,
pt_assumption = &amp;quot;post&amp;quot;, bstrap = FALSE, cband = FALSE, frame = units)
Group-Time Average Treatment Effects:
Group Time ATT(g,t) Std. Error [95% Pointwise Conf. Band]
3 2 0.0469 0.0823 -0.1143 0.2081
3 3 0.8946 0.0922 0.7139 1.0753 *
3 4 1.2016 0.1247 0.9573 1.4460 *
3 5 1.3501 0.1573 1.0419 1.6583 *
---
Signif. codes: `*' confidence band does not cover 0
P-value for pre-test of parallel trends assumption: 0.568617658368036
Control Group: Never Treated, Anticipation Periods: 0
Estimation Method: Inverse Probability Weighting
Chained support: 4 of 4 requested cells available.
Units: 1000 in the unit table, 0 observed at all 5 dates, 1000 with at least two observed outcomes.
Observation correction: none (selection = &amp;quot;none&amp;quot;).
Parallel trends: PT-post; base_period = &amp;quot;varying&amp;quot;.
GMM weighting: optimal (two-step); covariance regularization: not applied (moment covariance well conditioned).
Inference: analytic standard errors, unit-level; pointwise intervals.
Parallel-trends pre-test: W = 0.325001, df = 1, p = 0.5686 (Wald test of the pretrend cell).
nobs ngroup ntime control.group est.method estimator n.requested n.available
1 1000 1 5 nevertreated ipw chained IPW-GMM 4 4
band.family inference clustered
1 pointwise_normal_over_supported_ids analytic FALSE
target.id role estimate std.error available support.status
1 pre(g=3,t=2) pre 0.04689223 0.08225430 TRUE supported_direct_pretrend
2 ATT(g=3,t=3) post 0.89461117 0.09218505 TRUE estimable
3 ATT(g=3,t=4) post 1.20164289 0.12468476 TRUE estimable
4 ATT(g=3,t=5) post 1.35007838 0.15725715 TRUE estimable
support.reason
1 direct auxiliary comparison 1-&amp;gt;2 with controls {Inf}
2 level anchored to the cohort reference through retained comparison rows (prop:graph)
3 level anchored to the cohort reference through retained comparison rows (prop:graph)
4 level anchored to the cohort reference through retained comparison rows (prop:graph)
id cohort weight cluster eligible n_obs frame_only
1 1 Inf 1 NA TRUE 2 FALSE
2 2 Inf 1 NA TRUE 2 FALSE
3 3 3 1 NA TRUE 2 FALSE
4 4 3 1 NA TRUE 2 FALSE
5 5 Inf 1 NA TRUE 2 FALSE
6 6 3 1 NA TRUE 2 FALSE
eligible
cohort TRUE
3 494
Inf 506
&lt;/code>&lt;/pre>
&lt;/details>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Record&lt;/th>
&lt;th>What to investigate&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>frame&lt;/code>&lt;/td>
&lt;td>The full unit table, with &lt;code>id&lt;/code>, &lt;code>cohort&lt;/code>, &lt;code>weight&lt;/code>, &lt;code>cluster&lt;/code> and &lt;code>eligible&lt;/code>. Its cohort representation uses &lt;code>Inf&lt;/code> for never treated. &lt;code>eligible&lt;/code> marks repeated-outcome units, not units guaranteed to support every pair.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>support_status&lt;/code>, &lt;code>support_reason&lt;/code>, &lt;code>support&lt;/code>, &lt;code>support_ledger&lt;/code>&lt;/td>
&lt;td>Which requested cells the retained catalog recovers and the reasons for unavailable cells. &lt;code>tidy()&lt;/code> gives a convenient cell-level table.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>selection&lt;/code> and &lt;code>selection$models&lt;/code>&lt;/td>
&lt;td>The observation adjustment and its active model counts. Counts such as &lt;code>n_selection_fits&lt;/code> are nested in &lt;code>models&lt;/code> when that route fits them. They are not universal top-level fields.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>nuisance_diagnostics&lt;/code> and &lt;code>outcome_design&lt;/code>&lt;/td>
&lt;td>Active treatment, observation, counterfactual and imputation designs and fit diagnostics. Their detailed nesting depends on the route. Inspect the relevant record rather than assuming every method fits the same models.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>pt&lt;/code>&lt;/td>
&lt;td>The maintained parallel-trends choice. Under PT-all, &lt;code>pt$by_cohort&lt;/code> gives reference dates and the represented added restrictions, including no-extra cases.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>covariance_handling&lt;/code>&lt;/td>
&lt;td>The GMM weighting and whether covariance regularization was used, with its reason and conditioning record.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>inference&lt;/code> and &lt;code>pretest&lt;/code>&lt;/td>
&lt;td>What uncertainty and pretrend tests were actually computed, with draw, cluster and availability records.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The example uses &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>, so it fits no observation model. To inspect fitted observation-model counts, first run the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#example-observation-that-depends-on-a-covariate">missing-outcomes example&lt;/a>, which creates &lt;code>fit_weighting&lt;/code>, then inspect:&lt;/p>
&lt;pre>&lt;code class="language-r">str(fit_weighting$chained$selection$models, max.level = 1)
&lt;/code>&lt;/pre>
&lt;details>
&lt;summary>Console output&lt;/summary>
&lt;pre>&lt;code class="language-text">List of 10
$ n_selection_fits : int 12
$ n_selection_cells : int 12
$ n_selection_blocks : int 12
$ n_selection_parameters: int 24
$ n_regression_fits : int 1
$ n_regression_blocks : int 15
$ n_local_intercepts : int 15
$ n_shared_slopes : int 1
$ n_supports : int 30
$ n_treatment_fits : int 15
&lt;/code>&lt;/pre>
&lt;/details>
&lt;p>With inference computed, the influence-function matrix retains one row for every study unit, including units with no observed change, and carries the uncertainty of the active models and rates. Do not subset it to repeat observers when reconstructing uncertainty. With &lt;code>compute_inffunc = FALSE&lt;/code>, no influence-function matrix or standard errors are returned.&lt;/p>
&lt;h2 id="interpret-findings-without-overstating-them">Interpret findings without overstating them&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Finding&lt;/th>
&lt;th>What it says and what it does not establish&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Dropout, intermittent gaps or changing observed covariates&lt;/td>
&lt;td>Observable features that help assess the design and choose scientifically justified models. They do not prove mean missing-at-random or parallel trends.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Observed-pair units differ in outcome levels from the study population&lt;/td>
&lt;td>This can matter for level comparisons. Chained DiD allows observation to depend on a unit fixed effect when the relevant mean changes remain representative. Differencing alone does not make this assumption true.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>A cell is unavailable in &lt;code>tidy(fit)&lt;/code>&lt;/td>
&lt;td>With the chosen comparisons and assumptions, this fit cannot recover the effect.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>A required logit is separated, or a model lacks rank or prediction support&lt;/td>
&lt;td>Check which covariate levels appear in the fitting and prediction samples. In a logit, check whether predictors perfectly separate the two outcomes.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Moment covariance is singular or regularized&lt;/td>
&lt;td>Comparisons share sampling variation. Covariance regularization stabilizes their weighting and cannot create target identification. See the two &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/#covariance-singularity-versus-parameter-identification">analytical examples&lt;/a>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Standard errors or a pretrend p value are reported&lt;/td>
&lt;td>The computation was available. Valid inference still needs its large-sample assumptions, and few independent clusters can make the approximation unreliable. A nonrejection does not establish parallel trends.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Within a cohort, mean representativeness equates the population expected outcome change for units observed in a pair with the cohort&amp;rsquo;s population expected change over that pair. It requires neither identical unit-level changes nor exact sample-mean equality. Missingness can depend on unit fixed effects while this holds. If those fixed effects predict trends or treatment-effect heterogeneity, the condition can fail. The conditional version additionally needs a scientifically sufficient conditioning set, appropriate models and the positivity or prediction-support conditions of the chosen adjustment. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#the-assumption-about-missing-outcomes">Handling missing outcomes&lt;/a> states these conditions.&lt;/p>
&lt;p>Continue with &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>, &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a> or &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results reference&lt;/a>. For refused fits, see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>.&lt;/p>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p></description></item><item><title>Monte Carlo &amp; Scaling Validation: Cross-Pair Chaining, `PT-ctrl`, and Within-Unit GMM in `cdid`</title><link>https://www.davidbenatia.com/tools/cdid/guide/outputs/cross_pair_monte_carlo_results/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/outputs/cross_pair_monte_carlo_results/</guid><description>&lt;p>These results come from the cross-pair source revision &lt;code>5b1a614&lt;/code>. The simulations used &lt;code>cdid&lt;/code> (1.2.1.0), &lt;code>did&lt;/code> 2.5.1, and &lt;code>DRDID&lt;/code> 1.4.0 under R version 4.5.2 (2025-10-31) (&lt;code>seed = 20261111&lt;/code>, &lt;code>200&lt;/code> replications per design).&lt;/p>
&lt;h2 id="executive-summary-of-findings">Executive Summary of Findings&lt;/h2>
&lt;ol>
&lt;li>&lt;strong>Exact Numerical Equivalence ($\le 1.56e-13$):&lt;/strong> Across all 200 replications of cohort-balanced and wave-gap short-window designs (Designs 1, 2, 3, and 5), &lt;code>att_gt(..., cross_pair = TRUE, pt_assumption = &amp;quot;ctrl&amp;quot;, gmm_weighting = &amp;quot;within&amp;quot;, base_period = &amp;quot;universal&amp;quot;)&lt;/code> matches both unit-fixed-effect and cohort-fixed-effect stacked target-slice OLS to machine precision (max absolute difference &lt;code>1.563e-13&lt;/code>). Under non-monotone intermittent post-treatment dropout (Design 4), &lt;code>att_gt()&lt;/code> pools $O(T^2)$ cohort-pair differences rather than $2^T$ missingness strata (max finite-sample difference &lt;code>2.563e-02&lt;/code> vs unit-FE slice OLS) while eliminating cohort-FE composition bias.&lt;/li>
&lt;li>&lt;strong>Optimal Two-Step GMM Efficiency:&lt;/strong> When errors depart from homoskedastic random walks across cohorts (Design 2), &lt;code>gmm_weighting = &amp;quot;optimal&amp;quot;&lt;/code> achieves strictly lower empirical SD and RMSE than &lt;code>within&lt;/code>-weighted slice regression.&lt;/li>
&lt;li>&lt;strong>Pre-Reference Trend Robustness (&lt;code>PT-post&lt;/code> vs &lt;code>PT-ctrl&lt;/code>):&lt;/strong> When a later-treated control cohort experiences a trend shift prior to the target cohort&amp;rsquo;s reference period (Design 3), stacked slice OLS and &lt;code>PT-ctrl&lt;/code> are biased because they pool control pre-trends before the reference period, whereas &lt;code>cdid&lt;/code> under &lt;code>pt_assumption = &amp;quot;post&amp;quot;&lt;/code> remains unbiased with nominal 95% coverage.&lt;/li>
&lt;li>&lt;strong>Selective-Attrition Robustness (Unit Differences vs Cohort FE Levels):&lt;/strong> When post-treatment attrition depends on persistent unit fixed effects $\alpha_i$ (Design 4), cohort-FE slice OLS suffers severe composition bias, whereas &lt;code>cdid&lt;/code> removes $\alpha_i$ via within-unit differencing and remains unbiased with nominal 95% coverage.&lt;/li>
&lt;li>&lt;strong>Biennial Wave Gaps &amp;amp; Non-Overlapping Cross-Pair Windows with Covariates:&lt;/strong> Across biennial gaps (Design 5), &lt;code>cdid&lt;/code> estimates seamlessly without dropping post-transition waves. When target and control cohorts are never observed on a common date pair, control pair observation is partial ($r_{4,2,3} = 0.5$), and covariates $X_i$ drive both treatment timing and outcome trends (Design 6), same-pair &lt;code>att_gt(..., cross_pair = FALSE)&lt;/code> returns &lt;code>NA&lt;/code>, &lt;code>did::att_gt(..., allow_unbalanced_panel = TRUE)&lt;/code> falls back to repeated cross-sections across distinct cohorts (&lt;code>-4.022&lt;/code> bias), unadjusted slice OLS suffers covariate-trend bias (&lt;code>+1.985&lt;/code>), and both doubly robust and inverse-rate-calibrated IPW &lt;code>att_gt(..., xformla = ~ x, cross_pair = TRUE)&lt;/code> are unbiased with nominal 95% coverage.&lt;/li>
&lt;li>&lt;strong>Conditional-MTAR Selective Observation &amp;amp; Selection Double Robustness (&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>):&lt;/strong> When panel entry ($A_g \subset F_g$) and pair retention depend on covariates $X_i$ alongside heterogeneous treatment effects $\tau(X_i)$ on disjoint windows (Design 7), naive &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code> suffers severe selection bias (&lt;code>+0.640&lt;/code>) even with &lt;code>xformla = ~ x&lt;/code>, whereas &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code> across &lt;code>selection_est_method = &amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>&amp;quot;imputation&amp;quot;&lt;/code>, and &lt;code>&amp;quot;dr&amp;quot;&lt;/code> (augmented, which remains unbiased even when &lt;code>imputation_pooling = &amp;quot;within_cohort&amp;quot;&lt;/code> is misspecified) recovers the full study-population &lt;code>ATT(3, 4)&lt;/code> with nominal ~95% analytical coverage.&lt;/li>
&lt;/ol>
&lt;h2 id="design-1-staggered-short-windows--homoskedastic-iid-errors">Design 1: Staggered Short Windows — Homoskedastic i.i.d. Errors&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Target parameter:&lt;/strong> &lt;code>ATT(2005, 2009)&lt;/code> = &lt;code>5.00&lt;/code> ($N = 900$ units across 6 cohorts &lt;code>2005..2010&lt;/code>, 200 replications).&lt;/li>
&lt;li>&lt;strong>Max numerical discrepancy &lt;code>|cdid(within, PT-ctrl) - Stacked slice OLS (unit FE)|&lt;/code>:&lt;/strong> &lt;code>1.075e-13&lt;/code>.&lt;/li>
&lt;/ul>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Estimator&lt;/th>
&lt;th style="text-align:right">Avail (%)&lt;/th>
&lt;th style="text-align:right">Bias&lt;/th>
&lt;th style="text-align:right">Empirical SD&lt;/th>
&lt;th style="text-align:right">Mean Analytical SE&lt;/th>
&lt;th style="text-align:right">RMSE&lt;/th>
&lt;th style="text-align:right">95% Coverage&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Stacked slice OLS (cohort FE)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.001&lt;/td>
&lt;td style="text-align:right">0.163&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">0.163&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Stacked slice OLS (unit FE)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.001&lt;/td>
&lt;td style="text-align:right">0.163&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">0.163&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (within, PT-ctrl, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.001&lt;/td>
&lt;td style="text-align:right">0.163&lt;/td>
&lt;td style="text-align:right">0.164&lt;/td>
&lt;td style="text-align:right">0.163&lt;/td>
&lt;td style="text-align:right">0.975&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-ctrl, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.003&lt;/td>
&lt;td style="text-align:right">0.163&lt;/td>
&lt;td style="text-align:right">0.163&lt;/td>
&lt;td style="text-align:right">0.163&lt;/td>
&lt;td style="text-align:right">0.970&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-post, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.002&lt;/td>
&lt;td style="text-align:right">0.162&lt;/td>
&lt;td style="text-align:right">0.163&lt;/td>
&lt;td style="text-align:right">0.162&lt;/td>
&lt;td style="text-align:right">0.970&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-post, same-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.002&lt;/td>
&lt;td style="text-align:right">0.162&lt;/td>
&lt;td style="text-align:right">0.163&lt;/td>
&lt;td style="text-align:right">0.162&lt;/td>
&lt;td style="text-align:right">0.970&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-all, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.001&lt;/td>
&lt;td style="text-align:right">0.153&lt;/td>
&lt;td style="text-align:right">0.148&lt;/td>
&lt;td style="text-align:right">0.152&lt;/td>
&lt;td style="text-align:right">0.950&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>did::att_gt (CS 2021, NYT)&lt;/td>
&lt;td style="text-align:right">0%&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="design-2-staggered-short-windows--heteroskedastic-random-walk-errors">Design 2: Staggered Short Windows — Heteroskedastic Random-Walk Errors&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Target parameter:&lt;/strong> &lt;code>ATT(2005, 2009)&lt;/code> = &lt;code>5.00&lt;/code> ($N = 900$ units across 6 cohorts &lt;code>2005..2010&lt;/code>, 200 replications).&lt;/li>
&lt;li>&lt;strong>Max numerical discrepancy &lt;code>|cdid(within, PT-ctrl) - Stacked slice OLS (unit FE)|&lt;/code>:&lt;/strong> &lt;code>1.066e-13&lt;/code>.&lt;/li>
&lt;/ul>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Estimator&lt;/th>
&lt;th style="text-align:right">Avail (%)&lt;/th>
&lt;th style="text-align:right">Bias&lt;/th>
&lt;th style="text-align:right">Empirical SD&lt;/th>
&lt;th style="text-align:right">Mean Analytical SE&lt;/th>
&lt;th style="text-align:right">RMSE&lt;/th>
&lt;th style="text-align:right">95% Coverage&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Stacked slice OLS (cohort FE)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.013&lt;/td>
&lt;td style="text-align:right">0.213&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">0.213&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Stacked slice OLS (unit FE)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.013&lt;/td>
&lt;td style="text-align:right">0.213&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">0.213&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (within, PT-ctrl, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.013&lt;/td>
&lt;td style="text-align:right">0.213&lt;/td>
&lt;td style="text-align:right">0.207&lt;/td>
&lt;td style="text-align:right">0.213&lt;/td>
&lt;td style="text-align:right">0.960&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-ctrl, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.008&lt;/td>
&lt;td style="text-align:right">0.173&lt;/td>
&lt;td style="text-align:right">0.171&lt;/td>
&lt;td style="text-align:right">0.172&lt;/td>
&lt;td style="text-align:right">0.960&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-post, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.009&lt;/td>
&lt;td style="text-align:right">0.172&lt;/td>
&lt;td style="text-align:right">0.171&lt;/td>
&lt;td style="text-align:right">0.172&lt;/td>
&lt;td style="text-align:right">0.960&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-post, same-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.009&lt;/td>
&lt;td style="text-align:right">0.172&lt;/td>
&lt;td style="text-align:right">0.171&lt;/td>
&lt;td style="text-align:right">0.172&lt;/td>
&lt;td style="text-align:right">0.960&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-all, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.008&lt;/td>
&lt;td style="text-align:right">0.169&lt;/td>
&lt;td style="text-align:right">0.168&lt;/td>
&lt;td style="text-align:right">0.169&lt;/td>
&lt;td style="text-align:right">0.955&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>did::att_gt (CS 2021, NYT)&lt;/td>
&lt;td style="text-align:right">0%&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="design-3-control-cohort-2006-shifted-in-pre-reference-years-20022003-only">Design 3: Control Cohort 2006 Shifted in Pre-Reference Years (2002–2003 Only)&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Target parameter:&lt;/strong> &lt;code>ATT(2005, 2009)&lt;/code> = &lt;code>5.00&lt;/code> ($N = 900$ units across 6 cohorts &lt;code>2005..2010&lt;/code>, 200 replications).&lt;/li>
&lt;li>&lt;strong>Max numerical discrepancy &lt;code>|cdid(within, PT-ctrl) - Stacked slice OLS (unit FE)|&lt;/code>:&lt;/strong> &lt;code>1.075e-13&lt;/code>.&lt;/li>
&lt;/ul>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Estimator&lt;/th>
&lt;th style="text-align:right">Avail (%)&lt;/th>
&lt;th style="text-align:right">Bias&lt;/th>
&lt;th style="text-align:right">Empirical SD&lt;/th>
&lt;th style="text-align:right">Mean Analytical SE&lt;/th>
&lt;th style="text-align:right">RMSE&lt;/th>
&lt;th style="text-align:right">95% Coverage&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Stacked slice OLS (cohort FE)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.094&lt;/td>
&lt;td style="text-align:right">0.154&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">0.180&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Stacked slice OLS (unit FE)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.094&lt;/td>
&lt;td style="text-align:right">0.154&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">0.180&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (within, PT-ctrl, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.094&lt;/td>
&lt;td style="text-align:right">0.154&lt;/td>
&lt;td style="text-align:right">0.164&lt;/td>
&lt;td style="text-align:right">0.180&lt;/td>
&lt;td style="text-align:right">0.925&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-ctrl, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.091&lt;/td>
&lt;td style="text-align:right">0.158&lt;/td>
&lt;td style="text-align:right">0.163&lt;/td>
&lt;td style="text-align:right">0.182&lt;/td>
&lt;td style="text-align:right">0.925&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-post, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.029&lt;/td>
&lt;td style="text-align:right">0.154&lt;/td>
&lt;td style="text-align:right">0.163&lt;/td>
&lt;td style="text-align:right">0.156&lt;/td>
&lt;td style="text-align:right">0.965&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-post, same-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.029&lt;/td>
&lt;td style="text-align:right">0.154&lt;/td>
&lt;td style="text-align:right">0.163&lt;/td>
&lt;td style="text-align:right">0.156&lt;/td>
&lt;td style="text-align:right">0.965&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-all, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.756&lt;/td>
&lt;td style="text-align:right">0.170&lt;/td>
&lt;td style="text-align:right">0.148&lt;/td>
&lt;td style="text-align:right">0.774&lt;/td>
&lt;td style="text-align:right">0.000&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>did::att_gt (CS 2021, NYT)&lt;/td>
&lt;td style="text-align:right">0%&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="design-4-selective-post-treatment-attrition-low-alpha-units-drop-out">Design 4: Selective Post-Treatment Attrition (Low-alpha Units Drop Out)&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Target parameter:&lt;/strong> &lt;code>ATT(2005, 2009)&lt;/code> = &lt;code>5.00&lt;/code> ($N = 900$ units across 6 cohorts &lt;code>2005..2010&lt;/code>, 200 replications).&lt;/li>
&lt;li>&lt;strong>Max numerical discrepancy &lt;code>|cdid(within, PT-ctrl) - Stacked slice OLS (unit FE)|&lt;/code>:&lt;/strong> &lt;code>2.563e-02&lt;/code>.&lt;/li>
&lt;/ul>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Estimator&lt;/th>
&lt;th style="text-align:right">Avail (%)&lt;/th>
&lt;th style="text-align:right">Bias&lt;/th>
&lt;th style="text-align:right">Empirical SD&lt;/th>
&lt;th style="text-align:right">Mean Analytical SE&lt;/th>
&lt;th style="text-align:right">RMSE&lt;/th>
&lt;th style="text-align:right">95% Coverage&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Stacked slice OLS (cohort FE)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.468&lt;/td>
&lt;td style="text-align:right">0.195&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">0.507&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Stacked slice OLS (unit FE)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.009&lt;/td>
&lt;td style="text-align:right">0.168&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">0.168&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (within, PT-ctrl, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.008&lt;/td>
&lt;td style="text-align:right">0.169&lt;/td>
&lt;td style="text-align:right">0.173&lt;/td>
&lt;td style="text-align:right">0.168&lt;/td>
&lt;td style="text-align:right">0.950&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-ctrl, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.013&lt;/td>
&lt;td style="text-align:right">0.178&lt;/td>
&lt;td style="text-align:right">0.163&lt;/td>
&lt;td style="text-align:right">0.178&lt;/td>
&lt;td style="text-align:right">0.930&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-post, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.013&lt;/td>
&lt;td style="text-align:right">0.177&lt;/td>
&lt;td style="text-align:right">0.163&lt;/td>
&lt;td style="text-align:right">0.177&lt;/td>
&lt;td style="text-align:right">0.925&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-post, same-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.008&lt;/td>
&lt;td style="text-align:right">0.180&lt;/td>
&lt;td style="text-align:right">0.176&lt;/td>
&lt;td style="text-align:right">0.180&lt;/td>
&lt;td style="text-align:right">0.960&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-all, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.011&lt;/td>
&lt;td style="text-align:right">0.158&lt;/td>
&lt;td style="text-align:right">0.152&lt;/td>
&lt;td style="text-align:right">0.158&lt;/td>
&lt;td style="text-align:right">0.960&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>did::att_gt (CS 2021, NYT)&lt;/td>
&lt;td style="text-align:right">0%&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="design-5-biennial-wave-gaps-2007--2009-removed-target-att2005-2008">Design 5: Biennial Wave Gaps (2007 &amp;amp; 2009 Removed, Target ATT(2005, 2008))&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Target parameter:&lt;/strong> &lt;code>ATT(2005, 2008)&lt;/code> = &lt;code>4.00&lt;/code> ($N = 900$ units across 6 cohorts &lt;code>2005..2010&lt;/code>, 200 replications).&lt;/li>
&lt;li>&lt;strong>Max numerical discrepancy &lt;code>|cdid(within, PT-ctrl) - Stacked slice OLS (unit FE)|&lt;/code>:&lt;/strong> &lt;code>1.563e-13&lt;/code>.&lt;/li>
&lt;/ul>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Estimator&lt;/th>
&lt;th style="text-align:right">Avail (%)&lt;/th>
&lt;th style="text-align:right">Bias&lt;/th>
&lt;th style="text-align:right">Empirical SD&lt;/th>
&lt;th style="text-align:right">Mean Analytical SE&lt;/th>
&lt;th style="text-align:right">RMSE&lt;/th>
&lt;th style="text-align:right">95% Coverage&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Stacked slice OLS (cohort FE)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.011&lt;/td>
&lt;td style="text-align:right">0.148&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">0.148&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Stacked slice OLS (unit FE)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.011&lt;/td>
&lt;td style="text-align:right">0.148&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">0.148&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (within, PT-ctrl, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.011&lt;/td>
&lt;td style="text-align:right">0.148&lt;/td>
&lt;td style="text-align:right">0.152&lt;/td>
&lt;td style="text-align:right">0.148&lt;/td>
&lt;td style="text-align:right">0.945&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-ctrl, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.010&lt;/td>
&lt;td style="text-align:right">0.148&lt;/td>
&lt;td style="text-align:right">0.151&lt;/td>
&lt;td style="text-align:right">0.148&lt;/td>
&lt;td style="text-align:right">0.955&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-post, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.011&lt;/td>
&lt;td style="text-align:right">0.148&lt;/td>
&lt;td style="text-align:right">0.151&lt;/td>
&lt;td style="text-align:right">0.148&lt;/td>
&lt;td style="text-align:right">0.950&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-post, same-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.011&lt;/td>
&lt;td style="text-align:right">0.148&lt;/td>
&lt;td style="text-align:right">0.151&lt;/td>
&lt;td style="text-align:right">0.148&lt;/td>
&lt;td style="text-align:right">0.950&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (optimal, PT-all, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.006&lt;/td>
&lt;td style="text-align:right">0.128&lt;/td>
&lt;td style="text-align:right">0.134&lt;/td>
&lt;td style="text-align:right">0.127&lt;/td>
&lt;td style="text-align:right">0.960&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>did::att_gt (CS 2021, NYT)&lt;/td>
&lt;td style="text-align:right">0%&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="design-6-disjoint-cross-pair-observation-windows-with-covariate-confounding--partial-pair-observation">Design 6: Disjoint Cross-Pair Observation Windows with Covariate Confounding &amp;amp; Partial Pair Observation&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Target parameter:&lt;/strong> &lt;code>ATT(3, 4)&lt;/code> = &lt;code>4.00&lt;/code> ($N = 720$ units across cohorts &lt;code>{0, 3, 4, 5}&lt;/code>, where &lt;code>G=3&lt;/code> is observed at &lt;code>{1, 2, 4}&lt;/code>, half of &lt;code>G=4&lt;/code> at &lt;code>{2, 3}&lt;/code> and half at &lt;code>{1, 2}&lt;/code> so $r_{4,2,3} = 0.5$, &lt;code>G=5&lt;/code> at &lt;code>{3, 4}&lt;/code>, and &lt;code>G=0&lt;/code> at &lt;code>{1, 2}&lt;/code>; 200 replications).&lt;/li>
&lt;li>&lt;strong>Key property:&lt;/strong> Zero control units are observed at both dates &lt;code>(2, 4)&lt;/code>, so same-pair estimators return &lt;code>NA&lt;/code>, while covariate $X_i$ shifts both cohort assignment and untreated trend slopes under partial within-cohort pair observation.&lt;/li>
&lt;/ul>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Estimator&lt;/th>
&lt;th style="text-align:right">Avail (%)&lt;/th>
&lt;th style="text-align:right">Bias&lt;/th>
&lt;th style="text-align:right">Empirical SD&lt;/th>
&lt;th style="text-align:right">Mean Analytical SE&lt;/th>
&lt;th style="text-align:right">RMSE&lt;/th>
&lt;th style="text-align:right">95% Coverage&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Stacked slice OLS (cohort FE, unadjusted)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">1.985&lt;/td>
&lt;td style="text-align:right">0.366&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">2.018&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (unadjusted, within, PT-ctrl, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">1.875&lt;/td>
&lt;td style="text-align:right">0.222&lt;/td>
&lt;td style="text-align:right">0.217&lt;/td>
&lt;td style="text-align:right">1.888&lt;/td>
&lt;td style="text-align:right">0.000&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (xformla = ~x, DR, within, PT-ctrl, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.027&lt;/td>
&lt;td style="text-align:right">0.193&lt;/td>
&lt;td style="text-align:right">0.190&lt;/td>
&lt;td style="text-align:right">0.194&lt;/td>
&lt;td style="text-align:right">0.940&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (xformla = ~x, DR, optimal, PT-ctrl, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.027&lt;/td>
&lt;td style="text-align:right">0.192&lt;/td>
&lt;td style="text-align:right">0.190&lt;/td>
&lt;td style="text-align:right">0.194&lt;/td>
&lt;td style="text-align:right">0.940&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (xformla = ~x, DR, optimal, PT-post, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.027&lt;/td>
&lt;td style="text-align:right">0.193&lt;/td>
&lt;td style="text-align:right">0.190&lt;/td>
&lt;td style="text-align:right">0.194&lt;/td>
&lt;td style="text-align:right">0.940&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (xformla = ~x, IPW, optimal, PT-post, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.042&lt;/td>
&lt;td style="text-align:right">0.275&lt;/td>
&lt;td style="text-align:right">0.249&lt;/td>
&lt;td style="text-align:right">0.277&lt;/td>
&lt;td style="text-align:right">0.930&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (xformla = ~x, DR, optimal, PT-post, same-pair)&lt;/td>
&lt;td style="text-align:right">0%&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>did::att_gt (xformla = ~x, DR, CS 2021)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-4.022&lt;/td>
&lt;td style="text-align:right">0.157&lt;/td>
&lt;td style="text-align:right">0.156&lt;/td>
&lt;td style="text-align:right">4.025&lt;/td>
&lt;td style="text-align:right">0.000&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="design-7-disjoint-cross-pair-windows-with-covariate-dependent-selective-observation-selection--conditional_mtar">Design 7: Disjoint Cross-Pair Windows with Covariate-Dependent Selective Observation (&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>)&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Target parameter:&lt;/strong> Full study-population &lt;code>ATT_F(3, 4)&lt;/code> = &lt;code>3.00&lt;/code> ($N = 1{,}000$ frame units across cohorts &lt;code>{0, 3, 4, 5}&lt;/code> including frame-only and singleton dropouts, heterogeneous treatment effect $\tau(X_i) = 3.0 + 2.0(X_i - 0.4)$, and logit selection probabilities driven by $X_i$; 200 replications).&lt;/li>
&lt;li>&lt;strong>Key property:&lt;/strong> High-$X_i$ target units are far more likely to remain in the repeat-observed panel $A_3$ and have larger treatment effects, so &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code> uses the selected changes and exhibits substantial bias relative to &lt;code>ATT_F(3, 4)&lt;/code>, while &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code> (&lt;code>ipw&lt;/code>, &lt;code>imputation&lt;/code>, and &lt;code>dr&lt;/code> augmented) transports back to $F_3$ with full study-population influence-function inference.&lt;/li>
&lt;/ul>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Estimator&lt;/th>
&lt;th style="text-align:right">Avail (%)&lt;/th>
&lt;th style="text-align:right">Bias&lt;/th>
&lt;th style="text-align:right">Empirical SD&lt;/th>
&lt;th style="text-align:right">Mean Analytical SE&lt;/th>
&lt;th style="text-align:right">RMSE&lt;/th>
&lt;th style="text-align:right">95% Coverage&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>cdid (selection = &amp;lsquo;none&amp;rsquo;, DR, xformla = ~x, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">0.640&lt;/td>
&lt;td style="text-align:right">0.216&lt;/td>
&lt;td style="text-align:right">0.198&lt;/td>
&lt;td style="text-align:right">0.675&lt;/td>
&lt;td style="text-align:right">0.080&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (conditional_mtar, sel = &amp;lsquo;ipw&amp;rsquo;, IPW, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.014&lt;/td>
&lt;td style="text-align:right">0.308&lt;/td>
&lt;td style="text-align:right">0.261&lt;/td>
&lt;td style="text-align:right">0.308&lt;/td>
&lt;td style="text-align:right">0.905&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (conditional_mtar, sel = &amp;lsquo;ipw&amp;rsquo;, OR, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.008&lt;/td>
&lt;td style="text-align:right">0.292&lt;/td>
&lt;td style="text-align:right">0.250&lt;/td>
&lt;td style="text-align:right">0.292&lt;/td>
&lt;td style="text-align:right">0.900&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (conditional_mtar, sel = &amp;lsquo;ipw&amp;rsquo;, DR, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.009&lt;/td>
&lt;td style="text-align:right">0.295&lt;/td>
&lt;td style="text-align:right">0.249&lt;/td>
&lt;td style="text-align:right">0.294&lt;/td>
&lt;td style="text-align:right">0.910&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (conditional_mtar, sel = &amp;lsquo;imputation&amp;rsquo; [sep], DR, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.014&lt;/td>
&lt;td style="text-align:right">0.193&lt;/td>
&lt;td style="text-align:right">0.180&lt;/td>
&lt;td style="text-align:right">0.193&lt;/td>
&lt;td style="text-align:right">0.945&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (conditional_mtar, sel = &amp;lsquo;dr&amp;rsquo; [augmented], DR, cross-pair)&lt;/td>
&lt;td style="text-align:right">100%&lt;/td>
&lt;td style="text-align:right">-0.016&lt;/td>
&lt;td style="text-align:right">0.202&lt;/td>
&lt;td style="text-align:right">0.185&lt;/td>
&lt;td style="text-align:right">0.202&lt;/td>
&lt;td style="text-align:right">0.935&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cdid (conditional_mtar, sel = &amp;lsquo;dr&amp;rsquo; [augmented], DR, same-pair)&lt;/td>
&lt;td style="text-align:right">0%&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;td style="text-align:right">n/a&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="runtime-scaling-benchmarks-6-cohorts-10-calendar-periods">Runtime Scaling Benchmarks (6 Cohorts, 10 Calendar Periods)&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align:right">Physical Units ($N$)&lt;/th>
&lt;th style="text-align:right">Panel Rows&lt;/th>
&lt;th style="text-align:right">Same-Pair Opt (s)&lt;/th>
&lt;th style="text-align:right">Cross-Pair Within (s)&lt;/th>
&lt;th style="text-align:right">Cross-Pair DR Opt (s)&lt;/th>
&lt;th style="text-align:right">Cross-Pair MTAR IPW (s)&lt;/th>
&lt;th style="text-align:right">Cross-Pair MTAR Imp (s)&lt;/th>
&lt;th style="text-align:right">Cross-Pair MTAR Aug DR (s)&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align:right">900&lt;/td>
&lt;td style="text-align:right">6750&lt;/td>
&lt;td style="text-align:right">0.398&lt;/td>
&lt;td style="text-align:right">0.081&lt;/td>
&lt;td style="text-align:right">0.084&lt;/td>
&lt;td style="text-align:right">0.386&lt;/td>
&lt;td style="text-align:right">0.201&lt;/td>
&lt;td style="text-align:right">0.411&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:right">3000&lt;/td>
&lt;td style="text-align:right">22500&lt;/td>
&lt;td style="text-align:right">0.703&lt;/td>
&lt;td style="text-align:right">0.102&lt;/td>
&lt;td style="text-align:right">0.121&lt;/td>
&lt;td style="text-align:right">0.519&lt;/td>
&lt;td style="text-align:right">0.255&lt;/td>
&lt;td style="text-align:right">0.667&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:right">9000&lt;/td>
&lt;td style="text-align:right">67500&lt;/td>
&lt;td style="text-align:right">1.759&lt;/td>
&lt;td style="text-align:right">0.191&lt;/td>
&lt;td style="text-align:right">0.226&lt;/td>
&lt;td style="text-align:right">1.236&lt;/td>
&lt;td style="text-align:right">0.494&lt;/td>
&lt;td style="text-align:right">1.091&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:right">18000&lt;/td>
&lt;td style="text-align:right">135000&lt;/td>
&lt;td style="text-align:right">3.293&lt;/td>
&lt;td style="text-align:right">0.333&lt;/td>
&lt;td style="text-align:right">0.388&lt;/td>
&lt;td style="text-align:right">1.831&lt;/td>
&lt;td style="text-align:right">0.794&lt;/td>
&lt;td style="text-align:right">1.928&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table></description></item><item><title>Moving from did</title><link>https://www.davidbenatia.com/tools/cdid/guide/from-did/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/from-did/</guid><description>&lt;p>If you already use &lt;code>did&lt;/code>, most of &lt;code>cdid&lt;/code> will look familiar. This page explains what stays the same, how the two estimation modes differ, how each package treats an incomplete panel and when chained estimates should agree with those of &lt;code>did&lt;/code>.&lt;/p>
&lt;h2 id="what-stays-the-same">What stays the same&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Functions.&lt;/strong> &lt;code>att_gt()&lt;/code>, &lt;code>aggte()&lt;/code>, &lt;code>ggdid()&lt;/code>, &lt;code>tidy()&lt;/code>, &lt;code>glance()&lt;/code> and &lt;code>conditional_did_pretest()&lt;/code>. The generics &lt;code>ggdid()&lt;/code>, &lt;code>tidy()&lt;/code> and &lt;code>glance()&lt;/code> are exported unchanged from &lt;code>did&lt;/code>; &lt;code>cdid&lt;/code> registers methods only for its own result classes, so &lt;code>did&lt;/code> results keep &lt;code>did&lt;/code>&amp;rsquo;s methods.&lt;/li>
&lt;li>&lt;strong>Arguments.&lt;/strong> &lt;code>att_gt()&lt;/code> retains the upstream argument names and order, with &lt;code>allow_unbalanced_panel = NULL&lt;/code> as a mode-dependent sentinel in place of &lt;code>did&lt;/code>&amp;rsquo;s &lt;code>FALSE&lt;/code> default. &lt;code>aggte()&lt;/code> keeps the signature of &lt;code>did&lt;/code> 2.5.1. &lt;code>conditional_did_pretest()&lt;/code> retains the 19 upstream arguments in order, with the same unbalanced-panel sentinel. The arguments that only chained mode uses come after &lt;code>...&lt;/code> in &lt;code>att_gt()&lt;/code> and after &lt;code>did&lt;/code>&amp;rsquo;s arguments in &lt;code>conditional_did_pretest()&lt;/code>.&lt;/li>
&lt;li>&lt;strong>Defaults.&lt;/strong> &lt;code>att_gt()&lt;/code> uses &lt;code>est_method = &amp;quot;dr&amp;quot;&lt;/code>, and &lt;code>conditional_did_pretest()&lt;/code> uses &lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code>, as in &lt;code>did&lt;/code>. Units never treated have &lt;code>gname&lt;/code> equal to 0.&lt;/li>
&lt;li>&lt;strong>Results.&lt;/strong> Chained results inherit &lt;code>did&lt;/code>&amp;rsquo;s classes (&lt;code>MP&lt;/code> for &lt;code>att_gt()&lt;/code>, &lt;code>AGGTEobj&lt;/code> for &lt;code>aggte()&lt;/code>), and &lt;code>did&lt;/code>&amp;rsquo;s own methods tabulate and plot the estimates. &lt;code>cdid&lt;/code> adds a short chained record to the display and a &lt;code>chained&lt;/code> element to the object.&lt;/li>
&lt;/ul>
&lt;p>Qualify calls as &lt;code>cdid::att_gt()&lt;/code> and &lt;code>cdid::aggte()&lt;/code>. A later &lt;code>library(did)&lt;/code> then cannot change which function runs.&lt;/p>
&lt;h2 id="two-estimation-modes">Two estimation modes&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;code>mode&lt;/code>&lt;/th>
&lt;th>When it applies&lt;/th>
&lt;th>What runs&lt;/th>
&lt;th>Returned object&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>NULL&lt;/code> (default)&lt;/td>
&lt;td>resolved from &lt;code>panel&lt;/code>&lt;/td>
&lt;td>chained mode when &lt;code>panel = TRUE&lt;/code>, ordinary mode when &lt;code>panel = FALSE&lt;/code>&lt;/td>
&lt;td>as below&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;chained&amp;quot;&lt;/code>&lt;/td>
&lt;td>panel data&lt;/td>
&lt;td>chained DiD&lt;/td>
&lt;td>&lt;code>cdid_MP&lt;/code>, which inherits &lt;code>MP&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;ordinary&amp;quot;&lt;/code>&lt;/td>
&lt;td>any data &lt;code>did&lt;/code> accepts&lt;/td>
&lt;td>&lt;code>did::att_gt()&lt;/code>, unchanged&lt;/td>
&lt;td>&lt;code>did&lt;/code>&amp;rsquo;s &lt;code>MP&lt;/code>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>In ordinary mode, &lt;code>cdid&lt;/code> forwards only the arguments you supplied, so &lt;code>did&lt;/code> applies its own defaults. Each argument is evaluated once, in your environment, when &lt;code>did&lt;/code> needs it. The one exception is &lt;code>panel&lt;/code>: with &lt;code>mode = NULL&lt;/code>, &lt;code>cdid&lt;/code> evaluates it first to choose the mode. The chained arguments are neither evaluated nor forwarded. &lt;code>allow_unbalanced_panel = NULL&lt;/code> becomes &lt;code>did&lt;/code>&amp;rsquo;s default &lt;code>FALSE&lt;/code>. The delegated call is recorded in &lt;code>DIDparams$call&lt;/code>, so printed summaries show it. &lt;code>aggte()&lt;/code> passes ordinary results to &lt;code>did::aggte()&lt;/code> unchanged, and &lt;code>conditional_did_pretest(mode = &amp;quot;ordinary&amp;quot;)&lt;/code> runs &lt;code>did::conditional_did_pretest()&lt;/code>.&lt;/p>
&lt;p>Aggregate chained results with &lt;code>cdid::aggte()&lt;/code>. A chained result stores the state that aggregation needs but not the panel data, so &lt;code>did::aggte()&lt;/code> cannot aggregate it.&lt;/p>
&lt;h2 id="repeated-cross-sections">Repeated cross sections&lt;/h2>
&lt;p>With &lt;code>panel = FALSE&lt;/code>, the default mode is ordinary, and &lt;code>did&lt;/code>&amp;rsquo;s repeated cross section (RCS) estimators run unchanged. Chained mode needs panel data and refuses &lt;code>panel = FALSE&lt;/code>. When different units are observed at each date there are no changes within units to chain, so the RCS approach is the available one, under its own sampling assumptions.&lt;/p>
&lt;h2 id="incomplete-panels-in-did-and-in-chained-mode">Incomplete panels in did and in chained mode&lt;/h2>
&lt;p>&lt;code>did&lt;/code> already accepts unbalanced panels and offers two treatments of them through &lt;code>allow_unbalanced_panel&lt;/code>. Chained mode uses a third.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Approach&lt;/th>
&lt;th>Observations used&lt;/th>
&lt;th>What each comparison uses&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>did&lt;/code> with &lt;code>allow_unbalanced_panel = FALSE&lt;/code>, its default (also ordinary mode with &lt;code>NULL&lt;/code>)&lt;/td>
&lt;td>rows with missing values in the variables used are dropped, then only units observed at every date are kept&lt;/td>
&lt;td>changes within units of this balanced subset&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>did&lt;/code> with &lt;code>allow_unbalanced_panel = TRUE&lt;/code>&lt;/td>
&lt;td>rows with complete, finite values of the required variables&lt;/td>
&lt;td>&lt;code>did&lt;/code>&amp;rsquo;s repeated cross section estimators, which compare outcome levels among the units observed at each date&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid&lt;/code> chained mode&lt;/td>
&lt;td>every unit of the unit table; units with at least two observed outcomes contribute changes&lt;/td>
&lt;td>changes between two observed dates of the same unit, combined across dates&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>These descriptions refer to &lt;code>did&lt;/code> 2.5.1, the version &lt;code>cdid&lt;/code> is tested with. In chained mode, &lt;code>allow_unbalanced_panel = NULL&lt;/code> (the default) keeps every eligible unit, including in balanced panels, and an explicit &lt;code>FALSE&lt;/code> is refused with an error that points to &lt;code>mode = &amp;quot;ordinary&amp;quot;&lt;/code>.&lt;/p>
&lt;p>The choice matters for three reasons.&lt;/p>
&lt;ol>
&lt;li>&lt;strong>The balanced subset can describe a different population.&lt;/strong> If observation depends on characteristics related to how outcomes evolve, the units observed at every date differ from the study population. When effects vary across units, an analysis of that subset estimates effects for the subset.&lt;/li>
&lt;li>&lt;strong>Comparisons of levels need conditions on levels.&lt;/strong> Callaway and Sant&amp;rsquo;Anna&amp;rsquo;s repeated cross section setting assumes that the sample at each date represents the population at that date and that the distribution of cohorts and covariates is stable across dates. When observation depends on a fixed unit component, for example when units with persistently low outcomes leave the panel, the observed levels at later dates stop representing the population. Changes within units remove that component, so chained DiD can still rely on the observed changes.&lt;/li>
&lt;li>&lt;strong>Units with one observed outcome form no change.&lt;/strong> In chained mode they remain part of the study population through the unit table and still contribute their cohort, covariates and observation information. These units do not enter the regression fits for outcome changes, because computing a difference requires at least two observations per unit.&lt;/li>
&lt;/ol>
&lt;p>Each approach needs its own assumptions. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a> states the chained assumptions about observed changes.&lt;/p>
&lt;h2 id="when-chained-and-did-estimates-should-agree">When chained and did estimates should agree&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Setting&lt;/th>
&lt;th>Point estimates of chained and ordinary mode&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Baseline &lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>, complete panel, units never treated as controls, no covariates, each unit&amp;rsquo;s weight fixed across comparisons, PT-post, the same &lt;code>anticipation&lt;/code> and &lt;code>base_period&lt;/code>&lt;/td>
&lt;td>Expected to agree up to floating point rounding, because consecutive changes add up to the long comparisons &lt;code>did&lt;/code> uses. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/#optional-compare-with-did">Get started&lt;/a> gives the code.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>OR or DR with different fitted specifications or procedures&lt;/td>
&lt;td>Can differ when the specifications or fitted procedures differ. Both packages allow comparison-specific regressions; chained &lt;code>outcome_pooling = &amp;quot;separate&amp;quot;&lt;/code> is the default. Explicit &lt;code>&amp;quot;pooled&amp;quot;&lt;/code> instead shares slopes across comparison blocks. The method label alone is not a reason for a difference; identical formula notation need not impose identical coefficient restrictions.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Covariates with &lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code>&lt;/td>
&lt;td>This guide makes no general claim. Compare the two fits directly.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Units not yet treated as controls&lt;/td>
&lt;td>The chained catalog can retain additional fixed-horizon control-pool moments for the same date pair and combine them jointly. This differs from using only the cell&amp;rsquo;s ordinary control pool; see the concrete example below.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>pt_assumption = &amp;quot;all&amp;quot;&lt;/code>&lt;/td>
&lt;td>Need not agree. The added restrictions can change estimates with complete outcomes, and &lt;code>did&lt;/code> has no such option.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Incomplete panel&lt;/td>
&lt;td>The approaches use different observations and assumptions, as in the table above.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Sampling weights that change within units&lt;/td>
&lt;td>Chained mode requires a fixed reference weight through &lt;code>fix_weights&lt;/code>, described in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#changing-covariates-and-weights">Changing covariates and weights&lt;/a>.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="why-can-balanced-results-differ-and-which-should-i-use">Why can balanced results differ, and which should I use?&lt;/h2>
&lt;p>With the same complete sample, balance removes missing-outcome differences. A fair comparison must also match the fitted specification and procedure: coefficient restrictions, nuisance fitting, moments and weighting. If that full procedure is identical, the point estimates should agree up to numerical rounding. The labels OR or DR, or the same &lt;code>xformla&lt;/code> notation, do not themselves establish a difference or an equality.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Matched balanced panel setting&lt;/th>
&lt;th>Why point estimates can agree or differ&lt;/th>
&lt;th>Implication for the choice&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Baseline built-in IPW, never treated controls, no covariates, PT-post and each unit&amp;rsquo;s weight fixed across comparisons&lt;/td>
&lt;td>The common cohort and control means telescope, so the chained combination reduces to the long comparisons used by &lt;code>did&lt;/code>, up to floating point rounding.&lt;/td>
&lt;td>This is a useful common-case check, not a claim of equality for every method. Match the input, weights, anticipation and other settings before comparing.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Treatment OR or DR when slope restrictions or fitting differ&lt;/td>
&lt;td>The default separate fits allow comparison-specific coefficients. Choosing &lt;code>outcome_pooling = &amp;quot;pooled&amp;quot;&lt;/code> instead imposes shared slopes; estimates can differ when coefficient restrictions or fitting procedures differ. Even different nuisance fits need not change the final estimate if their correction cancels.&lt;/td>
&lt;td>If covariate effects on untreated changes vary across dates and the shared slope restriction lacks justification, separate comparison regressions are more flexible. If pooling is credible, sharing information may improve precision, but no uniform efficiency advantage is established.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Not-yet-treated controls&lt;/td>
&lt;td>The chained catalog retains original comparisons and distinct later fixed-horizon reuses. Multiple valid control-pool moments can be combined for one effect even with complete outcomes and no covariates.&lt;/td>
&lt;td>Under the full NYT parallel-trends and overlap conditions, these are valid additional moments. They may add information, but no universal finite-sample or efficiency advantage is claimed.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>PT-all&lt;/td>
&lt;td>Chained estimation adds represented untreated-trend restrictions from the chosen common start; &lt;code>did&lt;/code> has no corresponding PT-all option.&lt;/td>
&lt;td>Use these stronger restrictions only when credible. They may add identification or precision; false restrictions can bias the estimates.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="a-balanced-nyt-example">A balanced NYT example&lt;/h3>
&lt;p>Consider a regular calendar, zero anticipation, cohorts first treated in periods 3 and 5, and units never treated (&lt;code>G = 0&lt;/code>). Every outcome is observed, with no covariates and equal weights. For ATT(3,3), the reference date is 2.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Comparison of the change from 2 to 3&lt;/th>
&lt;th>Ordinary cell and chained catalog&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Cohort 3 against cohorts 5 and 0 together&lt;/td>
&lt;td>The ordinary &lt;code>did&lt;/code> cell uses this pool; the chained catalog retains it too.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Cohort 3 against cohort 0 alone&lt;/td>
&lt;td>The chained catalog also retains this same date pair with the control pool fixed at a later horizon, such as 5, by which time cohort 5 is treated.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Under the full not-yet-treated parallel-trends assumption, the target cohort&amp;rsquo;s untreated changes agree with each eligible later control tail, not only the largest tail at the cell&amp;rsquo;s own date. Both comparisons therefore have population expectation ATT(3,3). This implication uses the same full NYT assumption at every later cutoff; it adds no parallel-trends restriction before reference date 2 and is not PT-all. A weaker assumption asserted only for the combined &lt;code>{5, 0}&lt;/code> pool at period 3 would not justify the never-treated-only reuse.&lt;/p>
&lt;p>The two sample control averages need not coincide. &lt;code>cdid&lt;/code> combines these and the other valid moments jointly by GMM, whereas the ordinary cell uses its own comparison. The additional moment restrictions can therefore change finite sample point estimates even in this balanced example. Joint weighting can also affect other targets through covariance with these moments. This identifies the source of a possible difference; it does not rank efficiency or establish the assumptions from the data.&lt;/p>
&lt;p>For treatment DR, the correctness alternative remains: under valid observation reconstruction, parallel trends, overlap and the other regularity conditions, a correct treatment propensity model can protect a misspecified counterfactual regression, or a correct counterfactual regression can protect a misspecified propensity model. For &lt;code>outcome_pooling = &amp;quot;pooled&amp;quot;&lt;/code>, the regression must be correct across the blocks sharing its slope; separate fits require correctness in the relevant comparison. DR is not protection against invalid parallel trends or invalid handling of missing outcomes.&lt;/p>
&lt;p>Point estimates, standard errors and multiplier bands are separate comparisons. Agreement of point estimates does not establish agreement of influence functions or analytical standard errors. Different multiplier draws can also change reported bootstrap standard errors and critical values without changing the fitted effects; a reproducible inference comparison must align its settings and random number procedure.&lt;/p>
&lt;h2 id="differences-in-the-chained-interface">Differences in the chained interface&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Topic&lt;/th>
&lt;th>Chained mode&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>idname&lt;/code>&lt;/td>
&lt;td>Required, because units are aligned by identity.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>clustervars&lt;/code>&lt;/td>
&lt;td>At most one cluster variable in addition to &lt;code>idname&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>allow_unbalanced_panel&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code> keeps every eligible unit; &lt;code>FALSE&lt;/code> is refused.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>est_method&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;dr&amp;quot;&lt;/code> (default), &lt;code>&amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>&amp;quot;reg&amp;quot;&lt;/code> or a custom IPW function with &lt;code>did&lt;/code>&amp;rsquo;s panel interface. Any other string is refused before the data are read, and nothing is substituted.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>...&lt;/code>&lt;/td>
&lt;td>Passed to a custom &lt;code>est_method&lt;/code> function; refused when &lt;code>est_method&lt;/code> is a string.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>fix_weights&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>, &lt;code>&amp;quot;first_period&amp;quot;&lt;/code> or &lt;code>&amp;quot;base_period&amp;quot;&lt;/code>; &lt;code>&amp;quot;varying&amp;quot;&lt;/code> is refused.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>compute_inffunc = FALSE&lt;/code>&lt;/td>
&lt;td>Point estimates only, as in &lt;code>did&lt;/code>: no influence functions, standard errors, pretrend test or aggregation.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>pl = TRUE&lt;/code>, &lt;code>cores = k&lt;/code>&lt;/td>
&lt;td>Multiplier draws on &lt;code>k&lt;/code> worker processes, which you must declare with &lt;code>control = list(workers = k)&lt;/code>. Results equal those of &lt;code>cores = 1&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>faster_mode&lt;/code>&lt;/td>
&lt;td>Accepted with its &lt;code>did&lt;/code> meaning; chained mode has one computation engine.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>print_details = TRUE&lt;/code>&lt;/td>
&lt;td>Progress messages, which &lt;code>suppressMessages()&lt;/code> silences.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Chained mode adds arguments for the unit table, missing outcomes, parallel trends and GMM weighting. The &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#chained-arguments">options reference&lt;/a> lists them.&lt;/p>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 2 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;strong>Moving from did&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>Options reference</title><link>https://www.davidbenatia.com/tools/cdid/guide/reference/options/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/reference/options/</guid><description>&lt;p>Find the defaults and allowed values for each argument. Use the help topics in R for examples, or follow the links to the worked examples in this guide.&lt;/p>
&lt;h2 id="signatures">Signatures&lt;/h2>
&lt;p>For a complete example, see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>.&lt;/p>
&lt;pre>&lt;code class="language-r">cdid::att_gt(
yname, tname, idname = NULL, gname, xformla = NULL, data,
panel = TRUE, allow_unbalanced_panel = NULL,
control_group = c(&amp;quot;nevertreated&amp;quot;, &amp;quot;notyettreated&amp;quot;), anticipation = 0,
weightsname = NULL, fix_weights = NULL, alp = 0.05, bstrap = TRUE,
cband = TRUE, biters = 1000, clustervars = NULL, est_method = &amp;quot;dr&amp;quot;,
base_period = &amp;quot;varying&amp;quot;, faster_mode = TRUE, print_details = FALSE,
pl = FALSE, cores = 1, compute_inffunc = TRUE, ...,
mode = NULL, frame = NULL, selection = &amp;quot;none&amp;quot;,
selection_model = &amp;quot;pair_logit&amp;quot;, selection_pooling = &amp;quot;separate&amp;quot;,
selection_xformla = NULL, selection_universe = &amp;quot;F&amp;quot;, selection_rho = NULL,
selection_justification = NULL, selection_est_method = &amp;quot;ipw&amp;quot;,
imputation_pooling = &amp;quot;separate&amp;quot;, gmm_weighting = c(&amp;quot;optimal&amp;quot;, &amp;quot;identity&amp;quot;, &amp;quot;within&amp;quot;),
gmm_covariance = &amp;quot;tikhonov&amp;quot;, pt_assumption = c(&amp;quot;post&amp;quot;, &amp;quot;all&amp;quot;, &amp;quot;ctrl&amp;quot;),
pt_start = NULL, cross_pair = FALSE, control = NULL, outcome_pooling = &amp;quot;separate&amp;quot;,
dname = NULL, imputation_scale = &amp;quot;per_period&amp;quot;,
switchers = &amp;quot;both&amp;quot;, switch_times = NULL, missing_reference = &amp;quot;exclude&amp;quot;
)
cdid::aggte(
MP, type = &amp;quot;group&amp;quot;, balance_e = NULL, min_e = -Inf, max_e = Inf,
na.rm = FALSE, bstrap = NULL, biters = NULL, cband = NULL, alp = NULL,
clustervars = NULL
)
cdid::chain_report(
object, cohort = NULL, time = NULL, include_pre = FALSE, tol = 1e-10,
group = NULL, t = NULL
)
cdid::conditional_did_pretest(
yname, tname, idname = NULL, gname, xformla = NULL, data,
panel = TRUE, allow_unbalanced_panel = NULL,
control_group = c(&amp;quot;nevertreated&amp;quot;, &amp;quot;notyettreated&amp;quot;), weightsname = NULL,
alp = 0.05, bstrap = TRUE, cband = TRUE, biters = 1000, clustervars = NULL,
est_method = &amp;quot;ipw&amp;quot;, print_details = FALSE, pl = FALSE, cores = 1,
anticipation = 0, base_period = &amp;quot;varying&amp;quot;, fix_weights = NULL,
mode = NULL, frame = NULL, selection = &amp;quot;none&amp;quot;,
selection_model = &amp;quot;pair_logit&amp;quot;, selection_pooling = &amp;quot;separate&amp;quot;,
selection_xformla = NULL, selection_universe = &amp;quot;F&amp;quot;, selection_rho = NULL,
selection_justification = NULL, selection_est_method = &amp;quot;ipw&amp;quot;,
imputation_pooling = &amp;quot;separate&amp;quot;, control = NULL, outcome_pooling = &amp;quot;separate&amp;quot;
)
&lt;/code>&lt;/pre>
&lt;p>In &lt;code>att_gt()&lt;/code>, arguments before &lt;code>...&lt;/code> retain the names and order of &lt;code>did&lt;/code> 2.5.1. The deliberate default difference is &lt;code>allow_unbalanced_panel = NULL&lt;/code>, which uses &lt;code>did&lt;/code>&amp;rsquo;s &lt;code>FALSE&lt;/code> in ordinary mode. The arguments after &lt;code>...&lt;/code> are used only in chained mode; ordinary mode neither evaluates nor forwards them.&lt;/p>
&lt;h2 id="data-timing-and-comparison-group">Data, timing and comparison group&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Argument&lt;/th>
&lt;th>Default&lt;/th>
&lt;th>Accepted values&lt;/th>
&lt;th>Notes for chained mode&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>yname&lt;/code>&lt;/td>
&lt;td>required&lt;/td>
&lt;td>name of a numeric outcome column&lt;/td>
&lt;td>Observed values must be finite. Keep missing outcomes as &lt;code>NA&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>tname&lt;/code>&lt;/td>
&lt;td>required&lt;/td>
&lt;td>name of a finite numeric date column&lt;/td>
&lt;td>The stored calendar is the sorted set of dates present in the data. OR/imputation durations count positions in it; event time and anticipation cutoffs use numeric date values.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>idname&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>name of the unit identifier column&lt;/td>
&lt;td>Required, because units are aligned by identity.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>gname&lt;/code>&lt;/td>
&lt;td>required (when &lt;code>dname = NULL&lt;/code>)&lt;/td>
&lt;td>name of the column holding each unit&amp;rsquo;s first treatment period&lt;/td>
&lt;td>Known, constant within each panel unit. Use a finite positive treatment date on the time scale of &lt;code>tname&lt;/code>, or 0 for never treated. The treatment date need not be a stored row. Retains the cohort &lt;code>ATT(g, t)&lt;/code> route.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>dname&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code> or name of a binary period treatment column ($D_{it} \in {0, 1}$)&lt;/td>
&lt;td>Binary switching model under no carryover (returns &lt;code>cdid_static_att_gt&lt;/code>). In chained panel mode, selects the static route even if the binary treatment is absorbing; specifying both &lt;code>gname&lt;/code> and &lt;code>dname&lt;/code> is refused. Ordinary mode ignores static arguments. Requires complete known binary $D_{i,1:T}$ across all panel dates for every unit; units with zero or one observed outcome $Y_{it}$ remain in the study population and original-unit influence functions. See &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/static-entry-exit/">Static entry, exit and re-entry&lt;/a>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>data&lt;/code>&lt;/td>
&lt;td>required&lt;/td>
&lt;td>a data frame with one row per unit and date&lt;/td>
&lt;td>Each ID/date pair must be unique. A balanced panel and an observed reference-date outcome for every unit are not required. See &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel&lt;/a> and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/investigate-missingness/">Investigate missingness&lt;/a>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>missing_reference&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;exclude&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;exclude&amp;quot;&lt;/code> or &lt;code>&amp;quot;error&amp;quot;&lt;/code>&lt;/td>
&lt;td>When a required dated covariate is missing, warn and restrict comparisons for the affected cohort to units with known reference covariates. Choose &lt;code>&amp;quot;error&amp;quot;&lt;/code> to stop and list missing inputs. See &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/#add-a-known-reference-covariate-row">Add a known reference covariate row&lt;/a>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>panel&lt;/code>&lt;/td>
&lt;td>&lt;code>TRUE&lt;/code>&lt;/td>
&lt;td>&lt;code>TRUE&lt;/code> or &lt;code>FALSE&lt;/code>&lt;/td>
&lt;td>Chained mode requires &lt;code>TRUE&lt;/code>. With &lt;code>mode = NULL&lt;/code>, &lt;code>FALSE&lt;/code> selects ordinary mode.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>allow_unbalanced_panel&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>, &lt;code>TRUE&lt;/code> or &lt;code>FALSE&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code> retains the full unit table, including units with no observed change. Units with repeated observations supply changes. &lt;code>FALSE&lt;/code> is refused. In ordinary mode &lt;code>NULL&lt;/code> means &lt;code>did&lt;/code>&amp;rsquo;s default &lt;code>FALSE&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>control_group&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;nevertreated&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;nevertreated&amp;quot;&lt;/code> or &lt;code>&amp;quot;notyettreated&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>anticipation&lt;/code>&lt;/td>
&lt;td>0&lt;/td>
&lt;td>finite nonnegative whole number&lt;/td>
&lt;td>Sets each cohort&amp;rsquo;s reference period: the latest stored date d with &lt;code>d + anticipation &amp;lt; g&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>weightsname&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>name of a column of positive sampling weights&lt;/td>
&lt;td>Weights that change within a unit need &lt;code>fix_weights&lt;/code>, see &lt;a href="#changing-covariates-and-weights">Changing covariates and weights&lt;/a>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>fix_weights&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>, &lt;code>&amp;quot;first_period&amp;quot;&lt;/code> or &lt;code>&amp;quot;base_period&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;varying&amp;quot;&lt;/code> is refused.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The unit table &lt;code>frame&lt;/code> is described with the &lt;a href="#chained-arguments">chained arguments&lt;/a> and in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#the-study-population-and-the-unit-table">Handling missing outcomes&lt;/a>.&lt;/p>
&lt;h2 id="treatment-adjustment">Treatment adjustment&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Argument&lt;/th>
&lt;th>Default&lt;/th>
&lt;th>Accepted values&lt;/th>
&lt;th>Notes for chained mode&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>est_method&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;dr&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;dr&amp;quot;&lt;/code>, &lt;code>&amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>&amp;quot;reg&amp;quot;&lt;/code> or a custom IPW function (cohort &lt;code>gname&lt;/code> only)&lt;/td>
&lt;td>Any other string is refused before the data are read; nothing is substituted. On the static &lt;code>dname&lt;/code> route, built-in &lt;code>&amp;quot;dr&amp;quot;&lt;/code>, &lt;code>&amp;quot;ipw&amp;quot;&lt;/code> and &lt;code>&amp;quot;reg&amp;quot;&lt;/code> are supported and custom function callbacks are refused.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>outcome_pooling&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;separate&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;separate&amp;quot;&lt;/code> or &lt;code>&amp;quot;pooled&amp;quot;&lt;/code> (plus explicit cell partitions on the static &lt;code>dname&lt;/code> route)&lt;/td>
&lt;td>Counterfactual outcome-change regression for &lt;code>est_method = &amp;quot;reg&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code> (inactive and never evaluated when &lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code>). Separate fits have comparison-specific slopes; pooled fits share slopes across blocks with local intercepts. On the static &lt;code>dname&lt;/code> route, an explicit named character vector (&lt;code>cell_id -&amp;gt; block_id&lt;/code>) or named list of &lt;code>cell_id&lt;/code> vectors partitioning transition cells (including optional extra non-target stayer training cells) is also accepted; explicit partitions are static-only. Independent of selection and imputation pooling.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>xformla&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>one sided formula, such as &lt;code>~ x1 + x2&lt;/code>&lt;/td>
&lt;td>The design must have at least one column: &lt;code>~ 1&lt;/code> and &lt;code>~ 0 + x&lt;/code> are accepted, &lt;code>~ 0&lt;/code> is refused. Covariates must be fixed within units or are read at reference dates.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>...&lt;/code>&lt;/td>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;td>Passed to a custom &lt;code>est_method&lt;/code> function; refused when &lt;code>est_method&lt;/code> is a string or on the static &lt;code>dname&lt;/code> route.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>A custom function has &lt;code>did&lt;/code>&amp;rsquo;s panel IPW interface &lt;code>f(y1, y0, D, covariates, i.weights, inffunc = TRUE, ...)&lt;/code> and returns a list with a finite scalar &lt;code>ATT&lt;/code> and a finite vector or one-column matrix &lt;code>att.inf.func&lt;/code> with one entry per supplied row, in that order. Under observation weighting with &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, it must also return &lt;code>log_weight_gradient&lt;/code>. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/#custom-ipw-functions">Treatment adjustment&lt;/a> explains these requirements and the models behind the three string methods.&lt;/p>
&lt;h2 id="chained-arguments">Chained arguments&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Argument&lt;/th>
&lt;th>Default&lt;/th>
&lt;th>Accepted values&lt;/th>
&lt;th>Active when&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>mode&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>, &lt;code>&amp;quot;chained&amp;quot;&lt;/code> or &lt;code>&amp;quot;ordinary&amp;quot;&lt;/code>&lt;/td>
&lt;td>Always. &lt;code>NULL&lt;/code> selects chained mode for &lt;code>panel = TRUE&lt;/code> and ordinary mode otherwise.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>frame&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>the unit table: a data frame with one row per study unit, matched to &lt;code>data&lt;/code> by &lt;code>idname&lt;/code>&lt;/td>
&lt;td>Chained mode. Without it, the units in &lt;code>data&lt;/code> form the study population.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>selection&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;none&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;none&amp;quot;&lt;/code>, &lt;code>&amp;quot;conditional_mtar&amp;quot;&lt;/code>, or the legacy name &lt;code>&amp;quot;corollary1&amp;quot;&lt;/code>&lt;/td>
&lt;td>Chained mode. On the cohort &lt;code>gname&lt;/code> route only, &lt;code>&amp;quot;corollary1&amp;quot;&lt;/code> means &lt;code>&amp;quot;conditional_mtar&amp;quot;&lt;/code> with &lt;code>selection_model = &amp;quot;pair_logit&amp;quot;&lt;/code>. Static &lt;code>dname&lt;/code> accepts only &lt;code>&amp;quot;none&amp;quot;&lt;/code> or &lt;code>&amp;quot;conditional_mtar&amp;quot;&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>selection_est_method&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;ipw&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;ipw&amp;quot;&lt;/code> (observation weighting), &lt;code>&amp;quot;imputation&amp;quot;&lt;/code> (change imputation) or &lt;code>&amp;quot;dr&amp;quot;&lt;/code> (augmented correction)&lt;/td>
&lt;td>&lt;code>&amp;quot;imputation&amp;quot;&lt;/code> and &lt;code>&amp;quot;dr&amp;quot;&lt;/code> require &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code> and a built-in &lt;code>est_method&lt;/code> (&lt;code>&amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>&amp;quot;reg&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>selection_model&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;pair_logit&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;pair_logit&amp;quot;&lt;/code> or &lt;code>&amp;quot;independent_period_logit&amp;quot;&lt;/code>&lt;/td>
&lt;td>An active conditional-MTAR correction with &lt;code>selection_est_method&lt;/code> equal to &lt;code>&amp;quot;ipw&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>. Never evaluated under &lt;code>&amp;quot;imputation&amp;quot;&lt;/code>. A nondefault value with &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code> is refused.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>selection_pooling&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;separate&amp;quot;&lt;/code>&lt;/td>
&lt;td>Cohort &lt;code>gname&lt;/code>: &lt;code>&amp;quot;separate&amp;quot;&lt;/code>, &lt;code>&amp;quot;within_cohort&amp;quot;&lt;/code> or &lt;code>&amp;quot;across_cohorts&amp;quot;&lt;/code>. Static &lt;code>dname&lt;/code>: &lt;code>&amp;quot;separate&amp;quot;&lt;/code>, &lt;code>&amp;quot;within_group&amp;quot;&lt;/code> or &lt;code>&amp;quot;pooled&amp;quot;&lt;/code>&lt;/td>
&lt;td>As for &lt;code>selection_model&lt;/code>. Local intercepts are retained per pair/date and cohort or role population whenever &lt;code>selection_xformla&lt;/code> includes an intercept.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>selection_xformla&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>, which inherits &lt;code>xformla&lt;/code>&lt;/td>
&lt;td>one sided formula&lt;/td>
&lt;td>An observation model is fitted (&lt;code>&amp;quot;ipw&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>). Never evaluated under &lt;code>&amp;quot;imputation&amp;quot;&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>selection_universe&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;F&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;F&amp;quot;&lt;/code> (whole unit table), &lt;code>&amp;quot;B&amp;quot;&lt;/code> (units observed at least once) or &lt;code>&amp;quot;A&amp;quot;&lt;/code> (units observed at least twice)&lt;/td>
&lt;td>&lt;code>&amp;quot;B&amp;quot;&lt;/code> and &lt;code>&amp;quot;A&amp;quot;&lt;/code> require observation weighting and &lt;code>selection_model = &amp;quot;pair_logit&amp;quot;&lt;/code>. Static transport is defined within each transition role.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>selection_rho&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code> or the name of a column of known normalized density ratios&lt;/td>
&lt;td>For &lt;code>&amp;quot;A&amp;quot;&lt;/code> or &lt;code>&amp;quot;B&amp;quot;&lt;/code>. The column is in the unit table for cohort models and in &lt;code>data&lt;/code> for switching models.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>selection_justification&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>a nonempty character string&lt;/td>
&lt;td>Required with &lt;code>&amp;quot;B&amp;quot;&lt;/code> or &lt;code>&amp;quot;A&amp;quot;&lt;/code>. For switching models, the statement applies within each switcher and stayer group.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>imputation_pooling&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;separate&amp;quot;&lt;/code>&lt;/td>
&lt;td>Cohort &lt;code>gname&lt;/code>: &lt;code>&amp;quot;separate&amp;quot;&lt;/code>, &lt;code>&amp;quot;within_cohort&amp;quot;&lt;/code> or &lt;code>&amp;quot;across_cohorts&amp;quot;&lt;/code>. Static &lt;code>dname&lt;/code>: &lt;code>&amp;quot;separate&amp;quot;&lt;/code>, &lt;code>&amp;quot;within_group&amp;quot;&lt;/code> or &lt;code>&amp;quot;pooled&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>selection_est_method&lt;/code> is &lt;code>&amp;quot;imputation&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>; otherwise never evaluated. Local intercepts are retained when &lt;code>xformla&lt;/code> includes an intercept.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>imputation_scale&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;per_period&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;per_period&amp;quot;&lt;/code> or &lt;code>&amp;quot;per_change&amp;quot;&lt;/code>&lt;/td>
&lt;td>Static &lt;code>dname&lt;/code> route when &lt;code>selection_est_method&lt;/code> is &lt;code>&amp;quot;imputation&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>; otherwise never evaluated. &lt;code>&amp;quot;per_period&amp;quot;&lt;/code> multiplies non-intercept covariate slopes by the stored-calendar index gap $L_k = u_{\text{idx}} - s_{\text{idx}}$; &lt;code>&amp;quot;per_change&amp;quot;&lt;/code> leaves them unscaled.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>switchers&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;both&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;both&amp;quot;&lt;/code>, &lt;code>&amp;quot;entry&amp;quot;&lt;/code> or &lt;code>&amp;quot;exit&amp;quot;&lt;/code>&lt;/td>
&lt;td>Static &lt;code>dname&lt;/code> route: selects both transition directions ($0 \to 1$ and $1 \to 0$), entry only ($D_{t-1} = 0 \to D_t = 1$), or exit only ($D_{t-1} = 1 \to D_t = 0$).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>switch_times&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code> or a vector of panel transition dates in $t_2, \dots, t_T$&lt;/td>
&lt;td>Static &lt;code>dname&lt;/code> route: &lt;code>NULL&lt;/code> automatically includes all transition cells in the requested direction(s) with at least one switcher ($n_{\text{switchers}} \ge 1$). Explicit dates retain all requested directions at those dates (keeping zero-switcher cells as &lt;code>available = FALSE&lt;/code> with &lt;code>support_status = &amp;quot;empty_switchers&amp;quot;&lt;/code>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>gmm_weighting&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;optimal&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;optimal&amp;quot;&lt;/code>, its alias &lt;code>&amp;quot;two_step&amp;quot;&lt;/code>, &lt;code>&amp;quot;identity&amp;quot;&lt;/code> or &lt;code>&amp;quot;within&amp;quot;&lt;/code> (cohort &lt;code>gname&lt;/code> only)&lt;/td>
&lt;td>Chained mode (both cohort &lt;code>gname&lt;/code> and static &lt;code>dname&lt;/code> routes; on a complete panel with &lt;code>dname&lt;/code> and &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>, all-pair chaining reduces to the direct complete-data baseline estimator with &lt;code>gmm_executed = FALSE&lt;/code>). &lt;code>&amp;quot;within&amp;quot;&lt;/code> requires a built-in &lt;code>est_method&lt;/code> (&lt;code>&amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>&amp;quot;reg&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>) and supports all &lt;code>selection&lt;/code>, &lt;code>outcome_pooling&lt;/code>, and reference-date covariate/weight options on the cohort route; it is inapplicable and refused on the static &lt;code>dname&lt;/code> route.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>gmm_covariance&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;tikhonov&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;tikhonov&amp;quot;&lt;/code>&lt;/td>
&lt;td>Validated in chained mode; the handler is used under covariance-whitened weighting (&lt;code>&amp;quot;optimal&amp;quot;&lt;/code>, or &lt;code>&amp;quot;within&amp;quot;&lt;/code> on the cohort route).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>pt_assumption&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;post&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;post&amp;quot;&lt;/code>, &lt;code>&amp;quot;all&amp;quot;&lt;/code> or &lt;code>&amp;quot;ctrl&amp;quot;&lt;/code>&lt;/td>
&lt;td>Cohort &lt;code>gname&lt;/code> route (&lt;code>&amp;quot;all&amp;quot;&lt;/code> and &lt;code>&amp;quot;ctrl&amp;quot;&lt;/code> are inapplicable and refused on the static &lt;code>dname&lt;/code> route).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>pt_start&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>one finite numeric date of the stored calendar (or &lt;code>NULL&lt;/code> under &lt;code>&amp;quot;post&amp;quot;&lt;/code> and &lt;code>&amp;quot;ctrl&amp;quot;&lt;/code>)&lt;/td>
&lt;td>Cohort &lt;code>gname&lt;/code> route: required under &lt;code>&amp;quot;all&amp;quot;&lt;/code>; optional under &lt;code>&amp;quot;ctrl&amp;quot;&lt;/code> (&lt;code>NULL&lt;/code> defaults to the earliest stored calendar date); refused under &lt;code>&amp;quot;post&amp;quot;&lt;/code>. A non-&lt;code>NULL&lt;/code> value is refused on the static &lt;code>dname&lt;/code> route.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cross_pair&lt;/code>&lt;/td>
&lt;td>&lt;code>FALSE&lt;/code>&lt;/td>
&lt;td>&lt;code>TRUE&lt;/code> or &lt;code>FALSE&lt;/code>&lt;/td>
&lt;td>Cohort &lt;code>gname&lt;/code> route. &lt;code>TRUE&lt;/code> separates target-cohort and clean control-cohort within-unit change moments; requires a built-in &lt;code>est_method&lt;/code> (&lt;code>&amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>&amp;quot;reg&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>) and supports all &lt;code>selection&lt;/code>, &lt;code>outcome_pooling&lt;/code>, and reference-date covariate/weight options. On the static &lt;code>dname&lt;/code> route &lt;code>FALSE&lt;/code> is accepted and &lt;code>TRUE&lt;/code> is refused as inapplicable.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>control&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>a named list, see &lt;a href="#the-control-list">The control list&lt;/a>&lt;/td>
&lt;td>Chained mode (both cohort &lt;code>gname&lt;/code> and static &lt;code>dname&lt;/code> routes).&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="handling-missing-outcomes">Handling missing outcomes&lt;/h2>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a> explains the assumptions and models. The interface rules are these.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Formulas.&lt;/strong> &lt;code>xformla&lt;/code> and &lt;code>selection_xformla&lt;/code> are one sided formulas whose &lt;code>stats::terms&lt;/code> intercept and assignment information is respected, including intercept only (&lt;code>~ 1&lt;/code>) and no intercept (&lt;code>~ 0 + x&lt;/code>) forms. Only &lt;code>selection_xformla&lt;/code> accepts a design with no columns (&lt;code>~ 0&lt;/code>); its observation model then has no parameters and uses the fixed probability 0.5 for each pair, or 0.25 for a product of two dates.&lt;/li>
&lt;li>&lt;strong>Observation weighting&lt;/strong> (&lt;code>selection_est_method = &amp;quot;ipw&amp;quot;&lt;/code>) fits &lt;code>selection_model&lt;/code> with &lt;code>selection_pooling&lt;/code> on the fitting sample selected by &lt;code>selection_universe&lt;/code>. &lt;code>&amp;quot;independent_period_logit&amp;quot;&lt;/code> requires &lt;code>selection_universe = &amp;quot;F&amp;quot;&lt;/code> and the independence of the two dates given cohort and covariates.&lt;/li>
&lt;li>&lt;strong>Change imputation&lt;/strong> (&lt;code>&amp;quot;imputation&amp;quot;&lt;/code>) requires &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, &lt;code>selection_universe = &amp;quot;F&amp;quot;&lt;/code>, &lt;code>selection_rho = NULL&lt;/code>, known cohorts and complete &lt;code>xformla&lt;/code> covariates on every row of the unit table, and &lt;code>est_method&lt;/code> equal to &lt;code>&amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>&amp;quot;reg&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>. It fits no observation model.&lt;/li>
&lt;li>&lt;strong>Augmented correction&lt;/strong> (&lt;code>&amp;quot;dr&amp;quot;&lt;/code>) has the requirements of change imputation, supports treatment IPW, OR or DR, needs complete covariates of both formulas on every row of the unit table and uses every observation model and imputation argument. Observation, imputation and counterfactual outcome pooling are independent choices.&lt;/li>
&lt;li>&lt;strong>Not supported:&lt;/strong> known pair probabilities (including a design probability of one), estimated or unnormalized transport ratios, and probit models.&lt;/li>
&lt;/ul>
&lt;h2 id="parallel-trends-and-reporting">Parallel trends and reporting&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Argument&lt;/th>
&lt;th>Default&lt;/th>
&lt;th>Meaning&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>pt_assumption&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;post&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;post&amp;quot;&lt;/code>: parallel trends from each cohort&amp;rsquo;s reference period onward. &lt;code>&amp;quot;ctrl&amp;quot;&lt;/code>: adds common untreated trends among clean control cohorts $k &amp;gt; g$ from &lt;code>pt_start&lt;/code> onward, leaving target cohort $g$&amp;rsquo;s own pre-reference trends free. &lt;code>&amp;quot;all&amp;quot;&lt;/code>: adds common untreated trends for both target and control cohorts from &lt;code>pt_start&lt;/code> up to each reference period.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>pt_start&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>Under &lt;code>&amp;quot;all&amp;quot;&lt;/code>, one finite numeric date that equals a stored calendar date exactly, common to all cohorts and chosen before looking at results (omitting it, &lt;code>NULL&lt;/code> and dates outside the calendar are errors). Under &lt;code>&amp;quot;ctrl&amp;quot;&lt;/code>, &lt;code>NULL&lt;/code> defaults to the earliest stored calendar date, or a finite numeric date in the stored calendar restricts control-cohort trend pooling to dates from &lt;code>pt_start&lt;/code> onward. Under &lt;code>&amp;quot;post&amp;quot;&lt;/code>, any non-&lt;code>NULL&lt;/code> value is refused.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>base_period&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;varying&amp;quot;&lt;/code>&lt;/td>
&lt;td>Reporting of cells before treatment, with &lt;code>did&lt;/code>&amp;rsquo;s meaning: &lt;code>&amp;quot;varying&amp;quot;&lt;/code> compares each stored period after the first with the preceding stored period; &lt;code>&amp;quot;universal&amp;quot;&lt;/code> compares every preperiod with the reference period, including its exact-zero reference cell. Independent of &lt;code>pt_assumption&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>anticipation&lt;/code>&lt;/td>
&lt;td>0&lt;/td>
&lt;td>A nonnegative whole number used in the numeric-date cutoff &lt;code>d + anticipation &amp;lt; g&lt;/code>; it moves the reference period back. This is not the stored-index duration of the outcome models.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a> and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a> explain PT-post, PT-ctrl, PT-all and the cases where PT-ctrl or PT-all adds no restriction.&lt;/p>
&lt;h2 id="gmm-weighting-and-covariance-regularization">GMM weighting and covariance regularization&lt;/h2>
&lt;p>Chained mode combines the available comparisons by GMM. &lt;code>gmm_weighting = &amp;quot;optimal&amp;quot;&lt;/code>, the default, uses feasible two step weighting based on the estimated covariance of the comparisons; &lt;code>&amp;quot;two_step&amp;quot;&lt;/code> is an alias for it. &lt;code>gmm_weighting = &amp;quot;identity&amp;quot;&lt;/code> requests unweighted estimation explicitly. &lt;code>gmm_weighting = &amp;quot;within&amp;quot;&lt;/code> weights moments by the inverse of the analytical covariance of within-unit changes under uncorrelated level shocks. Inference uses complete unit-level influence functions. See &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining&lt;/a> for the matched regression specification. Identity weighting is never substituted automatically.&lt;/p>
&lt;p>Before the covariance is checked, the package applies exact reductions that remove proven redundancies among the comparisons. When the reduced covariance is well conditioned, it is used as it is. When it is singular or nearly singular, judged by the ratio of its smallest to its largest eigenvalue, or when it is known to be rank deficient or its Cholesky factorization fails, the selected handler &lt;code>gmm_covariance = &amp;quot;tikhonov&amp;quot;&lt;/code> adds a ridge proportional to the trace of the reduced covariance before it is inverted for the weights. At exactly zero covariance the criterion is full-catalog least squares with the actual zero sandwich variance. Invalid or materially indefinite covariance inputs still refuse. No comparison, unit or identified contrast is dropped. &lt;code>&amp;quot;tikhonov&amp;quot;&lt;/code> is the only accepted value of &lt;code>gmm_covariance&lt;/code>. The weighting request, whether the handler was invoked and why, its tuning and the conditioning are recorded in &lt;code>fit$chained$covariance_handling&lt;/code>. The advanced entries &lt;code>condition_trigger&lt;/code> and &lt;code>ridge_relative&lt;/code> of the control list belong to this step.&lt;/p>
&lt;p>Covariance regularization affects only how comparisons are weighted. It supplies no identifying information: an effect that the comparisons cannot identify remains unavailable. Standard errors and bands always use the complete influence functions and the sandwich variance, never the inverse of the regularized matrix. Feasible weighting does not make the estimates unbiased in finite samples.&lt;/p>
&lt;h2 id="inference-and-computation">Inference and computation&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Argument&lt;/th>
&lt;th>Default&lt;/th>
&lt;th>Meaning in chained mode&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>alp&lt;/code>&lt;/td>
&lt;td>0.05&lt;/td>
&lt;td>Significance level of intervals and bands.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>bstrap&lt;/code>&lt;/td>
&lt;td>&lt;code>TRUE&lt;/code>&lt;/td>
&lt;td>Standard errors from multiplier bootstrap draws instead of analytical ones.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cband&lt;/code>&lt;/td>
&lt;td>&lt;code>TRUE&lt;/code>&lt;/td>
&lt;td>Simultaneous band over the available cells where requested.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>biters&lt;/code>&lt;/td>
&lt;td>1000&lt;/td>
&lt;td>Number of multiplier draws.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>clustervars&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>At most one cluster variable in addition to &lt;code>idname&lt;/code>, with a label for every unit of the unit table. Clustering changes standard errors and bands; the point estimates stay the same.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>compute_inffunc&lt;/code>&lt;/td>
&lt;td>&lt;code>TRUE&lt;/code>&lt;/td>
&lt;td>&lt;code>FALSE&lt;/code> returns point estimates only, which equal those of &lt;code>TRUE&lt;/code>: no influence functions, standard errors, bands or pretrend test, and &lt;code>aggte()&lt;/code> refuses the result.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>pl&lt;/code>, &lt;code>cores&lt;/code>&lt;/td>
&lt;td>&lt;code>FALSE&lt;/code>, 1&lt;/td>
&lt;td>&lt;code>pl = TRUE, cores = k&lt;/code> computes the multiplier draw products on &lt;code>k&lt;/code> worker processes, which must be declared with &lt;code>control = list(workers = k)&lt;/code>; otherwise the request is refused before the data are read. Signs are drawn in your session, so the results equal those of &lt;code>cores = 1&lt;/code>. Estimation itself stays serial.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>print_details&lt;/code>&lt;/td>
&lt;td>&lt;code>FALSE&lt;/code>&lt;/td>
&lt;td>&lt;code>TRUE&lt;/code> reports progress through messages.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>faster_mode&lt;/code>&lt;/td>
&lt;td>&lt;code>TRUE&lt;/code>&lt;/td>
&lt;td>Accepted with &lt;code>did&lt;/code>&amp;rsquo;s meaning; chained mode has one computation engine.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The exact combinations of &lt;code>bstrap&lt;/code> and &lt;code>cband&lt;/code> at each output are listed in the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#uncertainty">results reference&lt;/a>.&lt;/p>
&lt;h2 id="the-control-list">The control list&lt;/h2>
&lt;p>&lt;code>control&lt;/code> is an advanced list used only in chained mode. &lt;code>NULL&lt;/code> and an empty list give the defaults below, which the result records.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Entry&lt;/th>
&lt;th>Default&lt;/th>
&lt;th>Meaning&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>numeric_workspace_bytes&lt;/code>&lt;/td>
&lt;td>1073741824 (1 GiB)&lt;/td>
&lt;td>Admission limit for the counted numeric workspace of a fit.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>workers&lt;/code>&lt;/td>
&lt;td>1&lt;/td>
&lt;td>Number of worker processes that &lt;code>pl = TRUE, cores = k&lt;/code> may use for multiplier draws. It is never raised automatically, and the workers' buffers count against the same workspace.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>counted_work_limit&lt;/code>&lt;/td>
&lt;td>&lt;code>Inf&lt;/code>&lt;/td>
&lt;td>The estimated work cap is off by default. A finite positive whole number refuses, before a stage runs, a fit whose conservative work estimate exceeds it; an explicit &lt;code>Inf&lt;/code> also turns it off. Zero, negative, &lt;code>NA&lt;/code> and &lt;code>NaN&lt;/code> values, numbers that are not whole, values out of range and nonnumeric values are refused.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>chunk_rows&lt;/code>&lt;/td>
&lt;td>chosen automatically&lt;/td>
&lt;td>Number of rows per processing chunk.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>condition_trigger&lt;/code>&lt;/td>
&lt;td>&lt;code>1e-10&lt;/code>&lt;/td>
&lt;td>Finite, strictly between zero and one; used by the covariance regularization step.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>ridge_relative&lt;/code>&lt;/td>
&lt;td>&lt;code>1e-4&lt;/code>&lt;/td>
&lt;td>Finite and positive; used by the covariance regularization step.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>For the linear cohort-by-date model, set &lt;code>control = list(preset = &amp;quot;cohort_time_fe&amp;quot;)&lt;/code>.
See the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cohort-time-fe/">cohort-by-date guide&lt;/a> for the two control
groups, supported date and weight setup, and the treatment and observation
adjustments. The preset also accepts &lt;code>keep_nuisance&lt;/code> for coefficient reporting.&lt;/p>
&lt;p>Unknown entries are refused. The opt-in reporting flag &lt;code>keep_nuisance&lt;/code> (&lt;code>TRUE&lt;/code> or &lt;code>FALSE&lt;/code>, default &lt;code>FALSE&lt;/code>) is validated and removed before these checks; it keeps the capture read by &lt;code>nuisance_models()&lt;/code> for supported fits on the cohort and static routes. The entry &lt;code>relative_accuracy&lt;/code> is refused with class &lt;code>cdid_chained_public_accuracy_deferred&lt;/code>, because a guaranteed accuracy for each fit is not provided. The fitted result records the public cap and the internal arithmetic ceiling separately, in &lt;code>fit$chained$public$counted_work_limit&lt;/code> and &lt;code>fit$chained$public$work_cap&lt;/code>.&lt;/p>
&lt;p>Work estimates are conservative diagnostics, not measured run time. These controls limit counted numeric storage and estimated work; they do not limit the memory of the R process, CPU time or the work of a whole call, and the package does not detect the memory or speed of your machine.&lt;/p>
&lt;h2 id="supported-combinations">Supported combinations&lt;/h2>
&lt;p>With &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, all nine built-in combinations of treatment adjustment and adjustment for missing outcomes are supported. The qualified custom IPW extension is listed separately in the last row:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;code>est_method&lt;/code>&lt;/th>
&lt;th>&lt;code>selection_est_method = &amp;quot;ipw&amp;quot;&lt;/code>&lt;/th>
&lt;th>&lt;code>&amp;quot;imputation&amp;quot;&lt;/code>&lt;/th>
&lt;th>&lt;code>&amp;quot;dr&amp;quot;&lt;/code>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>&amp;quot;ipw&amp;quot;&lt;/code>&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;reg&amp;quot;&lt;/code>&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;dr&amp;quot;&lt;/code>&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>custom IPW function&lt;/td>
&lt;td>supported with &lt;code>log_weight_gradient&lt;/code>&lt;/td>
&lt;td>refused&lt;/td>
&lt;td>refused&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>With &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>, &lt;code>selection_est_method&lt;/code> stays at &lt;code>&amp;quot;ipw&amp;quot;&lt;/code> and all of &lt;code>&amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>&amp;quot;reg&amp;quot;&lt;/code>, &lt;code>&amp;quot;dr&amp;quot;&lt;/code> and a custom function (cohort &lt;code>gname&lt;/code> route) are supported. On the static &lt;code>dname&lt;/code> route, &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code> runs the baseline no-equation estimator (using the direct complete-data kernel &lt;code>static_complete_fit&lt;/code> when all outcomes are observed, and chained GMM &lt;code>static_missing_fit&lt;/code> when outcomes are missing) and &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code> supports all nine built-in combinations of &lt;code>est_method&lt;/code> (&lt;code>&amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>&amp;quot;reg&amp;quot;&lt;/code>, &lt;code>&amp;quot;dr&amp;quot;&lt;/code>) and &lt;code>selection_est_method&lt;/code> (&lt;code>&amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>&amp;quot;imputation&amp;quot;&lt;/code>, &lt;code>&amp;quot;dr&amp;quot;&lt;/code>). &lt;code>selection_universe = &amp;quot;B&amp;quot;&lt;/code> or &lt;code>&amp;quot;A&amp;quot;&lt;/code> is available in the first column with &lt;code>selection_model = &amp;quot;pair_logit&amp;quot;&lt;/code>. The static route requires a transport justification within switcher and stayer roles. Refused requests stop with an error before estimation; no other combination is substituted. See &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/static-entry-exit/">Static entry, exit and re-entry&lt;/a> for the static &lt;code>dname&lt;/code> route details.&lt;/p>
&lt;h2 id="changing-covariates-and-weights">Changing covariates and weights&lt;/h2>
&lt;p>Covariates and sampling weights that are constant within each unit and agree with the unit table pass the usual checks and are used as unit characteristics. For such calls, &lt;code>fix_weights = NULL&lt;/code>, &lt;code>&amp;quot;first_period&amp;quot;&lt;/code> and &lt;code>&amp;quot;base_period&amp;quot;&lt;/code> give identical results.&lt;/p>
&lt;p>&lt;strong>Weights that change within a unit&lt;/strong> require a fixed reference:&lt;/p>
&lt;ul>
&lt;li>&lt;code>&amp;quot;first_period&amp;quot;&lt;/code>: every comparison uses each unit&amp;rsquo;s weight at the first stored date.&lt;/li>
&lt;li>&lt;code>&amp;quot;base_period&amp;quot;&lt;/code>: every unit in the comparisons for cohort g, controls included, uses its weight at the cohort&amp;rsquo;s reference period.&lt;/li>
&lt;li>&lt;code>NULL&lt;/code> would mean weights specific to each date, as in &lt;code>did&lt;/code>, and is refused.&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Covariates that change within a unit&lt;/strong>, or a formula that uses the time variable, are read at reference dates, following &lt;code>did&lt;/code>&amp;rsquo;s convention of using covariate values from the base period of each comparison. Every comparison used for the effects of cohort g reads each unit&amp;rsquo;s values at the cohort&amp;rsquo;s reference period, and a comparison reported before treatment reads them at its earlier date. Values come only from the actual unit and date rows, including rows whose outcome is missing, and are required only where an estimate reads them. When a required value is missing, the default warns and limits the affected cohort to units with known reference covariates. The input must supply the actual value at the relevant date, including for outcomes recorded as &lt;code>NA&lt;/code>. This handling is available with every chained method, with or without corrections for missing outcomes.&lt;/p>
&lt;p>&lt;strong>Aggregation of these fits&lt;/strong> weights cohorts by their masses at the first stored date, and the standard errors include the uncertainty of these shares. Units never treated need no weight at that date. A share-dependent aggregate is unavailable when a required treated-cohort first-date mass is incomplete, with the unit identifiers recorded. One-cohort bins and a one-bin group overall summary cancel the shares exactly and do not require that mass. With &lt;code>&amp;quot;base_period&amp;quot;&lt;/code>, each cell keeps the weights of its own cohort&amp;rsquo;s comparisons, so an aggregate is a declared mixture of cohort effects and does not describe a single weighted population.&lt;/p>
&lt;h2 id="aggregation-arguments">Aggregation arguments&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Argument&lt;/th>
&lt;th>Default&lt;/th>
&lt;th>Meaning for chained results&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>MP&lt;/code>&lt;/td>
&lt;td>required&lt;/td>
&lt;td>A cohort result of &lt;code>att_gt()&lt;/code> (&lt;code>cdid_MP&lt;/code> or &lt;code>MP&lt;/code>). Chained cohort results are aggregated from their stored state without refitting; ordinary results go to &lt;code>did::aggte()&lt;/code> unchanged. Static &lt;code>cdid_static_att_gt&lt;/code> results (&lt;code>dname&lt;/code> route) store their switcher-frequency weighted aggregate directly in &lt;code>fit$aggregate&lt;/code> and are refused by &lt;code>aggte()&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>type&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;group&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;simple&amp;quot;&lt;/code>, &lt;code>&amp;quot;group&amp;quot;&lt;/code>, &lt;code>&amp;quot;dynamic&amp;quot;&lt;/code> or &lt;code>&amp;quot;calendar&amp;quot;&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>balance_e&lt;/code>, &lt;code>min_e&lt;/code>, &lt;code>max_e&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>, &lt;code>-Inf&lt;/code>, &lt;code>Inf&lt;/code>&lt;/td>
&lt;td>Event time selectors with &lt;code>did&lt;/code>&amp;rsquo;s conventions. For the calendar type they are ignored with &lt;code>did&lt;/code>&amp;rsquo;s warning. The result records how they were applied.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>na.rm&lt;/code>&lt;/td>
&lt;td>&lt;code>FALSE&lt;/code>&lt;/td>
&lt;td>&lt;code>FALSE&lt;/code>: an aggregate that needs an unavailable cell is &lt;code>NA&lt;/code>, and the missing cells are named. &lt;code>TRUE&lt;/code>: the aggregate is computed over the available cells and labelled as a restricted target.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>bstrap&lt;/code>, &lt;code>biters&lt;/code>, &lt;code>cband&lt;/code>, &lt;code>alp&lt;/code>, &lt;code>clustervars&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code> inherits the value used by &lt;code>att_gt()&lt;/code>. An explicit value overrides it with &lt;code>did&lt;/code>&amp;rsquo;s meaning. A cluster override that cannot be honored is refused.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Selector details matter: simple and group aggregation use only &lt;code>max_e&lt;/code>, measured on the sorted union of calendar and cohort dates; &lt;code>min_e&lt;/code> and &lt;code>balance_e&lt;/code> have no effect there. Dynamic aggregation uses &lt;code>e = t - g&lt;/code> in original date units and applies its window and cohort-balance rules. Calendar aggregation ignores all three selectors with a warning. These selectors change the reported target, not the fitted comparison catalog.&lt;/p>
&lt;p>A result fitted with &lt;code>compute_inffunc = FALSE&lt;/code> is refused with class &lt;code>cdid_chained_request_no_inffunc_error&lt;/code>. Multiplier draws use your session&amp;rsquo;s random number stream, so &lt;code>set.seed()&lt;/code> before the call reproduces them, and workers admitted by the fit are reused.&lt;/p>
&lt;h2 id="conditional-pretrend-test-arguments">Conditional pretrend test arguments&lt;/h2>
&lt;p>&lt;code>conditional_did_pretest()&lt;/code> keeps &lt;code>did&lt;/code>&amp;rsquo;s 19 arguments in order and appends the chained settings it needs. For panel data, &lt;code>mode = NULL&lt;/code> runs the chained conditional test; &lt;code>mode = &amp;quot;ordinary&amp;quot;&lt;/code> and repeated cross sections go to &lt;code>did::conditional_did_pretest()&lt;/code>.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Argument&lt;/th>
&lt;th>Meaning in chained mode&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>est_method&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;ipw&amp;quot;&lt;/code> (default), &lt;code>&amp;quot;reg&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>. A custom function returns a result with status &lt;code>&amp;quot;not_applicable&amp;quot;&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>xformla&lt;/code>&lt;/td>
&lt;td>Its design columns are the coordinates of the test; variables that appear only in &lt;code>selection_xformla&lt;/code> are not.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>bstrap&lt;/code>, &lt;code>cband&lt;/code>&lt;/td>
&lt;td>Validated only. The test always uses multiplier draws and reports no standard errors.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>biters&lt;/code>, &lt;code>alp&lt;/code>&lt;/td>
&lt;td>Number of multiplier draws and level of the reported critical value.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>pl&lt;/code>, &lt;code>cores&lt;/code>&lt;/td>
&lt;td>Parallel draws when &lt;code>control$workers&lt;/code> declares them; results equal those of &lt;code>cores = 1&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>anticipation&lt;/code>, &lt;code>base_period&lt;/code>, &lt;code>fix_weights&lt;/code>, &lt;code>frame&lt;/code>, the &lt;code>selection&lt;/code> arguments, &lt;code>imputation_pooling&lt;/code>, &lt;code>outcome_pooling&lt;/code>, &lt;code>control&lt;/code>&lt;/td>
&lt;td>The chained settings of &lt;code>att_gt()&lt;/code>, with the same meanings; they select the fitted route whose comparisons before treatment are tested.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>GMM weighting, &lt;code>cross_pair&lt;/code> and the parallel-trends settings are not arguments of the test.&lt;/p>
&lt;h2 id="chain-inspection-arguments">Chain inspection arguments&lt;/h2>
&lt;p>&lt;code>chain_report()&lt;/code> inspects the identification paths and moment combination weights stored in a chained &lt;code>att_gt()&lt;/code> result (&lt;code>cdid_MP&lt;/code>), without refitting.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Argument&lt;/th>
&lt;th>Default&lt;/th>
&lt;th>Meaning&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>object&lt;/code>&lt;/td>
&lt;td>required&lt;/td>
&lt;td>A &lt;code>cdid_MP&lt;/code> result produced by &lt;code>att_gt()&lt;/code> in chained mode.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cohort&lt;/code>, &lt;code>group&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>Optional numeric vector of treatment cohorts to filter on (supply at most one).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>time&lt;/code>, &lt;code>t&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>Optional numeric vector of calendar periods to filter on (supply at most one).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>include_pre&lt;/code>&lt;/td>
&lt;td>&lt;code>FALSE&lt;/code>&lt;/td>
&lt;td>When &lt;code>FALSE&lt;/code> and &lt;code>time&lt;/code>/&lt;code>t&lt;/code> is &lt;code>NULL&lt;/code>, only post-treatment cells are included.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>tol&lt;/code>&lt;/td>
&lt;td>&lt;code>1e-10&lt;/code>&lt;/td>
&lt;td>Nonnegative threshold below which near-zero GMM moment weights are omitted from the active weight table.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="refusals">Refusals&lt;/h2>
&lt;p>The class names below let scripts distinguish errors. For guidance on what to check, see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Troubleshooting&lt;/a>.&lt;/p>
&lt;p>Refusals are errors that inherit class &lt;code>cdid_error&lt;/code>. The most common classes are:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Class&lt;/th>
&lt;th>Cause&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>cdid_mode_error&lt;/code>&lt;/td>
&lt;td>invalid &lt;code>mode&lt;/code>, or invalid &lt;code>panel&lt;/code> while resolving &lt;code>mode = NULL&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_chained_panel&lt;/code>&lt;/td>
&lt;td>chained mode with &lt;code>panel&lt;/code> not equal to &lt;code>TRUE&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_chained_balanced&lt;/code>&lt;/td>
&lt;td>explicit &lt;code>allow_unbalanced_panel = FALSE&lt;/code> in chained mode&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_chained_unavailable&lt;/code>&lt;/td>
&lt;td>an unsupported request, such as an unknown &lt;code>est_method&lt;/code> string (also &lt;code>cdid_chained_request_est_method&lt;/code>)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_chained_request_unsupported_selection&lt;/code>&lt;/td>
&lt;td>an unsupported missing-outcome correction, including custom callbacks with change imputation or the augmented correction&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_chained_request_*&lt;/code>&lt;/td>
&lt;td>other unsupported requests or inputs, for example invalid &lt;code>pt_start&lt;/code> values&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_chained_request_parallel_error&lt;/code>&lt;/td>
&lt;td>&lt;code>pl = TRUE, cores = k&lt;/code> beyond the declared &lt;code>control$workers&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_chained_public_control_error&lt;/code>&lt;/td>
&lt;td>an invalid &lt;code>control&lt;/code> list&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_custom_ipw_error&lt;/code>&lt;/td>
&lt;td>malformed or nonfinite output of a custom IPW function&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_chained_request_no_inffunc_error&lt;/code>&lt;/td>
&lt;td>&lt;code>aggte()&lt;/code> on a result fitted with &lt;code>compute_inffunc = FALSE&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_static_*&lt;/code> / &lt;code>cdid_static_error&lt;/code>&lt;/td>
&lt;td>invalid static &lt;code>dname&lt;/code> request (for example missing binary treatment values, inapplicable cohort options, invalid &lt;code>switchers&lt;/code>, &lt;code>switch_times&lt;/code>, &lt;code>imputation_scale&lt;/code> or &lt;code>outcome_pooling&lt;/code> partition)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cdid_untested_upstream&lt;/code>&lt;/td>
&lt;td>loading the package with &lt;code>did&lt;/code> older than 2.5.1 or &lt;code>DRDID&lt;/code> older than 1.4.0&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;code>aggte()&lt;/code> on a static result gives the upstream error that an &lt;code>MP&lt;/code> object is required. Use &lt;code>fit$aggregate&lt;/code> for the static switcher-weighted average.&lt;/p>
&lt;p>Fits can also stop because a numeric workspace or work limit would be exceeded, or because a model fit, covariance or solve is invalid. Such failures concern the computation; they are not conclusions about whether an effect is identified in the population. Nothing is dropped or relaxed to make a fit succeed.&lt;/p>
&lt;h2 id="tested-versions-and-dependencies">Tested versions and dependencies&lt;/h2>
&lt;p>The package requires R 4.1 or later, &lt;code>did&lt;/code> 2.5.1 or later and &lt;code>DRDID&lt;/code> 1.4.0 or later. Install these dependencies from CRAN. See the &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md#installation" target="_blank" rel="noopener">installation instructions&lt;/a>.&lt;/p>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 18 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;strong>Options&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>—&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/static-entry-exit/">Static entry, exit and re-entry (&lt;code>dname&lt;/code> route)&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>Parallel trends: PT-post, PT-ctrl, and PT-all</title><link>https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/</guid><description>&lt;p>Results below were produced on October 29, 2026 with &lt;code>cdid&lt;/code> 1.1.0.0, &lt;code>did&lt;/code> 2.5.1 and &lt;code>DRDID&lt;/code> 1.3.0 under R 4.5.2, using the displayed seeds where applicable. These are individual examples; they do not establish repeated-sample coverage.&lt;/p>
&lt;p>&lt;code>pt_assumption&lt;/code> chooses which parallel trends restrictions the estimator imposes. With &lt;code>&amp;quot;post&amp;quot;&lt;/code>, the default, untreated outcomes of each cohort and its controls are assumed to move in parallel from the cohort&amp;rsquo;s reference period onward. With &lt;code>&amp;quot;ctrl&amp;quot;&lt;/code>, clean control cohorts $k &amp;gt; g$ are additionally assumed to share untreated trends from &lt;code>pt_start&lt;/code> onward (defaulting to the earliest stored calendar date when &lt;code>pt_start = NULL&lt;/code>), while target cohort $g$&amp;rsquo;s own pre-reference trends remain unrestricted (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>). With &lt;code>&amp;quot;all&amp;quot;&lt;/code>, every one of those restrictions is kept and further restrictions are added for both target and control cohorts between an explicit common start date &lt;code>pt_start&lt;/code> and each cohort&amp;rsquo;s reference period. How effects before treatment are reported is a separate choice, made with &lt;code>base_period&lt;/code>.&lt;/p>
&lt;h2 id="reference-period-and-anticipation">Reference period and anticipation&lt;/h2>
&lt;p>The reference period of cohort g is the latest date d in the stored calendar (the sorted dates present in the data) such that &lt;code>d + anticipation &amp;lt; g&lt;/code>. This cutoff uses numeric date values; it is distinct from the stored-calendar index gap used for OR/imputation durations. Every effect of the cohort is measured relative to it. Dates after the reference period and before g are anticipation periods, in which effects may already be nonzero.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Cohort g&lt;/th>
&lt;th>&lt;code>anticipation&lt;/code>&lt;/th>
&lt;th>Reference period with dates 1, 2, &amp;hellip;, 6&lt;/th>
&lt;th>Anticipation periods&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>0&lt;/td>
&lt;td>2&lt;/td>
&lt;td>none&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>1&lt;/td>
&lt;td>1&lt;/td>
&lt;td>2&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>0&lt;/td>
&lt;td>4&lt;/td>
&lt;td>none&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="pt-post">PT-post&lt;/h2>
&lt;p>Under PT-post, for each cohort g and each qualified causal date used by its catalog, the average untreated outcome of the cohort would have changed from the reference period to t by the same amount as that of its comparison group, conditional on the covariates of &lt;code>xformla&lt;/code> when it has any. The comparison group consists of units never treated or units not yet treated, according to &lt;code>control_group&lt;/code>. Nothing is assumed about trends before the reference period.&lt;/p>
&lt;p>There is no endpoint cutoff that discards comparisons touching earlier dates. Their unrestricted pre-reference contributions must cancel in an identified target, as in the next section. An effect that could be reached only by assuming parallel trends before the reference period is reported as unavailable under PT-post.&lt;/p>
&lt;h2 id="how-the-estimator-uses-the-comparisons">How the estimator uses the comparisons&lt;/h2>
&lt;p>The reference period anchors the target. It need not be observed for every unit, and a useful comparison need not start there. The package works with a joint system rather than selecting one path through the dates:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>What enters the calculation&lt;/th>
&lt;th>What it requires&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1. Form comparisons&lt;/td>
&lt;td>All valid ordered-pair cohort-minus-eligible-control moments in the retained catalog, including longer spans and valid fixed-horizon control-pool reuses&lt;/td>
&lt;td>Observed pairs in the cohort and eligible controls, overlap and the support needed by active models&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2. Reconstruct population changes&lt;/td>
&lt;td>The treatment adjustment and, when requested, the observation weighting, change imputation or augmented correction&lt;/td>
&lt;td>Each comparison must reconstruct its stated cohort and control populations under the same fixed covariate and weight reference law whenever cancellation is used&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3. Build the PT model&lt;/td>
&lt;td>Population comparison means $d = A\theta$, with treatment effects and unrestricted earlier trend differentials in $\theta$&lt;/td>
&lt;td>PT-post leaves pre-reference differentials free; PT-ctrl equates clean control-cohort pre-reference trends from &lt;code>pt_start&lt;/code> onward while leaving target pre-reference trends free; PT-all sets represented in-window differentials to zero.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4. Recover supported targets&lt;/td>
&lt;td>GMM combines the estimated comparisons, accounting for their joint covariance and fitted-model uncertainty&lt;/td>
&lt;td>A target contrast must be recoverable from the rows of the maintained model. Covariance regularization is a separate step.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>In $d = A\theta$, a row of $A$ records which effects or free trend differentials enter one comparison, with their signs. A target is estimable when some combination of these rows isolates its contrast. This is the row-space condition. Under PT-post, every unrestricted term in that combination must cancel. A visible path in an observation graph alone does not establish this, especially when different comparisons use different not-yet-treated control pools.&lt;/p>
&lt;p>The sample vector $\hat d$ estimates $d$. It need not satisfy the population equations exactly, and GMM uses the whole retained system to combine the sample information. Exact structural reductions preserve all original comparisons, their full metric and their complete influence functions. They do not replace the system with a smaller identification forest. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/#exact-structural-reductions-and-the-full-comparison-metric">GMM weighting&lt;/a> explains this distinction.&lt;/p>
&lt;h2 id="comparisons-through-earlier-dates">Comparisons through earlier dates&lt;/h2>
&lt;p>Consider stored dates 1, 2, 3, 4 and 5, cohort $g = 3$, zero anticipation and reference period $b_3 = 2$. Use the same never-treated control pool and the same reference population law in both comparisons. Suppose units are observed in windows ${1,2}$ or ${1,4}$, with no unit observed at both 2 and 4. Dates 3 and 5 can remain in the stored calendar through rows whose outcomes are &lt;code>NA&lt;/code>.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Observation group (cohort 3 and controls alike)&lt;/th>
&lt;th>Period 1&lt;/th>
&lt;th>Period 2&lt;/th>
&lt;th>Period 3&lt;/th>
&lt;th>Period 4&lt;/th>
&lt;th>Period 5&lt;/th>
&lt;th>Change it supplies&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>First group&lt;/td>
&lt;td>observed&lt;/td>
&lt;td>observed&lt;/td>
&lt;td>missing&lt;/td>
&lt;td>missing&lt;/td>
&lt;td>missing&lt;/td>
&lt;td>1 to 2&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Second group&lt;/td>
&lt;td>observed&lt;/td>
&lt;td>missing&lt;/td>
&lt;td>missing&lt;/td>
&lt;td>observed&lt;/td>
&lt;td>missing&lt;/td>
&lt;td>1 to 4&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Let $a_2-a_1$ denote the unrestricted untreated cohort-minus-control trend differential from 1 to 2. Write $d_{st}$ for the population comparison from $s$ to $t$. PT-post restricts untreated trends from 2 onward, so&lt;/p>
&lt;p>$$
d_{14} = \mathrm{ATT}(3,4) + a_2-a_1, \qquad d_{12} = a_2-a_1.
$$&lt;/p>
&lt;p>The two-row model and its target combination are&lt;/p>
&lt;p>$$
\begin{pmatrix}d_{14}\d_{12}\end{pmatrix} =
\begin{pmatrix}1&amp;amp;1\0&amp;amp;1\end{pmatrix}
\begin{pmatrix}\mathrm{ATT}(3,4)\a_2-a_1\end{pmatrix},
\qquad d_{14}-d_{12}=\mathrm{ATT}(3,4).
$$&lt;/p>
&lt;p>Subtraction cancels the earlier differential without assuming that it is zero. This is a population identity for the same cohort and control populations. The two windows can contain different units, whose changes need only be representative in mean over their respective pairs. Their fitted comparisons need not telescope exactly in the sample. Catalog support, overlap and the observation/model assumptions remain required.&lt;/p>
&lt;p>If the ${1,2}$ window is absent and the only available comparison is $d_{14}$, the effect and $a_2-a_1$ cannot be separated under this PT-post model. PT-all with &lt;code>pt_start = 1&lt;/code> sets the earlier differential to zero, which makes the effect recoverable from $d_{14}$ if its other assumptions hold. A false restriction biases that recovery.&lt;/p>
&lt;h3 id="why-the-control-pool-must-match">Why the control pool must match&lt;/h3>
&lt;p>With &lt;code>control_group = &amp;quot;notyettreated&amp;quot;&lt;/code>, the largest eligible control set can differ from one pair to another. A comparison over ${1,2}$ may use cohorts that are already treated by date 4, while a comparison over ${1,4}$ must exclude them. Their unrestricted early differentials are then different parameters and need not cancel.&lt;/p>
&lt;p>The catalog therefore retains valid common, fixed-horizon control-pool reevaluations alongside every original valid comparison. For an earlier pair, a fixed-horizon reuse evaluates it with controls that remain eligible through the specified later horizon. This can provide the same control pool and reference law for the subtraction above. Only the retained, qualified combinations justify cancellation. The package does not assume that any connected sequence of different control pools supplies the needed equality, and clean control dates alone do not establish parallel trends or valid observation reconstruction.&lt;/p>
&lt;h2 id="pt-ctrl-and-cross-pair-chaining">PT-ctrl and cross-pair chaining&lt;/h2>
&lt;p>&lt;code>pt_assumption = &amp;quot;ctrl&amp;quot;&lt;/code> sits strictly between PT-post and PT-all for any individual target cohort $g$:&lt;/p>
&lt;ul>
&lt;li>Clean later-treated control cohorts $k, k' &amp;gt; g$ share conditional untreated trends from &lt;code>pt_start&lt;/code> onward (defaulting to the earliest stored calendar date when &lt;code>pt_start = NULL&lt;/code>), merging pool-specific pre-reference control coordinates into one shared baseline trajectory $\lambda_g(u)$ for $u \ge \text{pt_start}$.&lt;/li>
&lt;li>Target cohort $g$&amp;rsquo;s own pre-reference trajectory $\gamma_g(u)$ for $u &amp;lt; b_g$ remains unrestricted, so target-only pre-treatment shocks before $b_g$ do not bias post-treatment ATT estimates.&lt;/li>
&lt;/ul>
&lt;p>When &lt;code>cross_pair = TRUE&lt;/code>, target-cohort and clean control-cohort within-unit changes are evaluated separately rather than requiring both groups to be observed on the identical date pair $(s, t)$, allowing identification across staggered or non-overlapping observation windows. See &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a> and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a> for the identification conditions and worked examples.&lt;/p>
&lt;h2 id="pt-all">PT-all&lt;/h2>
&lt;p>Set &lt;code>pt_assumption = &amp;quot;all&amp;quot;&lt;/code> and give &lt;code>pt_start&lt;/code>, one finite numeric date that matches a date of the stored calendar exactly and is common to all cohorts. PT-all then:&lt;/p>
&lt;ul>
&lt;li>keeps every PT-post restriction, including at treated dates earlier than the start;&lt;/li>
&lt;li>keeps each cohort&amp;rsquo;s original reference period;&lt;/li>
&lt;li>restricts the represented pre-reference trend differentials for each cohort and its catalog control operators between &lt;code>pt_start&lt;/code> and the original reference period to zero;&lt;/li>
&lt;li>leaves trends before &lt;code>pt_start&lt;/code> and anticipation effects unrestricted;&lt;/li>
&lt;li>uses the same comparisons, comparison groups and combination step as PT-post, and keeps every assumption about sampling, missing outcomes, overlap and models.&lt;/li>
&lt;/ul>
&lt;p>The added restrictions can make previously unavailable effects estimable, as in the example above. When the effects are already available, valid and informative restrictions can also improve precision. Neither gain is guaranteed: a particular standard error can move in either direction, and restrictions that are false bias the estimates. &amp;ldquo;All&amp;rdquo; refers to the dates from the chosen start onward, not to every historical date.&lt;/p>
&lt;p>Algebraically, PT-all writes $\theta = H\eta$, where $H$ keeps the free parameters and sets only those represented in-window pre-reference differentials to zero. The model becomes $d = AH\eta$. The comparison catalog, population references and GMM combination remain the same. Earlier differentials stay free, and anticipation contributions remain free causal effects rather than imposed zeros. PT-all changes the restrictions within this estimator. It does not activate a separate efficiency estimator.&lt;/p>
&lt;p>A comparison between two restricted pre-reference dates can then have a zero row in $AH$: its model mean is zero for every $\eta$. The observed comparison is still noisy and may be correlated with comparisons that load on the treatment effects. Under covariance-weighted joint GMM, that correlation can inform the effect combination. Such zero-loading rows remain in the moment system rather than being discarded.&lt;/p>
&lt;p>&lt;code>pt_start&lt;/code> is required under PT-all: omitting it, passing &lt;code>NULL&lt;/code> or giving a date that is not in the stored calendar is an error, and no rounding or default date is used. Under PT-post, a non &lt;code>NULL&lt;/code> &lt;code>pt_start&lt;/code> is refused.&lt;/p>
&lt;h2 id="when-pt-all-adds-nothing">When PT-all adds nothing&lt;/h2>
&lt;p>If no cohort has a represented step between &lt;code>pt_start&lt;/code> and its reference period, PT-all adds no restriction. The fit still runs, the model is the PT-post model, and &lt;code>summary()&lt;/code> reports &amp;ldquo;No additional restrictions&amp;rdquo;. This happens, for example, when &lt;code>pt_start&lt;/code> equals the reference period of every cohort, or when anticipation moves the reference period back to the start. The result records the count of added restrictions for each cohort, so you can see where the assumption has content.&lt;/p>
&lt;h2 id="choosing-the-start-date">Choosing the start date&lt;/h2>
&lt;p>Choose &lt;code>pt_start&lt;/code> from knowledge of the application, for example the earliest period from which untreated trends are believed to be parallel, before looking at estimates, standard errors or pretrend tests. A start selected by searching for precise or significant results invalidates the interpretation of the restrictions.&lt;/p>
&lt;h2 id="reporting-with-base_period">Reporting with base_period&lt;/h2>
&lt;p>&lt;code>base_period&lt;/code> controls how cells before treatment are reported, with &lt;code>did&lt;/code>&amp;rsquo;s meaning and default. It does not change the parallel trends assumption, and &lt;code>pt_assumption&lt;/code> does not change the reporting.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;code>base_period&lt;/code>&lt;/th>
&lt;th>Cells before treatment&lt;/th>
&lt;th>Cells from treatment onward&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>&amp;quot;varying&amp;quot;&lt;/code> (default)&lt;/td>
&lt;td>each stored period after the first compared with the preceding stored period&lt;/td>
&lt;td>each period compared with the reference period&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;universal&amp;quot;&lt;/code>&lt;/td>
&lt;td>each period compared with the reference period; the cell at the reference period is an exact zero&lt;/td>
&lt;td>each period compared with the reference period&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Under both values of &lt;code>base_period&lt;/code>, cells before treatment under PT-post (and under PT-ctrl or PT-all when &lt;code>cross_pair = FALSE&lt;/code>) are direct comparisons with no restriction imposed; when &lt;code>cross_pair = TRUE&lt;/code> under PT-ctrl, in-window pre-reference target differentials solved from the catalog remain unrestricted target-minus-shared-control contrasts. Restricted zeros of PT-all never appear among them.&lt;/p>
&lt;h2 id="pretrend-tests-under-each-choice">Pretrend tests under each choice&lt;/h2>
&lt;p>The fit reports a Wald test of all declared nonreference pretrend cells of the chosen &lt;code>base_period&lt;/code>, stored as &lt;code>W&lt;/code> and &lt;code>Wpval&lt;/code>. Exact reference zeros are identities and are excluded. The test is computed only when every tested cell is available and the full covariance passes the existing Cholesky/solve and conditioning policy; otherwise the test is unavailable and the reason is recorded. A test on a subset of the cells is never substituted.&lt;/p>
&lt;p>Under PT-ctrl or PT-all, a cell that involves dates before &lt;code>pt_start&lt;/code> can reject without contradicting the assumption from the chosen start, and cells in anticipation periods need not be zero. Descriptive tags mark each comparison before treatment as lying before the start, inside the window or in the anticipation periods. An in-window tag implies a zero contrast only under PT-all and that comparison&amp;rsquo;s actual control operator and selection/trend premises (under PT-ctrl, target pre-reference trends remain unrestricted); an auxiliary not-yet-treated pool absent from the catalog assumptions is not covered by its date tag alone. A test that does not reject does not establish parallel trends, and restricted zeros are never used as evidence for them.&lt;/p>
&lt;p>&lt;code>conditional_did_pretest()&lt;/code> runs a separate conditional test, described in the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#pretrend-tests">results reference&lt;/a>. Its arguments do not include the PT-ctrl or PT-all settings.&lt;/p>
&lt;h2 id="example">Example&lt;/h2>
&lt;p>This example reuses &lt;code>sim_panel&lt;/code> from &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/#prepare-the-panel">Get started&lt;/a>; run that code first. Cohort 3 has reference period 2, and the simulation satisfies parallel trends at every date, so a restriction from period 1 is valid.&lt;/p>
&lt;pre>&lt;code class="language-r">fit_post &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
data = sim_panel, control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;ipw&amp;quot;,
pt_assumption = &amp;quot;post&amp;quot;,
bstrap = FALSE, cband = FALSE
)
fit_all &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
data = sim_panel, control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;ipw&amp;quot;,
pt_assumption = &amp;quot;all&amp;quot;, pt_start = 1,
bstrap = FALSE, cband = FALSE
)
fit_all_start2 &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
data = sim_panel, control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;ipw&amp;quot;,
pt_assumption = &amp;quot;all&amp;quot;, pt_start = 2,
bstrap = FALSE, cband = FALSE
)
fit_all_universal &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
data = sim_panel, control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;ipw&amp;quot;,
pt_assumption = &amp;quot;all&amp;quot;, pt_start = 1, base_period = &amp;quot;universal&amp;quot;,
bstrap = FALSE, cband = FALSE
)
fit_all$chained$pt$by_cohort
fit_all_start2$chained$pt$no_extra_restrictions
summary(fit_all_start2)
compare &amp;lt;- merge(
data.frame(group = fit_post$group, time = fit_post$t,
post = fit_post$att, post_se = fit_post$se),
data.frame(group = fit_all$group, time = fit_all$t,
all = fit_all$att, all_se = fit_all$se),
by = c(&amp;quot;group&amp;quot;, &amp;quot;time&amp;quot;)
)
compare
cdid::tidy(fit_all_universal)[, c(&amp;quot;target.id&amp;quot;, &amp;quot;role&amp;quot;, &amp;quot;estimate&amp;quot;, &amp;quot;std.error&amp;quot;)]
&lt;/code>&lt;/pre>
&lt;details>
&lt;summary>Console output&lt;/summary>
&lt;pre>&lt;code class="language-text">g ref pt_start baseline_status n_extra_calendar_dates n_extra_represented_dates
1 3 2 1 stored_reference 1 1
n_restricted_pre_parameters n_zero_loading_links no_extra_calendar_window no_extra_restrictions
1 1 1 FALSE FALSE
[1] TRUE
cdid chained difference-in-differences (chained IPW-GMM): cdid_MP
cdid 1.1.0.0 result built on did 2.5.1 (tested: did 2.5.1); did's MP methods tabulate the estimates below.
Chained estimators: Bellego C., Benatia D. and V. Dortet-Bernadet (2025). &amp;quot;The Chained Difference-in-Differences.&amp;quot; Journal of Econometrics 248, 105783. doi:10.1016/j.jeconom.2024.105783.
Ordinary estimators: Callaway B. and P. H. C. Sant'Anna (2021). &amp;quot;Difference-in-Differences with Multiple Time Periods.&amp;quot; Journal of Econometrics 225(2), 200-230. doi:10.1016/j.jeconom.2020.12.001.
Call:
cdid::att_gt(yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
data = sim_panel, control_group = &amp;quot;nevertreated&amp;quot;, est_method = &amp;quot;ipw&amp;quot;,
pt_assumption = &amp;quot;all&amp;quot;, pt_start = 2, bstrap = FALSE, cband = FALSE)
Group-Time Average Treatment Effects:
Group Time ATT(g,t) Std. Error [95% Pointwise Conf. Band]
3 2 -0.0583 0.0637 -0.1832 0.0665
3 3 1.0096 0.0632 0.8858 1.1334 *
3 4 1.3274 0.0616 1.2066 1.4482 *
3 5 1.4837 0.0630 1.3603 1.6072 *
3 6 1.8478 0.0630 1.7243 1.9713 *
---
Signif. codes: `*' confidence band does not cover 0
P-value for pre-test of parallel trends assumption: 0.359889309273502
Control Group: Never Treated, Anticipation Periods: 0
Estimation Method: Inverse Probability Weighting
Chained support: 5 of 5 requested cells available.
Units: 2000 in the unit table, 2000 observed at all 6 dates, 2000 with at least two observed outcomes.
Observation correction: none (selection = &amp;quot;none&amp;quot;).
Parallel trends: PT-all from common stored date 2, in addition to every PT-post restriction; base_period = &amp;quot;varying&amp;quot;.
No additional restrictions (PT-post-equivalent model).
Cohort 3: reference period 2; stored window dates 0; represented restrictions 0.
GMM weighting: optimal (two-step); covariance regularization: not applied (moment covariance well conditioned).
Inference: analytic standard errors, unit-level; pointwise intervals.
Parallel-trends pre-test: W = 0.838279, df = 1, p = 0.3599 (Wald test of the pretrend cell).
group time post post_se all all_se
1 3 2 -0.05831968 0.06369725 -0.05831968 0.06369725
2 3 3 1.00962257 0.06316956 0.98062848 0.05465855
3 3 4 1.32743963 0.06163755 1.29986751 0.05378014
4 3 5 1.48374276 0.06297661 1.45503400 0.05461554
5 3 6 1.84780436 0.06303371 1.81769972 0.05377841
target.id role estimate std.error
1 pre(g=3,t=1) pre 0.05831968 0.06369725
2 reference(g=3,t=2) reference 0.00000000 0.00000000
3 ATT(g=3,t=3) post 0.98062848 0.05465855
4 ATT(g=3,t=4) post 1.29986751 0.05378014
5 ATT(g=3,t=5) post 1.45503400 0.05461554
6 ATT(g=3,t=6) post 1.81769972 0.05377841
&lt;/code>&lt;/pre>
&lt;/details>
&lt;p>&lt;strong>What the design implies.&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>&lt;code>fit_all&lt;/code>: the stored calendar has one date, period 1, between the start and the reference period of cohort 3, so the record for cohort 3 should show one window date and the restriction it represents. The restriction is true in this simulation. The effects from period 3 onward may differ from those of &lt;code>fit_post&lt;/code>, and so may their standard errors, in either direction for a particular draw.&lt;/li>
&lt;li>&lt;code>fit_all_start2&lt;/code>: the start equals the reference period, so no restriction is added. &lt;code>no_extra_restrictions&lt;/code> should be &lt;code>TRUE&lt;/code>, the summary should report &amp;ldquo;No additional restrictions&amp;rdquo;, and the estimates should equal those of &lt;code>fit_post&lt;/code>.&lt;/li>
&lt;li>&lt;code>fit_all_universal&lt;/code>: only the reporting of cells before treatment changes. The cell for period 1 is now measured relative to period 2, the cell at period 2 is an exact zero with role &lt;code>&amp;quot;reference&amp;quot;&lt;/code>, and the effects from period 3 onward should equal those of &lt;code>fit_all&lt;/code>.&lt;/li>
&lt;/ul>
&lt;h2 id="where-the-result-records-the-choice">Where the result records the choice&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Location&lt;/th>
&lt;th>Contents&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>fit$chained$pt&lt;/code>&lt;/td>
&lt;td>&lt;code>pt_assumption&lt;/code> and &lt;code>pt_start&lt;/code>; under PT-ctrl or PT-all also the totals &lt;code>n_extra_calendar_dates&lt;/code> and &lt;code>n_restricted_pre_parameters&lt;/code>, the flag &lt;code>no_extra_restrictions&lt;/code>, the assumption text and the table &lt;code>by_cohort&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>fit$chained$pt$by_cohort&lt;/code>&lt;/td>
&lt;td>one row per cohort: &lt;code>g&lt;/code>, its reference period &lt;code>ref&lt;/code>, &lt;code>pt_start&lt;/code>, &lt;code>n_extra_calendar_dates&lt;/code>, &lt;code>n_extra_represented_dates&lt;/code>, &lt;code>n_restricted_pre_parameters&lt;/code>, &lt;code>no_extra_calendar_window&lt;/code> and &lt;code>no_extra_restrictions&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>fit$chained$base_period&lt;/code>, &lt;code>fit$DIDparams$base_period&lt;/code>&lt;/td>
&lt;td>the reporting choice&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>summary(fit)&lt;/code>&lt;/td>
&lt;td>the parallel trends assumption and &lt;code>base_period&lt;/code>; under PT-ctrl or PT-all also the common start, the number of added restrictions (or &amp;ldquo;No additional restrictions&amp;rdquo;) and a line for each cohort&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 13 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;strong>Parallel trends&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>Prepare your panel and unit table</title><link>https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/</guid><description>&lt;p>Preparing longitudinal data carefully before calling &lt;code>cdid::att_gt()&lt;/code> prevents common input errors and ensures that the fitted model targets your intended study population. This page explains how to format the long panel table (&lt;code>data&lt;/code>) and the table of study units (&lt;code>frame&lt;/code>), how &lt;code>cdid&lt;/code> distinguishes units with repeated observations from units with one or no observed outcomes, how reference dates work when covariates or sampling weights change over time, and how to diagnose data and model issues.&lt;/p>
&lt;p>For an introduction to how chained difference in differences combines outcome changes across observation windows, see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Estimate treatment effects from incomplete panels&lt;/a>, &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>, and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Coming from &lt;code>did&lt;/code>&lt;/a>.&lt;/p>
&lt;h2 id="if-treatment-can-stop-and-restart">If treatment can stop and restart&lt;/h2>
&lt;p>For the static binary &lt;code>dname&lt;/code> model, supply a row for every unit and study date, with a known &lt;code>0&lt;/code> or &lt;code>1&lt;/code> treatment indicator even when the outcome is &lt;code>NA&lt;/code>. Required covariates must be known at the transition reference dates. Units may already be treated at the first study date; their earlier adoption date is not needed for this static model. Missing treatment histories are not supported.&lt;/p>
&lt;p>The static model assumes no lingering effect of past treatment. Its input is the long &lt;code>data&lt;/code> table, without a separate &lt;code>frame&lt;/code> argument. The &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/static-entry-exit/#what-your-input-needs">entry and exit guide&lt;/a> gives the complete input requirements and a runnable example.&lt;/p>
&lt;p>The rest of this page describes the absorbing-treatment &lt;code>gname&lt;/code> interface, including its unit table, sampling weights and cohort reference dates.&lt;/p>
&lt;h2 id="core-requirements-for-data-and-frame">Core requirements for &lt;code>data&lt;/code> and &lt;code>frame&lt;/code>&lt;/h2>
&lt;p>On the cohort route, &lt;code>cdid::att_gt()&lt;/code> reads a long panel data frame (&lt;code>data&lt;/code>) and an optional table of study units (&lt;code>frame&lt;/code>, referred to after first introduction as the unit table).&lt;/p>
&lt;p>For the simplest unweighted specification without covariates or clustering, the essential columns are a unit identifier, a finite numeric date, a numeric outcome with &lt;code>NA&lt;/code> for missing values, and the unit&amp;rsquo;s known first-treatment cohort (constant within unit, with &lt;code>0&lt;/code> for never treated). Each unit/date pair must be unique. A balanced panel and an observed outcome at the reference date for every unit are not required. Valid columns, or two observed outcomes per unit, do not by themselves guarantee that the requested effects are estimable.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Requirement&lt;/th>
&lt;th>Column or argument&lt;/th>
&lt;th>Rule in &lt;code>cdid&lt;/code>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Long panel rows&lt;/td>
&lt;td>&lt;code>data&lt;/code>&lt;/td>
&lt;td>One row per unit and calendar date observation.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Unique unit and date pairs&lt;/td>
&lt;td>&lt;code>idname&lt;/code>, &lt;code>tname&lt;/code>&lt;/td>
&lt;td>&lt;code>idname&lt;/code> is required in chained mode because observations are aligned by unit identity. Every &lt;code>(idname, tname)&lt;/code> pair in &lt;code>data&lt;/code> must be unique.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Stored ordered numeric dates&lt;/td>
&lt;td>&lt;code>tname&lt;/code>&lt;/td>
&lt;td>Calendar dates must be finite numeric values. &lt;code>cdid&lt;/code> sorts the distinct stored dates $t_1 &amp;lt; t_2 &amp;lt; \dots &amp;lt; t_T$ and measures duration in shared outcome regression and change imputation models by the stored calendar index gap $L_e = i_t - i_s$ between ordered calendar positions $i_s &amp;lt; i_t$, rather than raw subtraction $t - s$ of date labels. Under &lt;code>pt_assumption = &amp;quot;all&amp;quot;&lt;/code>, &lt;code>pt_start&lt;/code> must match an exact finite date in this stored calendar.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Constant treatment cohort&lt;/td>
&lt;td>&lt;code>gname&lt;/code>&lt;/td>
&lt;td>Each unit&amp;rsquo;s first treatment period must be constant across all of its rows in &lt;code>data&lt;/code> and agree with &lt;code>frame&lt;/code>. Units never treated must be coded as &lt;code>0&lt;/code> (&lt;code>gname == 0&lt;/code>). Treated cohorts use a finite positive treatment date in the same numeric scale as &lt;code>tname&lt;/code>; it need not itself be a stored observation date.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Numeric outcomes, missing values kept as &lt;code>NA&lt;/code>&lt;/td>
&lt;td>&lt;code>yname&lt;/code>&lt;/td>
&lt;td>Observed values must be finite numeric outcomes. Keep missing outcomes as &lt;code>NA&lt;/code>. Never substitute &lt;code>0&lt;/code> or carry forward prior outcome values in place of a missing outcome.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Unit table of the study population&lt;/td>
&lt;td>&lt;code>frame&lt;/code>&lt;/td>
&lt;td>Optional data frame with one row per study unit, covering every ID in &lt;code>data&lt;/code> with the same ID type. Supply required cohort, weight, cluster and covariate attributes here when they are not available from panel rows; changing values are read from dated rows in &lt;code>data&lt;/code>. At most one cluster variable beyond &lt;code>idname&lt;/code> is accepted.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="never-impute-zero-for-missing-outcomes">Never impute zero for missing outcomes&lt;/h3>
&lt;p>A frequent data preparation mistake is replacing missing outcomes (&lt;code>NA&lt;/code>) with &lt;code>0&lt;/code> before passing &lt;code>data&lt;/code> to an estimator. In chained DiD, replacing a missing outcome $Y_{i,t}$ with &lt;code>0&lt;/code> tells the software that unit $i$ was actually observed at date $t$ with an outcome equal to zero. Doing so corrupts both the observation indicators $S_{i,e}$ for every date pair touching date $t$ and the within unit changes $\Delta Y_{s,t} = Y_t - Y_s$. Always retain &lt;code>NA&lt;/code> for unobserved outcomes.&lt;/p>
&lt;h2 id="the-unit-table-frame-and-unit-observation-roles">The unit table (&lt;code>frame&lt;/code>) and unit observation roles&lt;/h2>
&lt;h3 id="study-population-versus-census">Study population versus census&lt;/h3>
&lt;p>The unit table (&lt;code>frame&lt;/code>) defines the study population $F$ whose treatment effects your analysis estimates. It lists the study units and need not be a census of a wider external population. Any claim that these units represent a wider population needs its own sampling justification. When &lt;code>frame = NULL&lt;/code> (the default), the unique units present in &lt;code>data&lt;/code> (including units with only one observed outcome or all &lt;code>NA&lt;/code> outcomes) define $F$, and no wider external register is presumed. You may omit &lt;code>frame&lt;/code> when every intended study unit appears in &lt;code>data&lt;/code>. Units omitted entirely from &lt;code>data&lt;/code> cannot be recovered from its rows. To retain such zero-observation units in the target population, supply a complete unit table through &lt;code>frame&lt;/code>.&lt;/p>
&lt;p>Required fields depend on the route and the unit&amp;rsquo;s role. Panel units need known, constant cohorts. Baseline estimation can retain frame-only units with unknown cohort when the frame omits &lt;code>gname&lt;/code>, but cohort-share-dependent aggregates are then unavailable. Conditional selection, pure imputation and augmented observation correction require known cohorts on every F row. Supply weights, cluster labels and covariates wherever that route reads them; the package does not infer missing attributes.&lt;/p>
&lt;h3 id="roles-of-units-with-zero-one-or-repeated-observations">Roles of units with zero, one, or repeated observations&lt;/h3>
&lt;p>Across the full unit table $F$ (of size $N = |F|$), study units fall into three nested sets based on how many nonmissing outcomes they have in &lt;code>data&lt;/code>:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>$A$ (units with repeated observations, at least two observed outcomes):&lt;/strong> A unit must be observed at two or more dates to form a within unit outcome change $\Delta Y_{s,t} = Y_t - Y_s$. Units in $A$ contribute outcome changes to the specific date pairs ${s, t}$ where both endpoints $s$ and $t$ are observed. Having at least two observed outcomes makes a unit eligible to contribute changes, though it does not mean the unit is observed at every date pair.&lt;/li>
&lt;li>&lt;strong>$B \setminus A$ (units with one observed outcome, also called singletons):&lt;/strong> A unit observed at only one date cannot form a within unit outcome change, because its single outcome level still contains the unobserved unit fixed effect $\alpha_i$.&lt;/li>
&lt;li>&lt;strong>$F \setminus B$ (units with no observed outcomes):&lt;/strong> Units present in &lt;code>frame&lt;/code> (or present in &lt;code>data&lt;/code> with &lt;code>NA&lt;/code> outcomes at all dates) supply no observed outcomes at all.&lt;/li>
&lt;/ul>
&lt;p>In chained mode, &lt;code>cdid&lt;/code> &lt;strong>never drops&lt;/strong> units with one or zero observed outcomes from the study population $F$:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Population shares and rates:&lt;/strong> Every unit remains in the sample size $N = |F|$ and the appropriate population mass and rate accounting. Cohort shares require known cohort membership; unknown frame-only cohorts make share-dependent aggregates unavailable.&lt;/li>
&lt;li>&lt;strong>Models for handling missing outcomes:&lt;/strong> Under &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, observation probability models (&lt;code>selection_est_method = &amp;quot;ipw&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>) fitted on &lt;code>selection_universe = &amp;quot;F&amp;quot;&lt;/code> evaluate every unit in $F$ (including nonobservers), while change imputation (&lt;code>selection_est_method = &amp;quot;imputation&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>) fits actual change regressions on observed pairs and averages predicted changes across &lt;strong>all&lt;/strong> rows of $F$ in each cohort.&lt;/li>
&lt;li>&lt;strong>Uncertainty and clustering:&lt;/strong> When inference is requested, &lt;code>inffunc&lt;/code> has one row per F unit and carries every active nuisance and rate component, retaining clusters with no A units. Components absent from a chosen method are not fitted.&lt;/li>
&lt;/ol>
&lt;p>When &lt;code>selection_model = &amp;quot;pair_logit&amp;quot;&lt;/code> is used with &lt;code>selection_est_method = &amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>selection_universe&lt;/code> can be set to &lt;code>&amp;quot;F&amp;quot;&lt;/code> (default, all study units), &lt;code>&amp;quot;B&amp;quot;&lt;/code> (units with at least one observed outcome), or &lt;code>&amp;quot;A&amp;quot;&lt;/code> (units with at least two observed outcomes). Choosing &lt;code>&amp;quot;B&amp;quot;&lt;/code> or &lt;code>&amp;quot;A&amp;quot;&lt;/code> fits the pair observation logit on that subset and requires a nonempty &lt;code>selection_justification&lt;/code> string (plus an optional column name in &lt;code>selection_rho&lt;/code> containing known normalized transport ratios when $U \in {A, B}$ is not conditionally independent of covariates given cohort). Fitting the observation logit on &lt;code>&amp;quot;B&amp;quot;&lt;/code> or &lt;code>&amp;quot;A&amp;quot;&lt;/code> does not change the target parameter away from the full study population $F$; it relies on the declared transport assumption, which fit diagnostics cannot verify. Under &lt;code>selection_model = &amp;quot;independent_period_logit&amp;quot;&lt;/code>, &lt;code>selection_est_method = &amp;quot;imputation&amp;quot;&lt;/code>, or &lt;code>selection_est_method = &amp;quot;dr&amp;quot;&lt;/code>, &lt;code>selection_universe&lt;/code> must be &lt;code>&amp;quot;F&amp;quot;&lt;/code> with &lt;code>selection_rho = NULL&lt;/code>. For details, see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a> and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Option reference&lt;/a>.&lt;/p>
&lt;h2 id="panel-mode-selection-and-allow_unbalanced_panel">Panel mode selection and &lt;code>allow_unbalanced_panel&lt;/code>&lt;/h2>
&lt;p>&lt;code>cdid::att_gt()&lt;/code> supports both chained estimation (&lt;code>mode = &amp;quot;chained&amp;quot;&lt;/code>) and ordinary delegation to &lt;code>did::att_gt()&lt;/code> (&lt;code>mode = &amp;quot;ordinary&amp;quot;&lt;/code>). Both modes can analyze balanced or incomplete panels according to their respective options and assumptions.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Default mode (&lt;code>mode = NULL&lt;/code>):&lt;/strong> &lt;code>cdid&lt;/code> evaluates &lt;code>panel&lt;/code> first. When &lt;code>panel = TRUE&lt;/code> (the default), &lt;code>mode = NULL&lt;/code> selects &lt;code>&amp;quot;chained&amp;quot;&lt;/code>. When &lt;code>panel = FALSE&lt;/code> (genuine repeated cross sections), &lt;code>mode = NULL&lt;/code> selects &lt;code>&amp;quot;ordinary&amp;quot;&lt;/code> and forwards the call to &lt;code>did::att_gt()&lt;/code>. Requesting &lt;code>mode = &amp;quot;chained&amp;quot;&lt;/code> with &lt;code>panel = FALSE&lt;/code> raises a typed error (&lt;code>&amp;quot;cdid_chained_panel&amp;quot;&lt;/code>).&lt;/li>
&lt;li>&lt;strong>&lt;code>allow_unbalanced_panel&lt;/code> in chained mode versus ordinary mode:&lt;/strong>
&lt;ul>
&lt;li>In &lt;strong>chained mode&lt;/strong>, both &lt;code>allow_unbalanced_panel = NULL&lt;/code> (the default) and &lt;code>allow_unbalanced_panel = TRUE&lt;/code> retain all supplied units in $F$ and use all units with repeated observations ($A$), whether the panel is balanced or incomplete.&lt;/li>
&lt;li>Passing an explicit &lt;code>allow_unbalanced_panel = FALSE&lt;/code> in chained mode is refused with an error (&lt;code>&amp;quot;cdid_chained_balanced&amp;quot;&lt;/code>) that points to &lt;code>mode = &amp;quot;ordinary&amp;quot;&lt;/code>. &lt;code>cdid&lt;/code> never silently drops incomplete units to switch the target parameter to complete cases.&lt;/li>
&lt;li>In &lt;strong>ordinary mode&lt;/strong> (&lt;code>mode = &amp;quot;ordinary&amp;quot;&lt;/code>), &lt;code>allow_unbalanced_panel = NULL&lt;/code> resolves to &lt;code>did&lt;/code>&amp;rsquo;s default &lt;code>FALSE&lt;/code> (balancing the panel to complete cases), whereas &lt;code>allow_unbalanced_panel = TRUE&lt;/code> forwards &lt;code>TRUE&lt;/code> to &lt;code>did::att_gt()&lt;/code>. See &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Coming from &lt;code>did&lt;/code>&lt;/a> for a direct comparison.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;h2 id="static-versus-changing-covariates-and-sampling-weights">Static versus changing covariates and sampling weights&lt;/h2>
&lt;h3 id="static-covariates-and-weights">Static covariates and weights&lt;/h3>
&lt;p>When covariates (&lt;code>xformla&lt;/code>, &lt;code>selection_xformla&lt;/code>) and sampling weights (&lt;code>weightsname&lt;/code>) are constant within each unit across all rows in &lt;code>data&lt;/code> and agree with &lt;code>frame&lt;/code>, &lt;code>fix_weights = NULL&lt;/code>, &lt;code>fix_weights = &amp;quot;first_period&amp;quot;&lt;/code>, and &lt;code>fix_weights = &amp;quot;base_period&amp;quot;&lt;/code> produce identical estimates. Required covariate coverage still depends on the route: for example, baseline IPW with a static design requires that design for all study units, while baseline OR/DR require it on repeat observers.&lt;/p>
&lt;h3 id="reference-dates-for-covariates-that-change-within-a-unit">Reference dates for covariates that change within a unit&lt;/h3>
&lt;p>When covariates in &lt;code>xformla&lt;/code> or &lt;code>selection_xformla&lt;/code> change across dates within a unit (or when a formula uses &lt;code>tname&lt;/code>), &lt;code>cdid&lt;/code> treats them as reference date covariates:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Posttreatment comparisons:&lt;/strong> Every posttreatment comparison for target cohort $g$ (including intermediate bridges and comparison units) evaluates each unit&amp;rsquo;s covariates at cohort $g$&amp;rsquo;s baseline reference date&lt;/li>
&lt;/ul>
&lt;p>$$b_g = \max{d \in {t_1,\ldots,t_T}: d + \text{anticipation} &amp;lt; g}$$&lt;/p>
&lt;p>This cutoff compares numeric date values, using &lt;code>anticipation&lt;/code> in that scale. It is distinct from the stored-index gap $L_e$ used by outcome regression and imputation. If there is no admissible reference date, the relevant target has no reference support.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Auxiliary preperiod comparisons:&lt;/strong> Preperiod reports evaluate covariates at the earlier endpoint of the date pair.&lt;/li>
&lt;li>&lt;strong>Read from actual &lt;code>(id, date)&lt;/code> rows, including rows with &lt;code>y = NA&lt;/code>:&lt;/strong> Reference date covariate values come directly from the &lt;code>(idname, tname)&lt;/code> rows in &lt;code>data&lt;/code>; a static value in &lt;code>frame&lt;/code> cannot override changing values in &lt;code>data&lt;/code>. Crucially, a unit&amp;rsquo;s covariate row at &lt;code>(id, b_g)&lt;/code> may be needed even when the unit&amp;rsquo;s outcome &lt;code>y&lt;/code> at date $b_g$ is missing (&lt;code>NA&lt;/code>). For instance, if a unit in cohort $g = 3$ (with $b_3 = 2$ under &lt;code>anticipation = 0&lt;/code>) has observed outcomes only at $t = 3$ and $t = 4$, its covariate values at &lt;code>(id, time = 2)&lt;/code> are still required to form the reference design for cohort $g = 3$ comparisons. Keep the &lt;code>(id, time = 2)&lt;/code> row in &lt;code>data&lt;/code> with its covariate values and &lt;code>y = NA&lt;/code>.&lt;/li>
&lt;li>&lt;strong>No blanket full history or baseline outcome requirement:&lt;/strong> You do not need observed outcomes at $b_g$ for every unit, nor do you need covariate rows at dates that no active comparison or model reads. Covariate values are required only at the &lt;code>(id, date)&lt;/code> anchors read by the requested estimator: on observed pairs for baseline treatment adjustment (&lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>), on every unit in $F$ of each cohort for change imputation and doubly robust adjustment for missing outcomes (&lt;code>selection_est_method = &amp;quot;imputation&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>), and on the selection universe for observation probability models. If a required covariate is missing, the default warns and excludes units with missing covariates from the affected cohort’s comparisons. Set &lt;code>missing_reference = &amp;quot;error&amp;quot;&lt;/code> to stop and see the unit ID, date, variable and comparison that needs it.&lt;/li>
&lt;/ul>
&lt;h3 id="add-a-known-reference-covariate-row">Add a known reference covariate row&lt;/h3>
&lt;p>Suppose unit 1 in cohort 3 has outcomes in years 3 and 4, and its year-2
row is absent. If you know its year-2 covariate &lt;code>x&lt;/code> from another source,
add that value on a year-2 row. With &lt;code>y = NA&lt;/code>, the row supplies reference
information and the unit still contributes its change from years 3 to 4.&lt;/p>
&lt;pre>&lt;code class="language-r"># panel has columns id, t, g, y and x.
# x_year2 is unit 1's known covariate in year 2.
panel &amp;lt;- rbind(panel, data.frame(id = 1L, t = 2L, g = 3L,
y = NA_real_, x = x_year2))
&lt;/code>&lt;/pre>
&lt;p>If the row already exists, fill the known covariate on that row. Include
any other required fields, such as cluster or weight information, in your
data. For a variable such as age, a recorded date of birth can supply the
reference value if it determines age at the date used by the analysis.&lt;/p>
&lt;p>If the year-2 value is genuinely unknown, the default excludes unit 1 from
the comparisons for cohort 3. It can still contribute to an eligible
comparison for cohort 4, which uses year-3 covariates. If an affected unit
belongs to the treated cohort, the reported cohort effect describes the
remaining treated units. Review &lt;code>fit$chained$reference_eligibility&lt;/code>
for cohort and reference-date counts.&lt;/p>
&lt;h3 id="changing-sampling-weights-and-fix_weights">Changing sampling weights and &lt;code>fix_weights&lt;/code>&lt;/h3>
&lt;p>When sampling weights change within a unit, &lt;code>fix_weights = NULL&lt;/code> is refused in chained mode. The explicit &lt;code>&amp;quot;varying&amp;quot;&lt;/code> option is refused in chained mode even for static weights. You must specify one of two explicit reference weight rules:&lt;/p>
&lt;ul>
&lt;li>&lt;code>fix_weights = &amp;quot;first_period&amp;quot;&lt;/code>: Every comparison and rate denominator uses each unit&amp;rsquo;s weight $w_{t_1}$ at the first stored calendar date $t_1$.&lt;/li>
&lt;li>&lt;code>fix_weights = &amp;quot;base_period&amp;quot;&lt;/code>: Every comparison in target cohort $g$&amp;rsquo;s context (controls included) uses each unit&amp;rsquo;s weight at cohort $g$&amp;rsquo;s reference date $b_g$.&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Aggregation shares (&lt;code>aggte&lt;/code>) under reference inputs:&lt;/strong> When aggregating reference input fits with &lt;code>cdid::aggte()&lt;/code>, treated cohorts are weighted by their first calendar date masses $w_{t_1}$, and uncertainty in those cohort shares is included in the influence functions. Units never treated (&lt;code>g == 0&lt;/code>) do not need $w_{t_1}$ for cohort aggregation shares. A share-dependent aggregate is unavailable when a required treated-cohort first-date mass is incomplete, with the affected unit IDs recorded; one-cohort bins and a one-bin group overall summary cancel shares exactly and do not require that mass. Note that under &lt;code>fix_weights = &amp;quot;base_period&amp;quot;&lt;/code>, each cohort cell uses its own reference weight $w_{b_g}$, so an aggregate across cohorts is a declared mixture of cohort specific weighted effects rather than the effect under one common weight distribution.&lt;/p>
&lt;h2 id="outcome-formula-xformla-versus-observation-formula-selection_xformla">Outcome formula (&lt;code>xformla&lt;/code>) versus observation formula (&lt;code>selection_xformla&lt;/code>)&lt;/h2>
&lt;p>&lt;code>cdid::att_gt()&lt;/code> separates the covariate formula for treatment and outcome change models from the covariate formula for the observation probability model:&lt;/p>
&lt;ul>
&lt;li>&lt;code>xformla&lt;/code> specifies the one sided covariate design for treatment adjustment (&lt;code>est_method = &amp;quot;dr&amp;quot;&lt;/code>, &lt;code>&amp;quot;reg&amp;quot;&lt;/code>, or &lt;code>&amp;quot;ipw&amp;quot;&lt;/code>, see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>) and, when active, change imputation (&lt;code>selection_est_method = &amp;quot;imputation&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>). When covariates are used, &lt;code>xformla&lt;/code> requires a nonempty design (such as &lt;code>~1&lt;/code>, &lt;code>~x1 + x2&lt;/code>, or &lt;code>~0 + x1&lt;/code>).&lt;/li>
&lt;li>&lt;code>selection_xformla&lt;/code> specifies the one sided covariate design for the observation probability model under &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code> (&lt;code>selection_model = &amp;quot;pair_logit&amp;quot;&lt;/code> or &lt;code>&amp;quot;independent_period_logit&amp;quot;&lt;/code>). When &lt;code>selection_xformla = NULL&lt;/code> (the default), it inherits &lt;code>xformla&lt;/code>.&lt;/li>
&lt;li>Under pure change imputation (&lt;code>selection_est_method = &amp;quot;imputation&amp;quot;&lt;/code>), no observation probability model is fitted, so &lt;code>selection_xformla&lt;/code>, &lt;code>selection_model&lt;/code>, and &lt;code>selection_pooling&lt;/code> are inactive and never evaluated.&lt;/li>
&lt;li>Under augmented adjustment for missing outcomes (&lt;code>selection_est_method = &amp;quot;dr&amp;quot;&lt;/code>), &lt;code>xformla&lt;/code> builds the actual-change imputation design and the active treatment designs: propensity for IPW, counterfactual regression for OR, or both for DR on all rows of $F$, while &lt;code>selection_xformla&lt;/code> builds the observation probability design on all rows of $F$. Variables included only in &lt;code>selection_xformla&lt;/code> do not enter the outcome or treatment models; however, conditional mean MTAR must hold given the combined covariate set, and if variables present only in &lt;code>selection_xformla&lt;/code> shift the outcome change mean, an &lt;code>xformla&lt;/code> only imputer is not sufficient on its own. See &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a> and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Option reference&lt;/a>.&lt;/li>
&lt;/ul>
&lt;h2 id="diagnosing-separation-collinearity-and-covariance-issues">Diagnosing separation, collinearity, and covariance issues&lt;/h2>
&lt;p>First inspect who is observed, at which dates, and in the particular pairs your analysis needs. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/investigate-missingness/">Investigate missingness and data structure&lt;/a> gives executable base R checks and shows how to inspect the fitted support, model, parallel-trends and inference records. These checks assess observable structure. They cannot establish parallel trends or the representativeness of missing changes.&lt;/p>
&lt;p>When preparing covariates and inspecting fit messages, keep three distinct mechanisms separate:&lt;/p>
&lt;h3 id="1-separation-and-boundary-probabilities-in-logit-models">1. Separation and boundary probabilities in logit models&lt;/h3>
&lt;p>Treatment propensity logits (&lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>) and active observation probability logits (&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code> with &lt;code>selection_est_method = &amp;quot;ipw&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code>) require interior probabilities and appropriate support. The default &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code> fits no observation logit.&lt;/p>
&lt;ul>
&lt;li>If a covariate or factor level perfectly separates treated units from comparison units in an active risk set, or separates observed units from missing units in an active observation cell, no finite interior maximum likelihood root exists and &lt;code>cdid&lt;/code> refuses the fit with a typed error.&lt;/li>
&lt;li>In particular, if every unit in an active observation cell is observed or every unit is unobserved and that cell has a free intercept, the logit has no finite interior root (pooling slopes does not remove cell intercepts) and &lt;code>cdid&lt;/code> refuses the separated fit. Observing all units in a sample cell does not establish a known design probability of 1 when a logit observation model is requested.&lt;/li>
&lt;/ul>
&lt;h3 id="2-collinearity-preprocessing-versus-unsupported-covariate-predictions">2. Collinearity preprocessing versus unsupported covariate predictions&lt;/h3>
&lt;p>Outcome regression and change imputation can drop a redundant predictor when the remaining columns still give the same predictions for every required row. For example, two identical columns provide the same information as one.&lt;/p>
&lt;p>Check that the fitting data support the predictions you need. A factor level found only among treated units may have no coefficient in a regression fitted on controls. Separate regressions need enough information in each comparison. A pooled regression can use variation across comparisons when their slopes are assumed to be shared. Treatment and observation logits require a full-rank design.&lt;/p>
&lt;h3 id="3-covariance-regularization-versus-att-identification">3. Covariance regularization versus ATT identification&lt;/h3>
&lt;p>In feasible two step GMM (&lt;code>gmm_weighting = &amp;quot;optimal&amp;quot;&lt;/code>, the default), comparison moments can have singular or nearly singular covariance. Exact structural equivalence reductions come first. The default &lt;code>gmm_covariance = &amp;quot;tikhonov&amp;quot;&lt;/code> handles the remaining covariance problem using the recorded conditioning and rank rules, including &lt;code>control$condition_trigger&lt;/code> (&lt;code>1e-10&lt;/code> by default). Exactly zero covariance follows the existing full-catalog least-squares convention with zero sandwich variance.&lt;/p>
&lt;p>Covariance regularization only stabilizes the weighting matrix used to combine already identified comparison moments; it &lt;strong>cannot&lt;/strong> create ATT identification when date links, cohort support, or identifying assumptions are missing. Furthermore, analytical and multiplier bootstrap standard errors use the estimated sandwich covariance built from the complete influence functions, never the inverse of the regularized weighting matrix (see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results and uncertainty&lt;/a>).&lt;/p>
&lt;h2 id="resource-and-workspace-controls-control">Resource and workspace controls (&lt;code>control&lt;/code>)&lt;/h2>
&lt;p>Chained mode accepts an optional named &lt;code>control&lt;/code> list for internal numeric workspace and preflight work limits (see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Option reference&lt;/a>):&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Configurable numeric workspace (&lt;code>numeric_workspace_bytes&lt;/code>):&lt;/strong> Defaults to &lt;code>1073741824&lt;/code> (1 GiB) of counted numeric array payload, with automatic memory aware chunking controlled by &lt;code>chunk_rows&lt;/code>.&lt;/li>
&lt;li>&lt;strong>Opt in estimated work cap (&lt;code>counted_work_limit&lt;/code>):&lt;/strong> Defaults to &lt;code>Inf&lt;/code> (no estimated work cap). You can opt in by setting &lt;code>counted_work_limit&lt;/code> to a finite positive whole number (such as &lt;code>1e12&lt;/code>), which refuses a stage before it runs if its conservative preflight work estimate exceeds your budget.&lt;/li>
&lt;li>&lt;strong>Parallel multiplier bootstrap workers (&lt;code>workers&lt;/code>):&lt;/strong> Defaults to &lt;code>1&lt;/code>. To run multiplier bootstrap draws in parallel with &lt;code>pl = TRUE, cores = k&lt;/code>, you must also declare &lt;code>control = list(workers = k)&lt;/code>, and all worker buffers count against &lt;code>numeric_workspace_bytes&lt;/code>.&lt;/li>
&lt;li>&lt;strong>Scope of resource controls:&lt;/strong> &lt;code>numeric_workspace_bytes&lt;/code> and &lt;code>counted_work_limit&lt;/code> track internal numeric array allocations and conservative preflight operation counts; they do not cap total R process resident memory (RSS), R heap usage, or wall clock CPU time, and &lt;code>cdid&lt;/code> does not automatically detect machine RAM.&lt;/li>
&lt;/ul>
&lt;h2 id="concise-base-r-data-checklist-and-examples">Concise base R data checklist and examples&lt;/h2>
&lt;blockquote>
&lt;p>[!IMPORTANT]
The checks below are templates for your &lt;code>panel_data&lt;/code> and &lt;code>units&lt;/code> tables. The &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">observation-model example&lt;/a> shows a complete simulation, fitted results and output; the column names below illustrate how to prepare your own data.&lt;/p>
&lt;/blockquote>
&lt;h3 id="1-verify-long-panel-structure-unit-table-and-missing-outcome-coding">1. Verify long panel structure, unit table, and missing outcome coding&lt;/h3>
&lt;pre>&lt;code class="language-r"># Data checks for your panel and unit table.
# Suppose `panel_data` has columns: id, time, g, y, x1, z_sel, w
# and `units` (the unit table `frame`) has one row per study unit.
# 1. Check unique unit IDs in `units` and unique (id, time) pairs in `panel_data`.
stopifnot(
identical(class(units$id), class(panel_data$id)),
!anyNA(units$id),
!anyDuplicated(units$id),
all(panel_data$id %in% units$id),
!anyNA(panel_data$id),
!anyNA(panel_data$time),
!anyDuplicated(panel_data[c(&amp;quot;id&amp;quot;, &amp;quot;time&amp;quot;)])
)
# 2. Check that calendar dates are finite numeric values and inspect the sorted calendar.
stopifnot(is.numeric(panel_data$time), all(is.finite(panel_data$time)))
calendar_dates &amp;lt;- sort(unique(panel_data$time))
# 3. Check that cohort `g` is finite, constant within each unit, agrees with `units`,
# and is nonnegative (0 means never treated). This checklist assumes known cohorts
# for every study unit; that is convenient here, not a universal baseline requirement.
unit_g_lookup &amp;lt;- setNames(units$g, units$id)
stopifnot(
is.numeric(units$g),
all(is.finite(units$g)),
all(units$g &amp;gt;= 0),
all(panel_data$g == unit_g_lookup[as.character(panel_data$id)])
)
# 4. Count observed (not NA) outcomes per unit across the full unit table `units`.
# Counts do not reveal whether someone previously replaced missing outcomes with 0.
obs_counts &amp;lt;- tabulate(
match(panel_data$id[!is.na(panel_data$y)], units$id),
nbins = nrow(units)
)
n_total_F &amp;lt;- nrow(units) # Full study population F
n_at_least_1 &amp;lt;- sum(obs_counts &amp;gt;= 1) # Set B: at least one observed outcome
n_repeated_A &amp;lt;- sum(obs_counts &amp;gt;= 2) # Set A: units with repeated observations
n_singletons &amp;lt;- sum(obs_counts == 1) # Set B \ A: one observed outcome
n_zero_obs &amp;lt;- sum(obs_counts == 0) # Set F \ B: no observed outcomes
&lt;/code>&lt;/pre>
&lt;h3 id="2-check-reference-date-rows-when-covariates-or-weights-change-over-time">2. Check reference date rows when covariates or weights change over time&lt;/h3>
&lt;p>For this template, &lt;code>x1&lt;/code> and &lt;code>w&lt;/code> vary by date and are supplied only in &lt;code>panel_data&lt;/code>; keep their dated rows even when &lt;code>y&lt;/code> is missing. Do not also place a conflicting static copy in &lt;code>frame&lt;/code>. The inspection below does not assert that every F unit needs a row at every cohort baseline.&lt;/p>
&lt;pre>&lt;code class="language-r"># Check and call for changing covariates and weights.
# This example uses zero anticipation: b_g is the last stored date before g.
# For nonzero anticipation the cutoff is d + anticipation &amp;lt; g on numeric dates.
anticipation &amp;lt;- 0
treated_cohorts &amp;lt;- sort(unique(units$g[units$g &amp;gt; 0]))
base_dates &amp;lt;- vapply(treated_cohorts, function(g_val) {
eligible &amp;lt;- calendar_dates[calendar_dates &amp;lt; g_val]
if (length(eligible) == 0L) NA_real_ else max(eligible)
}, numeric(1))
names(base_dates) &amp;lt;- as.character(treated_cohorts)
base_dates
# Inspect rows at the reference dates, retaining y = NA where appropriate.
# This is an inspection aid, not an all-F baseline-row requirement. The package
# checks exact required IDs/dates by route, pair support, and recipe, including
# auxiliary preperiod recipes; it reports missing required values explicitly.
reference_rows &amp;lt;- panel_data[panel_data$time %in% base_dates, ]
head(reference_rows[c(&amp;quot;id&amp;quot;, &amp;quot;time&amp;quot;, &amp;quot;g&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;x1&amp;quot;, &amp;quot;w&amp;quot;)])
# Keep varying x1 and w in panel_data, not as dateless unit-table attributes.
frame_ref &amp;lt;- units[c(&amp;quot;id&amp;quot;, &amp;quot;g&amp;quot;)]
# Fit chained DiD with reference date covariates and explicit base period weights.
fit_ref &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;,
tname = &amp;quot;time&amp;quot;,
idname = &amp;quot;id&amp;quot;,
gname = &amp;quot;g&amp;quot;,
xformla = ~x1,
data = panel_data,
weightsname = &amp;quot;w&amp;quot;,
fix_weights = &amp;quot;base_period&amp;quot;,
est_method = &amp;quot;dr&amp;quot;,
frame = frame_ref,
bstrap = FALSE,
cband = FALSE
)
&lt;/code>&lt;/pre>
&lt;h3 id="3-separate-outcome-and-observation-formulas-with-optional-resource-controls">3. Separate outcome and observation formulas with optional resource controls&lt;/h3>
&lt;p>This is an independent, unweighted template with static covariates. It assumes &lt;code>x1&lt;/code> and &lt;code>z_sel&lt;/code> are available consistently in the panel or unit table on the route&amp;rsquo;s required supports and the chosen observation logits have finite interior roots. Distinct predictor lists require conditional-MTAR and treatment-model restrictions sufficient for their scientific conditioning sets; adding &lt;code>z_sel&lt;/code> is not a substitute for stating those assumptions.&lt;/p>
&lt;pre>&lt;code class="language-r"># Call template with separate xformla and selection_xformla and an optional work cap.
fit_sel &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;,
tname = &amp;quot;time&amp;quot;,
idname = &amp;quot;id&amp;quot;,
gname = &amp;quot;g&amp;quot;,
xformla = ~x1,
selection = &amp;quot;conditional_mtar&amp;quot;,
selection_est_method = &amp;quot;ipw&amp;quot;,
selection_model = &amp;quot;pair_logit&amp;quot;,
selection_pooling = &amp;quot;within_cohort&amp;quot;,
selection_xformla = ~x1 + z_sel,
selection_universe = &amp;quot;F&amp;quot;,
data = panel_data,
frame = units,
est_method = &amp;quot;dr&amp;quot;,
bstrap = FALSE,
cband = FALSE,
control = list(
counted_work_limit = 1e12,
numeric_workspace_bytes = 1073741824
)
)
&lt;/code>&lt;/pre>
&lt;h2 id="where-to-go-next">Where to go next&lt;/h2>
&lt;ul>
&lt;li>To see how chained DiD links pair comparisons across rotating, overlapping, and gapped panels, read &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Estimate treatment effects from incomplete panels&lt;/a>.&lt;/li>
&lt;li>To choose between observation weighting, change imputation, and doubly robust adjustment for missing outcomes, see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>.&lt;/li>
&lt;li>To compare treatment adjustment models (&lt;code>est_method = &amp;quot;dr&amp;quot;&lt;/code>, &lt;code>&amp;quot;reg&amp;quot;&lt;/code>, &lt;code>&amp;quot;ipw&amp;quot;&lt;/code>), see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>.&lt;/li>
&lt;li>To compare &lt;code>PT-post&lt;/code> and &lt;code>PT-all&lt;/code> (&lt;code>pt_assumption&lt;/code> and &lt;code>pt_start&lt;/code>) and reference period reporting (&lt;code>base_period&lt;/code>), see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends assumptions&lt;/a>.&lt;/li>
&lt;li>For complete parameter definitions and output structures, see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Option reference&lt;/a> and &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results and uncertainty&lt;/a>.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 6 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;strong>Prepare your panel and unit table&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>Results reference</title><link>https://www.davidbenatia.com/tools/cdid/guide/reference/results/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/reference/results/</guid><description>&lt;p>Use &lt;code>summary()&lt;/code> to read a fit, &lt;code>tidy()&lt;/code> to extract a table and &lt;code>ggdid()&lt;/code> to plot it. This page describes the reported effects, their uncertainty and the diagnostics you can use to investigate a result.&lt;/p>
&lt;h2 id="result-classes-and-functions">Result classes and functions&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Function&lt;/th>
&lt;th>Result in chained mode&lt;/th>
&lt;th>Methods&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>att_gt(gname = ...)&lt;/code>&lt;/td>
&lt;td>&lt;code>cdid_MP&lt;/code>, which inherits &lt;code>did&lt;/code>&amp;rsquo;s &lt;code>MP&lt;/code>&lt;/td>
&lt;td>&lt;code>print()&lt;/code>, &lt;code>summary()&lt;/code>, &lt;code>tidy()&lt;/code>, &lt;code>glance()&lt;/code>, &lt;code>ggdid()&lt;/code>, &lt;code>chain_report()&lt;/code>, and &lt;code>aggte()&lt;/code> for aggregation&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>att_gt(dname = ...)&lt;/code>&lt;/td>
&lt;td>&lt;code>cdid_static_att_gt&lt;/code>&lt;/td>
&lt;td>&lt;code>print()&lt;/code>, &lt;code>summary()&lt;/code>, &lt;code>tidy()&lt;/code>, &lt;code>glance()&lt;/code>, &lt;code>ggdid()&lt;/code> and &lt;code>plot()&lt;/code>; the aggregate is stored in the result&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>aggte()&lt;/code>&lt;/td>
&lt;td>&lt;code>cdid_AGGTEobj&lt;/code>, which inherits &lt;code>did&lt;/code>&amp;rsquo;s &lt;code>AGGTEobj&lt;/code>&lt;/td>
&lt;td>&lt;code>print()&lt;/code>, &lt;code>summary()&lt;/code>, &lt;code>tidy()&lt;/code>, &lt;code>glance()&lt;/code>, &lt;code>ggdid()&lt;/code> (except for the simple type)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>chain_report()&lt;/code>&lt;/td>
&lt;td>&lt;code>cdid_chain_report&lt;/code>&lt;/td>
&lt;td>&lt;code>print()&lt;/code>, &lt;code>as.data.frame()&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>conditional_did_pretest()&lt;/code>&lt;/td>
&lt;td>&lt;code>cdid_MP.TEST&lt;/code>, which inherits &lt;code>did&lt;/code>&amp;rsquo;s &lt;code>MP.TEST&lt;/code>&lt;/td>
&lt;td>&lt;code>print()&lt;/code>, &lt;code>summary()&lt;/code>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>In ordinary mode each function returns &lt;code>did&lt;/code>&amp;rsquo;s own object, unchanged. For the cohort chained classes, &lt;code>print()&lt;/code> and &lt;code>summary()&lt;/code> give the same display. The &lt;code>att_gt()&lt;/code> and &lt;code>aggte()&lt;/code> displays show &lt;code>did&lt;/code>&amp;rsquo;s summary table under a heading that names the chained estimator, without &lt;code>did&lt;/code>&amp;rsquo;s citation line, followed by a short chained record. For &lt;code>att_gt()&lt;/code> the record gives the available and requested cells with the reasons for unavailable ones, the units of the unit table, the correction for missing outcomes, the parallel trends assumption and &lt;code>base_period&lt;/code>, the GMM weighting and any covariance regularization, the inference actually performed and the pretrend test or the reason it is unavailable. For &lt;code>aggte()&lt;/code> it gives the available and intended aggregates, every restricted or unavailable target with its reason, the bins used and excluded by the overall summary, the parallel trends assumption and the inference, and, when they apply, nondefault event-time selectors, unknown cohort shares or shares taken as masses at the first stored date. The heading shows the package versions and both paper references once. Interval family codes, the numerical policy and resource profile remain in the result without being printed, as listed below. The conditional-test display reports its CvM test and status.&lt;/p>
&lt;h2 id="static-entry-and-exit-results">Static entry and exit results&lt;/h2>
&lt;p>With &lt;code>dname&lt;/code>, &lt;code>att_gt()&lt;/code> returns switching-date effects rather than cohort effects. &lt;code>summary(fit)&lt;/code> displays them, &lt;code>tidy(fit)&lt;/code> exports the transition table, &lt;code>glance(fit)&lt;/code> gives one summary row, and &lt;code>ggdid(fit)&lt;/code> plots the available entry and exit estimates.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Field&lt;/th>
&lt;th>Contents&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>target_id&lt;/code>, &lt;code>t&lt;/code>, &lt;code>t_prev&lt;/code>, &lt;code>d&lt;/code>, &lt;code>direction&lt;/code>&lt;/td>
&lt;td>Transition identifier, switching date, preceding stored date, prior treatment state and entry/exit direction&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>att&lt;/code>, &lt;code>theta_hat&lt;/code>&lt;/td>
&lt;td>Treatment effect on the treated-versus-untreated scale, and the raw switcher-minus-stayer contrast; the exit contrast is sign-reversed in &lt;code>att&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>available&lt;/code>, &lt;code>support_status&lt;/code>, &lt;code>support_reason&lt;/code>&lt;/td>
&lt;td>Whether each declared transition can be estimated and why a target is unavailable&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>se&lt;/code>, &lt;code>analytical_se&lt;/code>, &lt;code>bootstrap_se&lt;/code>&lt;/td>
&lt;td>Reported, analytical and multiplier standard errors, according to the inference requested&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>V_analytical&lt;/code>&lt;/td>
&lt;td>Estimated covariance of the static cell estimates; &lt;code>analytical_se&lt;/code> is &lt;code>sqrt(diag(V_analytical))&lt;/code>. This differs from the cohort matrix scaling described below.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>inffunc&lt;/code>, &lt;code>unit_id&lt;/code>, &lt;code>n&lt;/code>&lt;/td>
&lt;td>One influence-function row per original study unit, aligned with &lt;code>unit_id&lt;/code>, and the full study-unit count&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>aggregate&lt;/code>&lt;/td>
&lt;td>Switcher-weighted estimate, standard error, intervals, availability and full-unit influence function for the declared transition family&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>request&lt;/code>, &lt;code>diagnostics&lt;/code>, &lt;code>graphs&lt;/code>, &lt;code>inference&lt;/code>, &lt;code>references&lt;/code>&lt;/td>
&lt;td>Active settings, unit/role counts, whether the fit used direct adjacent comparisons or chained GMM (&lt;code>gmm_executed&lt;/code>), pair-graph support, inference record and route-specific references&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Use &lt;code>fit$aggregate&lt;/code> for the static average. &lt;code>aggte()&lt;/code> remains a cohort aggregation function. An unavailable declared cell also makes the declared static average unavailable; the package does not silently change its target family. See the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/static-entry-exit/#read-the-result">entry and exit guide&lt;/a> for an example and the sign convention.&lt;/p>
&lt;p>&lt;code>chain_report()&lt;/code> describes the comparisons and identifying paths in cohort &lt;code>gname&lt;/code> fits. Use &lt;code>control = list(keep_nuisance = TRUE)&lt;/code> to inspect fitted model equations and coefficient tables with &lt;code>nuisance_models(fit)&lt;/code> on supported cohort and static fits. The static models label their switcher and stayer populations. The cohort-by-date model identifies the reference levels and its covariate basis. The report indicates when a model was unnecessary, a fit was requested without capture, or coefficient standard errors are unavailable.&lt;/p>
&lt;p>The remaining sections describe cohort &lt;code>gname&lt;/code> objects and their aggregation and pretrend tests.&lt;/p>
&lt;h2 id="group-time-results">Group time results&lt;/h2>
&lt;h3 id="fields-inherited-from-did">Fields inherited from did&lt;/h3>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Field&lt;/th>
&lt;th>Contents in a chained result&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>group&lt;/code>, &lt;code>t&lt;/code>&lt;/td>
&lt;td>cohort and period of each reported cell&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>att&lt;/code>&lt;/td>
&lt;td>estimates; &lt;code>NA&lt;/code> for unavailable cells, never zero filled; exactly zero for the reference cell under &lt;code>base_period = &amp;quot;universal&amp;quot;&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>se&lt;/code>&lt;/td>
&lt;td>standard errors, analytical or from multiplier draws according to the inference actually performed; &lt;code>NA&lt;/code> for unavailable cells&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>c&lt;/code>&lt;/td>
&lt;td>critical value: the pointwise normal value &lt;code>qnorm(1 - alp / 2)&lt;/code> or a simultaneous multiplier quantile&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>V_analytical&lt;/code>&lt;/td>
&lt;td>estimated asymptotic covariance of &lt;code>sqrt(n) * (estimate - target)&lt;/code>, equal to &lt;code>n&lt;/code> times the estimated covariance of the cell estimates; analytical standard errors are &lt;code>sqrt(diag(V_analytical) / n)&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>inffunc&lt;/code>&lt;/td>
&lt;td>influence function matrix with one row per unit of the unit table (row names are the unit identifiers) and one column per cell; columns of unavailable cells are &lt;code>NA&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>n&lt;/code>&lt;/td>
&lt;td>number of units in the unit table&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>W&lt;/code>, &lt;code>Wpval&lt;/code>&lt;/td>
&lt;td>unconditional pretrend Wald statistic and p value; &lt;code>NULL&lt;/code> when the test is not computed&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>alp&lt;/code>, &lt;code>DIDparams&lt;/code>&lt;/td>
&lt;td>significance level and settings&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="the-chained-record">The chained record&lt;/h3>
&lt;p>&lt;code>fit$chained&lt;/code> holds everything specific to chained estimation.&lt;/p>
&lt;p>For a worked inspection of unit table coverage, missingness, selected-pair counts and these fitted records, see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/investigate-missingness/">Investigate missingness and data structure&lt;/a>.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Element&lt;/th>
&lt;th>Contents&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>estimator&lt;/code>, &lt;code>references&lt;/code>, &lt;code>versions&lt;/code>&lt;/td>
&lt;td>estimator label, the two references, and the versions of &lt;code>cdid&lt;/code> and &lt;code>did&lt;/code> with the tested &lt;code>did&lt;/code> version&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>target_id&lt;/code>, &lt;code>target_meta&lt;/code>, &lt;code>role&lt;/code>, &lt;code>available&lt;/code>&lt;/td>
&lt;td>identifiers and descriptions of the reported cells; &lt;code>role&lt;/code> is &lt;code>&amp;quot;pre&amp;quot;&lt;/code>, &lt;code>&amp;quot;post&amp;quot;&lt;/code> or &lt;code>&amp;quot;reference&amp;quot;&lt;/code>; &lt;code>available&lt;/code> is &lt;code>TRUE&lt;/code> or &lt;code>FALSE&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>support_status&lt;/code>, &lt;code>support_reason&lt;/code>, &lt;code>support&lt;/code>, &lt;code>support_ledger&lt;/code>&lt;/td>
&lt;td>why each cell is or is not available, with the supporting records&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>deterministic_reference&lt;/code>&lt;/td>
&lt;td>cells that are exact zeros by construction, which have no test statistic&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>z_stat&lt;/code>, &lt;code>p_value&lt;/code>, &lt;code>analytical_se&lt;/code>, &lt;code>ci_lower&lt;/code>, &lt;code>ci_upper&lt;/code>, &lt;code>cband_lower&lt;/code>, &lt;code>cband_upper&lt;/code>&lt;/td>
&lt;td>statistics, analytical standard errors, pointwise intervals and band limits for each cell, named by &lt;code>target_id&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>band_family&lt;/code>, &lt;code>band_families&lt;/code>&lt;/td>
&lt;td>the interval family of the reported cells; values beginning with &lt;code>&amp;quot;simultaneous&amp;quot;&lt;/code> denote a simultaneous band, values beginning with &lt;code>&amp;quot;pointwise&amp;quot;&lt;/code> pointwise intervals&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>inference&lt;/code>&lt;/td>
&lt;td>the inference actually performed: &lt;code>kind&lt;/code> (&lt;code>&amp;quot;analytic&amp;quot;&lt;/code>, &lt;code>&amp;quot;multiplier_bootstrap_iqr_se&amp;quot;&lt;/code> or &lt;code>&amp;quot;not_computed&amp;quot;&lt;/code>), the effective &lt;code>bstrap&lt;/code> and &lt;code>cband&lt;/code>, the number of draws, clustering and number of clusters, &lt;code>n_total&lt;/code>, the random number record and the requested flags&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>pretest&lt;/code>&lt;/td>
&lt;td>status and details of the unconditional pretrend test&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>frame&lt;/code>&lt;/td>
&lt;td>the unit table as used: &lt;code>id&lt;/code>, &lt;code>cohort&lt;/code>, &lt;code>weight&lt;/code>, &lt;code>cluster&lt;/code> and &lt;code>eligible&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>base_period&lt;/code>, &lt;code>pt&lt;/code>&lt;/td>
&lt;td>the reporting choice and the parallel trends record&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>covariance_handling&lt;/code>&lt;/td>
&lt;td>the GMM weighting request and the covariance regularization record&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>selection&lt;/code>&lt;/td>
&lt;td>the handling of missing outcomes and model descriptions. Fit counts are nested in &lt;code>selection$models&lt;/code> and depend on the active route. Observation weighting also records its fitting universe and active cells.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>nuisance_diagnostics&lt;/code>, &lt;code>outcome_design&lt;/code>&lt;/td>
&lt;td>the fitted treatment, outcome, observation and imputation models, and the design columns&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>chain_info&lt;/code>&lt;/td>
&lt;td>the comparisons, the paths that identify effects and the comparison weights used by &lt;code>chain_report()&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>numerical_certificate&lt;/code>&lt;/td>
&lt;td>a numerical certificate when one is produced; the current numerical policy uses conventional computation without per fit error certification&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>request&lt;/code>, &lt;code>public&lt;/code>&lt;/td>
&lt;td>the honored computation flags with the admitted multiplier workers, and the resource profile with the numerical policy&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>basis&lt;/code>&lt;/td>
&lt;td>optional separate contrasts, kept apart from the cells&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="settings-in-didparams">Settings in DIDparams&lt;/h3>
&lt;p>&lt;code>fit$DIDparams&lt;/code> keeps &lt;code>did&lt;/code>&amp;rsquo;s settings as requested, including &lt;code>est_method&lt;/code>, &lt;code>control_group&lt;/code>, &lt;code>anticipation&lt;/code>, &lt;code>base_period&lt;/code>, &lt;code>xformla&lt;/code>, &lt;code>bstrap&lt;/code>, &lt;code>cband&lt;/code>, &lt;code>biters&lt;/code>, &lt;code>clustervars&lt;/code> and &lt;code>compute_inffunc&lt;/code>. &lt;code>fit$DIDparams$cdid&lt;/code> adds the mode, the estimator label, the versions, the requested and effective inference flags and the number of draws actually made. It also records &lt;code>data_retained = FALSE&lt;/code>: a chained result does not store the panel data, so it must be aggregated with &lt;code>cdid::aggte()&lt;/code>.&lt;/p>
&lt;h2 id="tables-from-tidy-and-glance">Tables from tidy and glance&lt;/h2>
&lt;p>&lt;code>tidy()&lt;/code> of a group time result returns one row per reported cell, with &lt;code>did&lt;/code>&amp;rsquo;s columns (including &lt;code>estimate&lt;/code>, &lt;code>std.error&lt;/code>, &lt;code>conf.low&lt;/code> and &lt;code>conf.high&lt;/code>) and the following chained columns or updates:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Column&lt;/th>
&lt;th>Meaning&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>statistic&lt;/code>, &lt;code>p.value&lt;/code>&lt;/td>
&lt;td>test of a zero effect for the cell; &lt;code>NA&lt;/code> for exact zero reference cells&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>target.id&lt;/code>, &lt;code>role&lt;/code>&lt;/td>
&lt;td>cell identifier and role (&lt;code>&amp;quot;pre&amp;quot;&lt;/code>, &lt;code>&amp;quot;post&amp;quot;&lt;/code> or &lt;code>&amp;quot;reference&amp;quot;&lt;/code>)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>available&lt;/code>, &lt;code>support.status&lt;/code>, &lt;code>support.reason&lt;/code>&lt;/td>
&lt;td>availability and its reason&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>certified&lt;/code>&lt;/td>
&lt;td>whether a numerical certificate covers the cell; &lt;code>NA&lt;/code> when no certificate was produced, the usual case&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>estimator&lt;/code>&lt;/td>
&lt;td>estimator label, present for OR and DR fits and for change imputation and the augmented correction&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>band.family&lt;/code>&lt;/td>
&lt;td>interval family&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The &lt;code>statistic&lt;/code> and &lt;code>p.value&lt;/code> columns update the inherited values. P-values remain pointwise even when &lt;code>conf.low&lt;/code> and &lt;code>conf.high&lt;/code> use a simultaneous critical value; the inherited &lt;code>point.conf.low&lt;/code> and &lt;code>point.conf.high&lt;/code> are always pointwise normal intervals.&lt;/p>
&lt;p>&lt;code>glance()&lt;/code> of a group time result returns one row with &lt;code>did&lt;/code>&amp;rsquo;s columns plus &lt;code>estimator&lt;/code>, &lt;code>n.requested&lt;/code>, &lt;code>n.available&lt;/code>, &lt;code>band.family&lt;/code>, &lt;code>inference&lt;/code> and &lt;code>clustered&lt;/code>.&lt;/p>
&lt;p>&lt;code>tidy()&lt;/code> of an aggregated result updates the inherited &lt;code>statistic&lt;/code> and &lt;code>p.value&lt;/code> and adds &lt;code>label&lt;/code>, &lt;code>available&lt;/code>, &lt;code>restricted&lt;/code>, &lt;code>n.intended&lt;/code>, &lt;code>n.used&lt;/code>, &lt;code>excluded.ids&lt;/code>, &lt;code>reason&lt;/code>, &lt;code>certified&lt;/code>, &lt;code>band.family&lt;/code> and, as above, &lt;code>estimator&lt;/code>. Its rows depend on the type: the group type starts with the overall summary (&lt;code>label&lt;/code> equal to &lt;code>&amp;quot;overall&amp;quot;&lt;/code>) followed by one row per cohort; the simple type has one row; the dynamic and calendar types have one row per event time or period and no overall row. &lt;code>glance()&lt;/code> of an aggregated result adds &lt;code>estimator&lt;/code>, &lt;code>status&lt;/code>, &lt;code>na.rm&lt;/code>, &lt;code>n.bins&lt;/code>, &lt;code>n.bins.available&lt;/code>, &lt;code>overall.status&lt;/code>, &lt;code>band.family&lt;/code> and &lt;code>inference&lt;/code>.&lt;/p>
&lt;h2 id="unavailable-effects">Unavailable effects&lt;/h2>
&lt;p>A cell is unavailable when the comparisons available to the estimator cannot support it, for example because no chain of observed changes connects the needed dates for the cohort or its controls, or because the parallel trends choice does not cover a needed step. Its estimate, standard error, influence function column and covariance entries are &lt;code>NA&lt;/code>, never zero, and &lt;code>support_status&lt;/code> and &lt;code>support_reason&lt;/code> give the reason. The summary lists unavailable cells. An unavailable cell reflects the information in the available comparisons; whether the effect is identified in the population is a separate question.&lt;/p>
&lt;p>Failures of a model fit, a covariance calculation or a numerical solve are different: the fit stops with an error that names the problem, and nothing is dropped or relaxed to obtain a result.&lt;/p>
&lt;p>Unavailable cells also affect other outputs. A simultaneous band covers only the available cells. The pretrend test is unavailable when any of its cells is. An aggregate that needs an unavailable cell is &lt;code>NA&lt;/code> with the missing cells named, unless &lt;code>na.rm = TRUE&lt;/code> requests the restricted target over the available cells, which is then marked in &lt;code>restricted&lt;/code> and &lt;code>excluded.ids&lt;/code>.&lt;/p>
&lt;h3 id="reference-covariate-exclusions">Reference covariate exclusions&lt;/h3>
&lt;p>If a fit encounters a required reference covariate that is missing, inspect
&lt;code>fit$chained$reference_eligibility&lt;/code>. The &lt;code>targets&lt;/code> table reports the
reference date and eligible treated count for each cohort. Its counts of
missing values by group describe the supplied units at that date and can
include units outside the comparison groups. &lt;code>restricted_treated_cohorts&lt;/code>
lists the cohorts whose effects describe fewer treated units.
&lt;code>auxiliary_unavailable&lt;/code> explains any pretrend comparison that could not
use its required covariates.&lt;/p>
&lt;h2 id="aggregated-results">Aggregated results&lt;/h2>
&lt;h3 id="four-aggregation-types">Four aggregation types&lt;/h3>
&lt;p>&lt;code>aggte()&lt;/code> follows &lt;code>did&lt;/code>&amp;rsquo;s definitions. Cohort shares are estimated from the unit table, and the standard errors include their uncertainty.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Type&lt;/th>
&lt;th>Separate estimates (&lt;code>egt&lt;/code>, &lt;code>att.egt&lt;/code>)&lt;/th>
&lt;th>Overall summary (&lt;code>overall.att&lt;/code>)&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>&amp;quot;simple&amp;quot;&lt;/code>&lt;/td>
&lt;td>none&lt;/td>
&lt;td>average of the intended effects after treatment, each weighted by its cohort&amp;rsquo;s share; missing cells require explicit &lt;code>na.rm = TRUE&lt;/code> for a restricted target&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;group&amp;quot;&lt;/code>&lt;/td>
&lt;td>one per cohort: the average of the cohort&amp;rsquo;s effects after treatment&lt;/td>
&lt;td>average of the cohort estimates, weighted by cohort shares&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;dynamic&amp;quot;&lt;/code>&lt;/td>
&lt;td>one per event time &lt;code>e = t - g&lt;/code>, including event times before treatment&lt;/td>
&lt;td>average of the estimates for event times from 0 onward&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;calendar&amp;quot;&lt;/code>&lt;/td>
&lt;td>one per calendar period: the share weighted average over the cohorts treated by then&lt;/td>
&lt;td>average of the calendar period estimates&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>With several cohorts the overall summaries answer different questions. The simple type gives more weight to cohorts observed for more periods after treatment, the group type weights each cohort by its share whatever the number of its periods, and the dynamic and calendar types weight event times or periods equally. With one treated cohort, as in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/#aggregate-the-effects">Get started&lt;/a>, they coincide in the population. For fits with changing covariates or weights, the cohort shares are masses at the first stored date, as described in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#changing-covariates-and-weights">Changing covariates and weights&lt;/a>.&lt;/p>
&lt;p>Share uncertainty enters only when the target depends on shares. For one-cohort bins and a one-bin group overall summary the ratio cancels shares exactly, so missing first-date masses do not by themselves make those targets unavailable.&lt;/p>
&lt;h3 id="fields-of-an-aggregated-result">Fields of an aggregated result&lt;/h3>
&lt;p>The fields inherited from &lt;code>did&lt;/code> are &lt;code>overall.att&lt;/code>, &lt;code>overall.se&lt;/code>, &lt;code>type&lt;/code>, &lt;code>egt&lt;/code>, &lt;code>att.egt&lt;/code>, &lt;code>se.egt&lt;/code>, &lt;code>crit.val.egt&lt;/code>, &lt;code>inf.function&lt;/code>, &lt;code>call&lt;/code> and &lt;code>DIDparams&lt;/code>, and for the dynamic type &lt;code>min_e&lt;/code>, &lt;code>max_e&lt;/code> and &lt;code>balance_e&lt;/code>. For the simple type the separate estimates are &lt;code>NULL&lt;/code> and &lt;code>overall.att&lt;/code> holds the estimate. &lt;code>inf.function&lt;/code> holds complete influence functions with one row per unit of the unit table, named as in &lt;code>did&lt;/code>: &lt;code>simple.att&lt;/code>; &lt;code>selective.inf.func.g&lt;/code> and &lt;code>selective.inf.func&lt;/code>; &lt;code>dynamic.inf.func.e&lt;/code> and &lt;code>dynamic.inf.func&lt;/code>; &lt;code>calendar.inf.func.t&lt;/code> and &lt;code>calendar.inf.func&lt;/code>.&lt;/p>
&lt;p>&lt;code>agg$chained&lt;/code> adds:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Element&lt;/th>
&lt;th>Contents&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>type&lt;/code>, &lt;code>status&lt;/code>, &lt;code>na_rm&lt;/code>, &lt;code>reason&lt;/code>, &lt;code>target_definition&lt;/code>&lt;/td>
&lt;td>what was aggregated and whether it is available&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cell&lt;/code>&lt;/td>
&lt;td>one row per aggregate bin, including the scalar simple target: &lt;code>label&lt;/code>, &lt;code>key&lt;/code>, &lt;code>available&lt;/code>, &lt;code>restricted&lt;/code>, &lt;code>share_dependent&lt;/code>, &lt;code>n_intended&lt;/code>, &lt;code>n_used&lt;/code>, &lt;code>intended_ids&lt;/code>, &lt;code>used_ids&lt;/code>, &lt;code>excluded_ids&lt;/code>, &lt;code>reason&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cell_target_ids&lt;/code>, &lt;code>cell_used_target_ids&lt;/code>&lt;/td>
&lt;td>the cells each estimate intended to use and actually used&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>overall&lt;/code>&lt;/td>
&lt;td>the overall summary: &lt;code>status&lt;/code>, &lt;code>reason&lt;/code>, &lt;code>intended_bins&lt;/code>, &lt;code>used_bins&lt;/code>, &lt;code>excluded_bins&lt;/code>, &lt;code>weights&lt;/code>, &lt;code>inference_kind&lt;/code>, &lt;code>n_draws&lt;/code>, &lt;code>ci_lower&lt;/code>, &lt;code>ci_upper&lt;/code> and related records&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>shares_known&lt;/code>, &lt;code>cohort_shares&lt;/code>, &lt;code>weights_theta&lt;/code>&lt;/td>
&lt;td>the cohort shares and the weights of the cells&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>z_stat&lt;/code>, &lt;code>p_value&lt;/code>, &lt;code>ci_lower&lt;/code>, &lt;code>ci_upper&lt;/code>, &lt;code>cband_lower&lt;/code>, &lt;code>cband_upper&lt;/code>&lt;/td>
&lt;td>statistics and limits of the separate estimates&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>se_fixed_shares_only&lt;/code>, &lt;code>if_fixed_full&lt;/code>, &lt;code>if_share_full&lt;/code>, &lt;code>decomposition&lt;/code>&lt;/td>
&lt;td>standard errors treating the shares as fixed, kept as a diagnostic, and the parts of the influence function&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>band_family&lt;/code>, &lt;code>inference&lt;/code>, &lt;code>requested&lt;/code>&lt;/td>
&lt;td>the inference performed and the effective request, with whether each setting was inherited or explicit&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>selectors&lt;/code>&lt;/td>
&lt;td>how &lt;code>min_e&lt;/code>, &lt;code>max_e&lt;/code> and &lt;code>balance_e&lt;/code> were applied&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>share_law&lt;/code>, &lt;code>cohort_mass_complete&lt;/code>&lt;/td>
&lt;td>present for fits whose shares are first date masses&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="uncertainty">Uncertainty&lt;/h2>
&lt;h3 id="which-interval-each-output-reports">Which interval each output reports&lt;/h3>
&lt;p>The defaults are &lt;code>bstrap = TRUE&lt;/code>, &lt;code>cband = TRUE&lt;/code>, &lt;code>biters = 1000&lt;/code> and &lt;code>alp = 0.05&lt;/code>. The behavior depends on the output, following &lt;code>did&lt;/code> 2.5.1:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;code>bstrap&lt;/code>&lt;/th>
&lt;th>&lt;code>cband&lt;/code>&lt;/th>
&lt;th>Cells of &lt;code>att_gt()&lt;/code>&lt;/th>
&lt;th>&lt;code>aggte()&lt;/code> simple&lt;/th>
&lt;th>Separate estimates of &lt;code>aggte()&lt;/code> group, dynamic and calendar&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>FALSE&lt;/code>&lt;/td>
&lt;td>&lt;code>FALSE&lt;/code>&lt;/td>
&lt;td>analytical standard errors, pointwise normal intervals&lt;/td>
&lt;td>the same&lt;/td>
&lt;td>the same&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>TRUE&lt;/code>&lt;/td>
&lt;td>&lt;code>FALSE&lt;/code>&lt;/td>
&lt;td>multiplier standard errors, pointwise normal intervals&lt;/td>
&lt;td>the same&lt;/td>
&lt;td>the same&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>TRUE&lt;/code>&lt;/td>
&lt;td>&lt;code>TRUE&lt;/code>&lt;/td>
&lt;td>multiplier standard errors, simultaneous band over the available cells&lt;/td>
&lt;td>multiplier standard error, pointwise normal interval&lt;/td>
&lt;td>multiplier standard errors, simultaneous band over the available estimates&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>FALSE&lt;/code>&lt;/td>
&lt;td>&lt;code>TRUE&lt;/code>&lt;/td>
&lt;td>analytical standard errors, pointwise normal intervals, no draws&lt;/td>
&lt;td>analytical standard error, pointwise normal interval, no draws&lt;/td>
&lt;td>analytical standard errors with a simultaneous critical value from multiplier draws, and &lt;code>did&lt;/code>&amp;rsquo;s warning&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>These flag conventions describe supported nondegenerate families. Empty or exactly zero families may require no draws; read the effective flags and draw count in the result rather than assuming &lt;code>biters&lt;/code> draws ran. Separate interval families, including any retained basis contrasts, do not form one simultaneous band over their union.&lt;/p>
&lt;p>The overall summaries of the group, dynamic and calendar types always have pointwise normal intervals; their standard errors are multiplier or analytical according to the effective &lt;code>bstrap&lt;/code>. &lt;code>aggte()&lt;/code> inherits the settings of the fit unless you override them.&lt;/p>
&lt;h3 id="multiplier-draws">Multiplier draws&lt;/h3>
&lt;p>The multiplier bootstrap reuses the estimated influence functions; it does not refit the estimator. Each draw multiplies the influence function rows of each unit, or the row sums of each cluster, by a random sign of plus or minus one (Rademacher multipliers). A multiplier standard error is the interquartile range of the draws divided by the interquartile range of the standard normal distribution, on the scale of the estimate. A simultaneous critical value is the &lt;code>1 - alp&lt;/code> empirical quantile of the largest absolute standardized draw across the covered estimates, and the band is the estimate plus or minus that value times the standard error. In the &lt;code>bstrap = FALSE, cband = TRUE&lt;/code> case of the aggregate bins, the draws are standardized by their own interquartile range scale and the resulting critical value is applied to the analytical standard errors. Pointwise intervals use the normal critical value.&lt;/p>
&lt;p>The signs come from your session&amp;rsquo;s random number stream, so &lt;code>set.seed()&lt;/code> before &lt;code>att_gt()&lt;/code> or &lt;code>aggte()&lt;/code> reproduces the draws; there is no fixed seed. Parallel workers only multiply the signs drawn in your session, so the results equal those of &lt;code>cores = 1&lt;/code>.&lt;/p>
&lt;h3 id="analytical-standard-errors-and-clustering">Analytical standard errors and clustering&lt;/h3>
&lt;p>Analytical standard errors come from the complete influence functions, with one row for every unit of the unit table, including units without an observed change. They account for the estimation of the treatment, outcome, observation and imputation models, the response rates and the cohort shares used by the chosen method.&lt;/p>
&lt;p>With &lt;code>clustervars&lt;/code>, influence function rows are summed within clusters, including clusters without any unit that contributes a change, and the multiplier signs are drawn by cluster. Clustering changes the standard errors and bands; the point estimates stay the same, because the GMM weights are based on units. A cluster scheme that &lt;code>aggte()&lt;/code> cannot honor is refused.&lt;/p>
&lt;h3 id="what-the-uncertainty-assumes">What the uncertainty assumes&lt;/h3>
&lt;p>The reported uncertainty rests on large sample approximations: enough independent units or clusters, overlap, the model conditions of the chosen methods and regularity conditions. A completed fit does not establish these conditions, and no finite sample, few cluster or nominal coverage guarantee is made. Computation is conventional, with conditioning and residual checks, and no per fit error certificate is produced.&lt;/p>
&lt;h2 id="point-estimates-only">Point estimates only&lt;/h2>
&lt;p>With &lt;code>compute_inffunc = FALSE&lt;/code>, &lt;code>att_gt()&lt;/code> returns the same point estimates as with &lt;code>TRUE&lt;/code>, without allocating unit-level influence functions or analytical covariance matrices. For cohort results, &lt;code>inffunc&lt;/code>, &lt;code>V_analytical&lt;/code>, &lt;code>W&lt;/code> and &lt;code>Wpval&lt;/code> are &lt;code>NULL&lt;/code>, &lt;code>se&lt;/code> is &lt;code>NA&lt;/code>, and &lt;code>c&lt;/code> is the pointwise normal value. The recorded &lt;code>bstrap&lt;/code> and &lt;code>cband&lt;/code> are &lt;code>FALSE&lt;/code>; &lt;code>fit$chained$inference$kind&lt;/code> and the pretrend test status are &lt;code>&amp;quot;not_computed&amp;quot;&lt;/code>. &lt;code>aggte()&lt;/code> refuses such a result.&lt;/p>
&lt;p>Static &lt;code>dname&lt;/code> results record &lt;code>fit$inference$compute_inffunc = FALSE&lt;/code> and &lt;code>fit$inference$se_reported = &amp;quot;none_compute_inffunc_false&amp;quot;&lt;/code>. Their influence functions, covariance and standard errors are unavailable, as described in the static result fields above.&lt;/p>
&lt;h2 id="pretrend-tests">Pretrend tests&lt;/h2>
&lt;h3 id="unconditional-wald-test">Unconditional Wald test&lt;/h3>
&lt;p>&lt;code>att_gt()&lt;/code> tests jointly all cells before treatment (role &lt;code>&amp;quot;pre&amp;quot;&lt;/code>) of the chosen &lt;code>base_period&lt;/code>, excluding exact zero reference cells, with &lt;code>did&lt;/code>&amp;rsquo;s Wald statistic. &lt;code>W&lt;/code> and &lt;code>Wpval&lt;/code> are set only when every one of these cells is available and the full covariance passes the existing Cholesky/solve and conditioning policy. Otherwise they are &lt;code>NULL&lt;/code> and &lt;code>fit$chained$pretest&lt;/code> records the status (&lt;code>&amp;quot;unavailable&amp;quot;&lt;/code>, &lt;code>&amp;quot;not_applicable&amp;quot;&lt;/code> or &lt;code>&amp;quot;not_computed&amp;quot;&lt;/code>) with its reason. A test on the available subset is never substituted. When the test is computed, &lt;code>fit$chained$pretest&lt;/code> has &lt;code>status = &amp;quot;computed&amp;quot;&lt;/code>, the tested &lt;code>cells&lt;/code>, the degrees of freedom &lt;code>df&lt;/code>, &lt;code>W&lt;/code> and &lt;code>Wpval&lt;/code>.&lt;/p>
&lt;p>A test that does not reject does not establish parallel trends. Under PT-all, cells before the chosen start can reject without contradicting the assumption, as explained in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/#pretrend-tests-under-each-choice">Parallel trends&lt;/a>.&lt;/p>
&lt;h3 id="conditional-test">Conditional test&lt;/h3>
&lt;p>&lt;code>conditional_did_pretest()&lt;/code> tests a conditional null: for every cell before treatment of the chosen &lt;code>base_period&lt;/code> (reference zeros excluded), the mean of the cell&amp;rsquo;s comparison given the &lt;code>xformla&lt;/code> design row of the unit at the earlier endpoint of its auxiliary date pair is zero. This can be weaker than conditioning on every relevant variable. The statistic is the unstandardized Cramér von Mises (CvM) statistic over a grid with one point for every unit of the unit table. Its multiplier draws use one matrix of Rademacher signs shared by all cells and grid points, at the unit or cluster level. The p value is the share of draws that exceed the statistic, and the critical value is their empirical type-1 &lt;code>1 - alp&lt;/code> quantile.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Field&lt;/th>
&lt;th>Contents&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>CvM&lt;/code>&lt;/td>
&lt;td>test statistic&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>CvMb&lt;/code>&lt;/td>
&lt;td>the statistic in each multiplier draw&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>CvMcval&lt;/code>, &lt;code>CvMpval&lt;/code>&lt;/td>
&lt;td>critical value and p value&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>KS&lt;/code>, &lt;code>KSb&lt;/code>, &lt;code>KScval&lt;/code>, &lt;code>KSpval&lt;/code>&lt;/td>
&lt;td>&lt;code>NULL&lt;/code>; this test is not computed&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>clustervars&lt;/code>, &lt;code>xformla&lt;/code>&lt;/td>
&lt;td>settings of the test&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>chained&lt;/code>&lt;/td>
&lt;td>the null, &lt;code>status&lt;/code>, &lt;code>reason&lt;/code>, base period, tested cells with their estimates, route, grid, statistic and multiplier conventions, clusters, random number record, execution and resources&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;code>status&lt;/code> is &lt;code>&amp;quot;available&amp;quot;&lt;/code>, &lt;code>&amp;quot;unavailable&amp;quot;&lt;/code> (with &lt;code>NA&lt;/code> statistics and a reason) or &lt;code>&amp;quot;not_applicable&amp;quot;&lt;/code> for a custom &lt;code>est_method&lt;/code> function. The test is unavailable when a needed cell is unavailable, when a covariate needed on the grid is missing or has a level absent from the fitted design, when there is no cell before treatment to test, when clustered inference has fewer than two clusters, or when the estimated process is exactly zero everywhere. Estimated effects are never affected. The conditional test is separate from &lt;code>W&lt;/code> and &lt;code>Wpval&lt;/code>. Its calibration requires uniform process and multiplier regularity conditions, including a growing number of independent clusters for clustered inference.&lt;/p>
&lt;h2 id="plots">Plots&lt;/h2>
&lt;p>&lt;code>ggdid()&lt;/code> returns &lt;code>did&lt;/code>&amp;rsquo;s &lt;code>ggplot2&lt;/code> plots with intervals that use the result&amp;rsquo;s critical values. For a group time result, the plot is built on the grid of cohorts and periods; &lt;code>attr(p, &amp;quot;cdid_presentation_grid&amp;quot;)&lt;/code> lists each grid point with its &lt;code>group&lt;/code>, &lt;code>time&lt;/code>, &lt;code>target_id&lt;/code>, &lt;code>att&lt;/code>, &lt;code>se&lt;/code>, &lt;code>status&lt;/code> (&lt;code>&amp;quot;available&amp;quot;&lt;/code>, &lt;code>&amp;quot;unavailable&amp;quot;&lt;/code> or &lt;code>&amp;quot;unrequested&amp;quot;&lt;/code>), &lt;code>support_status&lt;/code> and &lt;code>support_reason&lt;/code>. For an aggregated result, &lt;code>attr(p, &amp;quot;cdid_presentation_bins&amp;quot;)&lt;/code> lists &lt;code>key&lt;/code>, &lt;code>label&lt;/code>, &lt;code>att&lt;/code>, &lt;code>se&lt;/code>, &lt;code>status&lt;/code> (&lt;code>&amp;quot;available&amp;quot;&lt;/code>, &lt;code>&amp;quot;restricted&amp;quot;&lt;/code> or &lt;code>&amp;quot;unavailable&amp;quot;&lt;/code>) and &lt;code>reason&lt;/code>. As in &lt;code>did&lt;/code>, &lt;code>ggdid()&lt;/code> refuses the simple type; it has no plot. For OR and DR fits and for change imputation and the augmented correction, the plot caption shows the estimator label.&lt;/p>
&lt;h2 id="saving-and-exporting">Saving and exporting&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Tables.&lt;/strong> &lt;code>tidy()&lt;/code> and &lt;code>glance()&lt;/code> return data frames that &lt;code>write.csv()&lt;/code> exports, with unavailable values as &lt;code>NA&lt;/code>. The overall summary of the group type is the first row of its tidy table; for the dynamic and calendar types use &lt;code>overall.att&lt;/code> and &lt;code>overall.se&lt;/code>, as in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/#aggregate-the-effects">Get started&lt;/a>.&lt;/li>
&lt;li>&lt;strong>Plots.&lt;/strong> Save with &lt;code>ggplot2::ggsave()&lt;/code>.&lt;/li>
&lt;li>&lt;strong>Fitted objects.&lt;/strong> &lt;code>saveRDS()&lt;/code> keeps the complete result, including influence functions, for later inspection with the same package versions; &lt;code>fit$chained$versions&lt;/code> records them. The panel data are not part of the result.&lt;/li>
&lt;/ul>
&lt;h2 id="chain-and-combination-reports">Chain and combination reports&lt;/h2>
&lt;p>&lt;code>chain_report(fit, cohort = NULL, time = NULL, include_pre = FALSE, tol = 1e-10)&lt;/code> inspects how each reported cell is identified and reconstructed from the retained moments in &lt;code>fit$chained$chain_info&lt;/code>:&lt;/p>
&lt;ul>
&lt;li>&lt;code>cr$summary&lt;/code> (or &lt;code>as.data.frame(cr, what = &amp;quot;summary&amp;quot;)&lt;/code>) returns one row per selected cell with &lt;code>target_id&lt;/code>, &lt;code>g&lt;/code>, &lt;code>time&lt;/code>, &lt;code>event_time&lt;/code>, &lt;code>ref&lt;/code>, &lt;code>role&lt;/code>, &lt;code>available&lt;/code>, &lt;code>status&lt;/code>, &lt;code>requires_chaining&lt;/code> (whether no single-pair comparison spans from the baseline date directly to &lt;code>time&lt;/code> in the unreduced catalog), &lt;code>n_witness_links&lt;/code>, &lt;code>n_active_gmm_links&lt;/code>, &lt;code>estimate&lt;/code>, &lt;code>se&lt;/code>, &lt;code>chain_path&lt;/code>, and &lt;code>support_reason&lt;/code>.&lt;/li>
&lt;li>&lt;code>as.data.frame(cr, what = &amp;quot;witness&amp;quot;)&lt;/code> returns a short path of comparisons that identifies the selected effect (&lt;code>s&lt;/code>, &lt;code>t&lt;/code>, &lt;code>link_role&lt;/code>, &lt;code>control_pool&lt;/code>, &lt;code>sign&lt;/code>, &lt;code>link_estimate&lt;/code>, &lt;code>contribution&lt;/code>) bridging the reference period to the target date.&lt;/li>
&lt;li>&lt;code>as.data.frame(cr, what = &amp;quot;gmm_weights&amp;quot;)&lt;/code> (or &lt;code>print(cr, show_gmm_weights = TRUE)&lt;/code>) returns all retained comparison moments with &lt;code>|gmm_weight| &amp;gt; tol&lt;/code> and their linear &lt;code>contribution = gmm_weight * link_estimate&lt;/code>, which sum to the reported estimate.&lt;/li>
&lt;/ul>
&lt;h2 id="inspect-fitted-models">Inspect fitted models&lt;/h2>
&lt;p>Set &lt;code>control = list(keep_nuisance = TRUE)&lt;/code> in the estimation call to keep the fitted equations and coefficient tables. Use &lt;code>nuisance_models(fit)&lt;/code> to see which models are available. Select a component and a fitted block to see the equation, its sample and its coefficient estimates with standard errors.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Component&lt;/th>
&lt;th>What it models&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>&amp;quot;treatment&amp;quot;&lt;/code>&lt;/td>
&lt;td>Which units enter the treatment group in a comparison&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;outcome&amp;quot;&lt;/code>&lt;/td>
&lt;td>The untreated change used as the counterfactual&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;selection&amp;quot;&lt;/code>&lt;/td>
&lt;td>Whether the outcomes needed for a change are observed&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;imputation&amp;quot;&lt;/code>&lt;/td>
&lt;td>The actual outcome change within the relevant group&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>For a doubly robust treatment fit with augmented missing-outcome adjustment, all four models can be active. The &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/notebooks/cdid_practical_guide.qmd" target="_blank" rel="noopener">hands-on notebook&lt;/a> shows a coefficient table for each in its section on the four fitted models. Use &lt;code>?nuisance_models&lt;/code> for options and supported fits.&lt;/p>
&lt;p>Keep three kinds of weights apart. Observation weights adjust for missing outcomes. Combination coefficients (&lt;code>gmm_weight&lt;/code> in &lt;code>chain_report()&lt;/code>) reconstruct an effect from comparisons; they can be negative and are not population shares. Aggregation weights combine effects into summaries.&lt;/p>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 19 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;strong>Results&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>Sampling information for the observation model</title><link>https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/</guid><description>&lt;p>Results below were produced on October 29, 2026 with &lt;code>cdid&lt;/code> 1.1.0.0, &lt;code>did&lt;/code> 2.5.1 and &lt;code>DRDID&lt;/code> 1.3.0 under R 4.5.2, using the displayed seeds where applicable. These are individual examples; they do not establish repeated-sample coverage.&lt;/p>
&lt;p>With &lt;code>selection_model = &amp;quot;pair_logit&amp;quot;&lt;/code>, observation weighting fits one logit per cohort and pair of dates for the probability that a unit is observed at both dates. By default each of these pair logits is fitted on all of the cohort&amp;rsquo;s rows in the unit table. This advanced page explains the smaller fitting sets that &lt;code>selection_universe&lt;/code> offers, what &lt;code>selection_rho&lt;/code> and &lt;code>selection_justification&lt;/code> must then declare, and why a smaller fitting set is a different model rather than a simplification. It expands the advanced section of &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#advanced-fitting-the-observation-model-on-part-of-the-unit-table">Handling missing outcomes&lt;/a>, which you should read first, and introduces no new option.&lt;/p>
&lt;p>The declared target remains the average treatment effects of the study population listed by the unit table; changing the fitting set supplies no validity guarantee.&lt;/p>
&lt;p>The identity and hand table below use covariates fixed within units and fixed unit sampling weights. Write W for the full scientific conditioning set needed by the analysis, including relevant treatment, outcome and observation covariates. An observation formula may use fewer variables only when its model remains correct for the required conditioning set. The existing &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#changing-covariates-and-weights">reference-date covariate and weight options&lt;/a> remain available; this fixed-covariate derivation alone supplies no blanket transport guarantee for changing reference contexts.&lt;/p>
&lt;h2 id="three-sets-of-units">Three sets of units&lt;/h2>
&lt;p>&lt;code>selection_universe&lt;/code> names one of three nested sets of rows of the unit table:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>F&lt;/strong>, the whole unit table: the study population, one row per unit, including units observed once or never.&lt;/li>
&lt;li>&lt;strong>B&lt;/strong>, the units with at least one observed outcome.&lt;/li>
&lt;li>&lt;strong>A&lt;/strong>, the units with at least two observed outcomes.&lt;/li>
&lt;/ul>
&lt;p>The counts are of observed outcomes, that is, nonmissing values of the outcome column at the dates of the stored calendar. They do not describe structural observation windows: a unit scheduled for two interviews that answers only one belongs to B but not to A. A row of &lt;code>data&lt;/code> kept for its covariates with a missing outcome adds nothing to the count, while an outcome replaced by zero counts as observed, one more reason to &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/#never-impute-zero-for-missing-outcomes">keep missing outcomes as &lt;code>NA&lt;/code>&lt;/a>.&lt;/p>
&lt;p>If you omit &lt;code>frame&lt;/code>, the units present in &lt;code>data&lt;/code> form F, including units observed once and units whose outcomes are all missing. A unit that was never observed and has no row in &lt;code>data&lt;/code> is then outside F, and no fitting set brings it back. When every unit in &lt;code>data&lt;/code> has an observed outcome, F and B are then the same set.&lt;/p>
&lt;p>These sets answer two different questions. The first is which units supply observed changes. A change needs two observed outcomes of the same unit, at both dates of a pair, so every observed change comes from A, whatever the fitting set. The second is the question &lt;code>selection_universe&lt;/code> answers: which units enter the pair logits, as successes (observed at both dates of the pair) or failures (not observed at both). Every success belongs to A, so the three fitting sets differ only in the failures that the logits see. For a pair e, the rows of a cohort play these roles in the cohort&amp;rsquo;s logit:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Row of the unit table&lt;/th>
&lt;th>Observed changes&lt;/th>
&lt;th>Under &lt;code>&amp;quot;F&amp;quot;&lt;/code>&lt;/th>
&lt;th>Under &lt;code>&amp;quot;B&amp;quot;&lt;/code>&lt;/th>
&lt;th>Under &lt;code>&amp;quot;A&amp;quot;&lt;/code>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>observed at both dates of e&lt;/td>
&lt;td>the change over e, and over its other observed pairs&lt;/td>
&lt;td>success&lt;/td>
&lt;td>success&lt;/td>
&lt;td>success&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>observed at two or more dates, but not at both dates of e&lt;/td>
&lt;td>changes over other pairs only&lt;/td>
&lt;td>failure&lt;/td>
&lt;td>failure&lt;/td>
&lt;td>failure&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>observed at one date&lt;/td>
&lt;td>none&lt;/td>
&lt;td>failure&lt;/td>
&lt;td>failure&lt;/td>
&lt;td>not a row&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>no observed outcome, including rows present only in the unit table&lt;/td>
&lt;td>none&lt;/td>
&lt;td>failure&lt;/td>
&lt;td>not a row&lt;/td>
&lt;td>not a row&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Whatever its role in the logits, every row keeps its cohort, weight and cluster label and counts in the cohort shares, the cohort rates and the standard errors.&lt;/p>
&lt;h2 id="what-the-fitting-set-changes">What the fitting set changes&lt;/h2>
&lt;p>&lt;code>selection_universe&lt;/code> chooses the fitting set U, the rows on which each cohort&amp;rsquo;s pair logits are fitted. The observation weights then combine these logits with cohort rates and, under &lt;code>&amp;quot;B&amp;quot;&lt;/code> or &lt;code>&amp;quot;A&amp;quot;&lt;/code>, with the declaration described below. The choice does not change the study population, the target effects or the cohort shares, and the influence function keeps one row for every row of the unit table, all counted in the reported &lt;code>n&lt;/code>. The package determines B and A itself from the outcomes in &lt;code>data&lt;/code>. Do not trim the unit table or &lt;code>data&lt;/code> to U: a unit removed from the unit table, or from &lt;code>data&lt;/code> when you omit &lt;code>frame&lt;/code>, leaves the study population, and outcomes removed from &lt;code>data&lt;/code> change which units count as observed.&lt;/p>
&lt;p>For the fixed covariates used here, the fitting set also decides where the observation design is read. Under &lt;code>&amp;quot;F&amp;quot;&lt;/code> they are read on every row of the unit table. Under &lt;code>&amp;quot;B&amp;quot;&lt;/code> or &lt;code>&amp;quot;A&amp;quot;&lt;/code>, the observation design and the column named by &lt;code>selection_rho&lt;/code> are evaluated only on rows of U, so their values may be missing outside U as long as no other active part of the fit reads them there. Under &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, every row of the unit table still needs a known cohort, and a weight and a cluster label when you use them, and the treatment and outcome models keep their own covariate requirements. A missing or nonfinite observation covariate on a row of U is refused with an error. The package does not infer missing attributes, drop rows, or change the fitting set, the model or the target to make a fit succeed.&lt;/p>
&lt;h2 id="where-the-choice-is-available">Where the choice is available&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Route&lt;/th>
&lt;th>Arguments&lt;/th>
&lt;th>Fitting set&lt;/th>
&lt;th>Models for missing outcomes&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Observation weighting with the pair logit&lt;/td>
&lt;td>&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, &lt;code>selection_est_method = &amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>selection_model = &amp;quot;pair_logit&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;F&amp;quot;&lt;/code> (default), &lt;code>&amp;quot;B&amp;quot;&lt;/code> or &lt;code>&amp;quot;A&amp;quot;&lt;/code>&lt;/td>
&lt;td>one pair logit per cohort and pair, fitted on the cohort&amp;rsquo;s rows in U&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Observation weighting with the product of date probabilities&lt;/td>
&lt;td>the same, with &lt;code>selection_model = &amp;quot;independent_period_logit&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;F&amp;quot;&lt;/code> only&lt;/td>
&lt;td>date logits fitted on the whole unit table&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Change imputation&lt;/td>
&lt;td>&lt;code>selection_est_method = &amp;quot;imputation&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;F&amp;quot;&lt;/code> only, with &lt;code>selection_rho = NULL&lt;/code>&lt;/td>
&lt;td>no observation model; each change model is trained on the units observed at both dates of its pair and evaluated on every row of its cohort in the unit table&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Augmented correction&lt;/td>
&lt;td>&lt;code>selection_est_method = &amp;quot;dr&amp;quot;&lt;/code>, with treatment IPW, OR or DR&lt;/td>
&lt;td>&lt;code>&amp;quot;F&amp;quot;&lt;/code> only, with &lt;code>selection_rho = NULL&lt;/code>&lt;/td>
&lt;td>the observation model, fitted on every row of the cohort in the unit table, and the change models of change imputation&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>In the first row, the treatment adjustment can be any that observation weighting supports. &lt;code>&amp;quot;B&amp;quot;&lt;/code> and &lt;code>&amp;quot;A&amp;quot;&lt;/code> are available only there; other requests are refused with an error before estimation, and no other combination is substituted.&lt;/p>
&lt;p>Pooling and the formulas work the same way under every fitting set. &lt;code>selection_pooling&lt;/code> restricts only the slopes of the pair logits: &lt;code>&amp;quot;separate&amp;quot;&lt;/code> (the default) gives each cell, a cohort and pair, its own slopes, &lt;code>&amp;quot;within_cohort&amp;quot;&lt;/code> shares slopes across a cohort&amp;rsquo;s pairs, and &lt;code>&amp;quot;across_cohorts&amp;quot;&lt;/code> shares one slope vector across all cells. Each cell keeps its own intercept when the observation formula has one. &lt;code>selection_xformla&lt;/code>, or &lt;code>xformla&lt;/code> when it is inherited, defines the covariates of the pair logits, and &lt;code>xformla&lt;/code> alone defines the treatment and outcome models. Pooling and the fitting set are independent choices.&lt;/p>
&lt;p>Only the pair logit of observation weighting has a fitting set choice. B and A describe actual outcome counts, not an initial observation schedule or a model for singleton outcome levels. Their representativeness or transport declaration and the mean-change conditions below still need justification. Known pair probabilities, including a design probability of one, are not supported.&lt;/p>
&lt;h2 id="what-you-declare-with-b-or-a">What you declare with B or A&lt;/h2>
&lt;p>With &lt;code>&amp;quot;F&amp;quot;&lt;/code>, the fitting set is the study population itself, the ratio defined below equals 1, and &lt;code>selection_rho&lt;/code> must be &lt;code>NULL&lt;/code>; supplying a column is refused.&lt;/p>
&lt;p>With &lt;code>&amp;quot;B&amp;quot;&lt;/code> or &lt;code>&amp;quot;A&amp;quot;&lt;/code>, the logits describe units of U only, and you must state how U relates to the study population. &lt;code>selection_justification&lt;/code> must be a nonempty character string, and requests without one are refused. What it asserts depends on &lt;code>selection_rho&lt;/code>:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;code>selection_rho&lt;/code>&lt;/th>
&lt;th>What the justification asserts&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>NULL&lt;/code>&lt;/td>
&lt;td>Within each cohort, the conditioning variables W have the same weighted distribution in U as in the study population, so the ratio below equals 1. Equivalently, membership in U does not depend on these covariates within the cohort.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>the name of a column of the unit table&lt;/td>
&lt;td>The column holds the known ratio defined below, and the justification states where it comes from.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Representativeness is not automatically true: whether a unit is observed at least once or twice can depend on the same covariates that drive observation of each pair. A transport column is correct only if its source is. The package records the justification as written, and no fit diagnostic can confirm either assertion, because the logits are fitted on U alone and describe observation within U.&lt;/p>
&lt;p>For known transport, the column holds, on every row of U,&lt;/p>
&lt;pre>&lt;code>rho_U(W, G) = f_P(W | G, U) / f_P(W | G)
&lt;/code>&lt;/pre>
&lt;p>where W is the full scientific conditioning set, G the cohort and &lt;code>f_P&lt;/code> for a density under the declared weighted population law: the study population described by the unit table and its fixed sampling weights, the same law that defines the target effects. The density of the fitting set is in the numerator. The column must be numeric, with finite positive values on U, fixed and known rather than estimated from your data, and normalized: as a ratio of two densities, &lt;code>rho_U&lt;/code> averages to one over the cohort&amp;rsquo;s population. The validator checks that the named column is numeric and its values on U are finite and positive. It cannot establish that those values are the known normalized density ratio; that remains your declaration. It neither estimates nor renormalizes the column. Estimated or unnormalized ratios are not supported. Do not estimate a ratio from your sample, or rescale one until its sample average is one, to meet these requirements: the package would treat the result as known, and the standard errors would omit its estimation uncertainty.&lt;/p>
&lt;p>The declaration and the logit for observation within U are separate assumptions, and either can hold while the other fails. The illustration below has a correct logit and a false declaration of representativeness.&lt;/p>
&lt;h2 id="the-identity-behind-the-weights">The identity behind the weights&lt;/h2>
&lt;p>Write &lt;code>S(e) = 1&lt;/code> when a unit is observed at both dates of pair e. Under &lt;code>&amp;quot;B&amp;quot;&lt;/code> or &lt;code>&amp;quot;A&amp;quot;&lt;/code>, each pair logit models&lt;/p>
&lt;pre>&lt;code>q_U(e, W) = P(S(e) = 1 | W, G, U)
&lt;/code>&lt;/pre>
&lt;p>the probability of observing the pair among the cohort&amp;rsquo;s units in U, which is a different probability for A and for B. Let &lt;code>pi_U(G) = P(U | G)&lt;/code> be the share of the cohort&amp;rsquo;s study population that belongs to U. A unit with &lt;code>S(e) = 1&lt;/code> has two observed outcomes, so it belongs to both A and B. Under the positivity that weighting requires, conditioning on membership in U and applying Bayes' rule to &lt;code>P(U | W, G)&lt;/code> gives the identity&lt;/p>
&lt;pre>&lt;code>P(S(e) = 1 | W, G) = pi_U(G) * rho_U(W, G) * q_U(e, W)
&lt;/code>&lt;/pre>
&lt;p>The left side is the probability of observing the pair in the cohort&amp;rsquo;s study population. Under &lt;code>&amp;quot;F&amp;quot;&lt;/code> the pair logit models it directly; under &lt;code>&amp;quot;B&amp;quot;&lt;/code> or &lt;code>&amp;quot;A&amp;quot;&lt;/code> the declaration transports the fitted probability through the right side. Within a cohort, the observation adjustment is proportional to its inverse; total weights also include the fixed unit sampling weights and cohort rate normalizations. The required positivity means that every covariate value of the cohort&amp;rsquo;s population must also be possible in U, so that &lt;code>rho_U&lt;/code> is positive, and that the pair must have a positive probability of being observed there, so that &lt;code>q_U&lt;/code> is positive.&lt;/p>
&lt;p>&lt;code>pi_U(G)&lt;/code> is a population quantity in this identity, not an additional public input. The package computes the response and fitting-set rate quantities it needs from the declared unit table, weights and outcome counts; F remains the population and inference frame. Complete influence functions account for estimated rates and logits. The fixed, known ratio contributes no estimation uncertainty.&lt;/p>
&lt;p>The identity follows from the definitions alone. It shows how the denominator is assembled, and it does not by itself establish conditional mean trends missing at random, parallel trends or valid treatment models for the pairs the estimator uses.&lt;/p>
&lt;h2 id="an-illustration-with-probabilities-chosen-by-hand">An illustration with probabilities chosen by hand&lt;/h2>
&lt;p>The probabilities below are chosen by hand for one cohort, one pair of dates and a single fixed conditioning variable X with two values, so W = X here. They illustrate the identity; they are not fitted values, package output or a simulation design.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;/th>
&lt;th>X = 0&lt;/th>
&lt;th>X = 1&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Share of the cohort&amp;rsquo;s study population&lt;/td>
&lt;td>0.5&lt;/td>
&lt;td>0.5&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Probability of belonging to A&lt;/td>
&lt;td>0.2&lt;/td>
&lt;td>0.6&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Share among the cohort&amp;rsquo;s units in A&lt;/td>
&lt;td>0.25&lt;/td>
&lt;td>0.75&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>rho_A(X, G)&lt;/code>&lt;/td>
&lt;td>0.5&lt;/td>
&lt;td>1.5&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>q_A(e, X)&lt;/code> for the pair of dates 1 and 2&lt;/td>
&lt;td>0.5&lt;/td>
&lt;td>0.5&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Probability of observing the pair in the study population&lt;/td>
&lt;td>0.1&lt;/td>
&lt;td>0.3&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The cohort&amp;rsquo;s share in A is &lt;code>pi_A(G) = 0.5 * 0.2 + 0.5 * 0.6 = 0.4&lt;/code>, so the shares within A are &lt;code>0.5 * 0.2 / 0.4 = 0.25&lt;/code> and &lt;code>0.5 * 0.6 / 0.4 = 0.75&lt;/code>, and the ratios are &lt;code>0.25 / 0.5 = 0.5&lt;/code> and &lt;code>0.75 / 0.5 = 1.5&lt;/code>. The identity reproduces the last row: &lt;code>0.4 * 0.5 * 0.5 = 0.1&lt;/code> and &lt;code>0.4 * 1.5 * 0.5 = 0.3&lt;/code>. These values fit, for example, three stored dates at which each unit of A, whatever its X, is observed only at dates 1 and 2 with probability 0.5, only at dates 1 and 3 with probability 0.25, and only at dates 2 and 3 with probability 0.25.&lt;/p>
&lt;p>Within A the pair probability is the same for both values of X, yet in the population it is three times larger for X = 1: a constant &lt;code>q_U&lt;/code> does not imply a constant population probability. A logit on A describes &lt;code>q_A&lt;/code> exactly here, and that says nothing about the ratio. Declaring &lt;code>selection_rho = NULL&lt;/code> would assert shares of 0.5 and 0.5 within A, but they are 0.25 and 0.75. The identity would then give 0.2 for both values, every observed pair would receive the same observation adjustment, and the weighted pairs would keep the covariate shares of the observed pairs, 0.25 and 0.75, instead of the population&amp;rsquo;s 0.5 and 0.5. With the correct column, the observation adjustment factors are in the proportion of 1 / 0.1 to 1 / 0.3 and restore equal shares under the declared weighted population law. A ratio of 1 is justified only when the covariate distributions match, never because the logit for &lt;code>q_U&lt;/code> fits well.&lt;/p>
&lt;h2 id="why-a-is-not-always-simpler">Why A is not always simpler&lt;/h2>
&lt;p>A smaller fitting set changes the probability being modeled, not only the number of rows. Because &lt;code>q_U(e, W)&lt;/code> is &lt;code>P(S(e) = 1 | W, G)&lt;/code> divided by &lt;code>P(U | W, G)&lt;/code>, a logit that is correct on the whole unit table is generally not correct on A or B, and the reverse.&lt;/p>
&lt;p>A smaller fitting set can also leave a cell without failures, since moving from F to B to A removes only failures. With two stored dates, A is exactly the set of units observed at both dates, so every row of the A logit is a success and &lt;code>q_A = 1&lt;/code>. For a nonempty A fitting set this probability is one by definition, but a logit with its own free cell intercept has no finite interior root. The requested fit is refused; pooling slopes keeps the intercepts. This special identity does not provide a supported known-probability interface. In other settings an all-success sample alone does not prove a population probability of one. An all-failure cell with its own free intercept is also refused. Separation, boundary solutions and rank deficiency are refused under every fitting set, and no observations are trimmed. Since version 1.1.0.0, finite inverse observation denominators use a fixed &lt;code>1e-6&lt;/code> floor; this safeguard does not repair a failed logit or support violation (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#probability-safeguards">Probability safeguards&lt;/a>). The whole unit table faces the same checks, so a fit on F is not guaranteed to succeed either.&lt;/p>
&lt;p>Fewer fitting rows guarantee neither a faster fit nor smaller standard errors, and the package does not rank the fitting sets by efficiency or flexibility. A sufficient route under any fitting set retains conditional mean trends missing at random for every pair used given a scientifically sufficient W, positivity, a correct pair logit on U for each needed cell, valid representativeness or known transport, the treatment adjustment conditions, parallel trends, no anticipation and large sample regularity. These are separate premises: a correct logit does not prove transport, and correct transport does not prove either the logit or the outcome conditions. Sharing slopes requires correctness across the cells that share them, and all active fits and catalog links must meet their own regularity and support requirements.&lt;/p>
&lt;h2 id="declaring-the-choice-in-a-call">Declaring the choice in a call&lt;/h2>
&lt;p>Each list below is an argument template, rather than a stand-alone fit. For executed fits and their output, see &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>.&lt;/p>
&lt;p>Supply one of these sets of arguments in your &lt;code>cdid::att_gt()&lt;/code> call, together with the data, unit table, formulas and treatment adjustment of your analysis.&lt;/p>
&lt;pre>&lt;code class="language-r"># Pair logits fitted on the whole unit table, the default.
observation_args_F &amp;lt;- list(
selection = &amp;quot;conditional_mtar&amp;quot;,
selection_est_method = &amp;quot;ipw&amp;quot;,
selection_model = &amp;quot;pair_logit&amp;quot;,
selection_universe = &amp;quot;F&amp;quot;,
selection_rho = NULL
)
# Pair logits fitted on units with at least two observed
# outcomes, declared representative within each cohort.
observation_args_A &amp;lt;- list(
selection = &amp;quot;conditional_mtar&amp;quot;,
selection_est_method = &amp;quot;ipw&amp;quot;,
selection_model = &amp;quot;pair_logit&amp;quot;,
selection_universe = &amp;quot;A&amp;quot;,
selection_rho = NULL,
selection_justification = paste(
&amp;quot;Whether a unit has at least two observed outcomes depends only on its&amp;quot;,
&amp;quot;randomly assigned revisit schedule, which is independent of the&amp;quot;,
&amp;quot;scientific conditioning variables within each cohort, so within each cohort the&amp;quot;,
&amp;quot;units observed at least twice have the weighted covariate distribution&amp;quot;,
&amp;quot;of the study population.&amp;quot;
)
)
# Presumes that the unit table passed as `frame` already has a
# column `rho` holding the fixed, known, normalized ratio
# f_P(W | G, A) / f_P(W | G) on every row of A.
observation_args_A_transport &amp;lt;- list(
selection = &amp;quot;conditional_mtar&amp;quot;,
selection_est_method = &amp;quot;ipw&amp;quot;,
selection_model = &amp;quot;pair_logit&amp;quot;,
selection_universe = &amp;quot;A&amp;quot;,
selection_rho = &amp;quot;rho&amp;quot;,
selection_justification = paste(
&amp;quot;Column rho is the known ratio f_P(W | G, A) / f_P(W | G) under the&amp;quot;,
&amp;quot;weighted population law, taken from the design documentation of the&amp;quot;,
&amp;quot;revisit sample; it is not estimated from these data.&amp;quot;
)
)
&lt;/code>&lt;/pre>
&lt;p>After a fit with observation weighting, the selection record shows what you declared:&lt;/p>
&lt;pre>&lt;code class="language-r"># Requires `fit`, a result of cdid::att_gt() fitted with
# selection = &amp;quot;conditional_mtar&amp;quot; and selection_est_method = &amp;quot;ipw&amp;quot;.
str(fit$chained$selection[c(&amp;quot;selection_model&amp;quot;, &amp;quot;selection_pooling&amp;quot;,
&amp;quot;fitting_universe&amp;quot;, &amp;quot;empirical_repeat_rates&amp;quot;)])
&lt;/code>&lt;/pre>
&lt;details>
&lt;summary>Console output&lt;/summary>
&lt;pre>&lt;code class="language-text">List of 4
$ selection_model : chr &amp;quot;independent_period_logit&amp;quot;
$ selection_pooling : chr &amp;quot;separate&amp;quot;
$ fitting_universe : chr &amp;quot;F&amp;quot;
$ empirical_repeat_rates: Named num [1:2] 0.963 0.968
..- attr(*, &amp;quot;names&amp;quot;)= chr [1:2] &amp;quot;3&amp;quot; &amp;quot;Inf&amp;quot;
&lt;/code>&lt;/pre>
&lt;/details>
&lt;p>This fit uses date logits with separate slopes and the full study-unit table. The last entries show the proportion of repeat observers in cohort 3 and in the never-treated group, stored as &lt;code>Inf&lt;/code>.&lt;/p>
&lt;h2 id="related-pages">Related pages&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#advanced-fitting-the-observation-model-on-part-of-the-unit-table">Handling missing outcomes&lt;/a>: the assumptions and models of observation weighting, and the advanced section this page expands.&lt;/li>
&lt;li>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#handling-missing-outcomes">Options reference&lt;/a>: the definitions of &lt;code>selection_universe&lt;/code>, &lt;code>selection_rho&lt;/code> and &lt;code>selection_justification&lt;/code>, and the supported combinations.&lt;/li>
&lt;li>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/#the-unit-table-frame-and-unit-observation-roles">Prepare your panel and unit table&lt;/a>: building the unit table and the roles of units with zero, one or repeated observations.&lt;/li>
&lt;li>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Compare model robustness across treatment and missing outcome adjustments&lt;/a>: which models must be correct for each combination.&lt;/li>
&lt;li>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/#the-chained-record">Results reference&lt;/a>: the contents of &lt;code>fit$chained&lt;/code>.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 10 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/">Treatment adjustment&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;strong>Sampling information for the observation model&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>Short Pre-Treatment Windows and Cross-Pair Chaining</title><link>https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/</guid><description>&lt;p>Longitudinal panels with staggered adoption often observe each unit only over a limited window around treatment—for instance, administrative registers tracking workers over fixed windows around an event, rotating household surveys, or longitudinal surveys that switch from annual to biennial waves. When no never-treated group is available, standard two-period not-yet-treated estimators (&lt;code>did::att_gt()&lt;/code>) run out of single-cohort comparison groups at long horizons: by the time early-treated cohort $g$ reaches $g + 4$, later-treated cohorts observed back at $g - 1$ have already entered treatment, while cohorts still untreated at $g + 4$ were not yet observed at $g - 1$.&lt;/p>
&lt;p>This guide shows how &lt;code>cdid::att_gt()&lt;/code> recovers long-horizon effects in short-window designs across both same-pair and cross-pair chained modes, how to inspect the underlying control chains with &lt;code>chain_report()&lt;/code>, and how to choose among &lt;code>pt_assumption = &amp;quot;post&amp;quot;&lt;/code> vs &lt;code>&amp;quot;ctrl&amp;quot;&lt;/code> and &lt;code>gmm_weighting = &amp;quot;optimal&amp;quot;&lt;/code> vs &lt;code>&amp;quot;within&amp;quot;&lt;/code>.&lt;/p>
&lt;hr>
&lt;h2 id="1-simulating-a-staggered-short-window-panel-no-never-treated-units">1. Simulating a Staggered Short-Window Panel (No Never-Treated Units)&lt;/h2>
&lt;p>Consider years &lt;code>2001&lt;/code> through &lt;code>2010&lt;/code> and six adoption cohorts &lt;code>2005, 2006, ..., 2010&lt;/code>, with no never-treated units. Each cohort $g$ enters the panel four years prior to treatment ($\max(2001, g - 4)$ through &lt;code>2010&lt;/code>):&lt;/p>
&lt;pre>&lt;code class="language-r">library(cdid)
set.seed(20261111)
cohorts &amp;lt;- 2005:2010
rows &amp;lt;- list()
uid &amp;lt;- 0L
for (g in cohorts) {
win_t &amp;lt;- seq.int(max(2001L, g - 4L), 2010L)
for (i in seq_len(100L)) {
uid &amp;lt;- uid + 1L
alpha_i &amp;lt;- rnorm(1, mean = 0.5 * (g - 2005), sd = 1.2)
for (tv in win_t) {
tau &amp;lt;- if (tv &amp;gt;= g) 1.0 + 1.0 * (tv - g) else 0.0 # ATT(2005, 2009) = 5.0
y_it &amp;lt;- alpha_i + 0.4 * (tv - 2001) + tau + rnorm(1)
rows[[length(rows) + 1L]] &amp;lt;- data.frame(id = uid, period = tv, G = g, y = y_it)
}
}
}
df_short &amp;lt;- do.call(rbind, rows)
&lt;/code>&lt;/pre>
&lt;p>Why does two-period &lt;code>did::att_gt(..., control_group = &amp;quot;notyettreated&amp;quot;)&lt;/code> return &lt;code>NA&lt;/code> for &lt;code>ATT(2005, 2008)&lt;/code> and &lt;code>ATT(2005, 2009)&lt;/code>?&lt;/p>
&lt;ul>
&lt;li>Cohort &lt;code>2005&lt;/code>&amp;rsquo;s reference period is &lt;code>2004&lt;/code>.&lt;/li>
&lt;li>Only cohorts &lt;code>2009&lt;/code> and &lt;code>2010&lt;/code> remain untreated in &lt;code>2008&lt;/code>, and only cohort &lt;code>2010&lt;/code> remains untreated in &lt;code>2009&lt;/code>.&lt;/li>
&lt;li>Cohort &lt;code>2009&lt;/code> enters the panel in &lt;code>2005&lt;/code> ($2009 - 4$), and cohort &lt;code>2010&lt;/code> enters in &lt;code>2006&lt;/code> ($2010 - 4$)—neither is observed at &lt;code>2004&lt;/code>.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="2-analytical-within-unit-weighting-vs-optimal-chained-gmm">2. Analytical Within-Unit Weighting vs. Optimal Chained GMM&lt;/h2>
&lt;p>In this design, all units in a cohort share the same dates and neither fit adjusts for covariates or observation probabilities. The within-weighted fit matches the available point estimates from stacked target-slice unit- or cohort-fixed-effect OLS on the same clean-control samples. The second fit uses PT-post and feasible two-step GMM weighting.&lt;/p>
&lt;pre>&lt;code class="language-r"># 1. Analytical within-unit covariance weighting under PT-ctrl and universal base
fit_within &amp;lt;- att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;G&amp;quot;,
control_group = &amp;quot;notyettreated&amp;quot;,
base_period = &amp;quot;universal&amp;quot;,
cross_pair = TRUE,
pt_assumption = &amp;quot;ctrl&amp;quot;,
gmm_weighting = &amp;quot;within&amp;quot;,
data = df_short
)
agg_within &amp;lt;- aggte(fit_within, type = &amp;quot;dynamic&amp;quot;, na.rm = TRUE)
summary(agg_within)
# 2. Optimal two-step GMM under weaker PT-post (no pre-reference control pooling)
fit_post_opt &amp;lt;- att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;G&amp;quot;,
control_group = &amp;quot;notyettreated&amp;quot;,
pt_assumption = &amp;quot;post&amp;quot;,
gmm_weighting = &amp;quot;optimal&amp;quot;,
cross_pair = TRUE,
data = df_short
)
&lt;/code>&lt;/pre>
&lt;p>Both &lt;code>fit_within&lt;/code> and &lt;code>fit_post_opt&lt;/code> (as well as default same-pair &lt;code>att_gt(..., control_group = &amp;quot;notyettreated&amp;quot;)&lt;/code> on contiguous windows) recover all &lt;strong>15 post-treatment effects&lt;/strong>, including &lt;code>ATT(2005, 2008)&lt;/code> ($e = 3$) and &lt;code>ATT(2005, 2009)&lt;/code> ($e = 4$). Only &lt;code>t = 2010&lt;/code> is &lt;code>NA&lt;/code> because cohort &lt;code>2010&lt;/code> is already treated in &lt;code>2010&lt;/code>, leaving zero untreated units in the population.&lt;/p>
&lt;hr>
&lt;h2 id="3-auditing-the-control-chain-with-chain_report">3. Auditing the Control Chain with &lt;code>chain_report()&lt;/code>&lt;/h2>
&lt;p>To see &lt;em>how&lt;/em> &lt;code>ATT(2005, 2009)&lt;/code> bridges &lt;code>2004&lt;/code> to &lt;code>2009&lt;/code> without any control cohort observed at both dates, call &lt;code>chain_report()&lt;/code>:&lt;/p>
&lt;pre>&lt;code class="language-r">cr &amp;lt;- chain_report(fit_within, cohort = 2005, time = c(2005, 2008, 2009))
print(cr)
&lt;/code>&lt;/pre>
&lt;p>&lt;code>chain_report()&lt;/code> flags &lt;code>requires_chaining = FALSE&lt;/code> for &lt;code>ATT(2005, 2005)&lt;/code> (directly supported by clean cohorts observed across &lt;code>2004&lt;/code> and &lt;code>2005&lt;/code>) and &lt;code>requires_chaining = TRUE&lt;/code> for &lt;code>ATT(2005, 2008)&lt;/code> and &lt;code>ATT(2005, 2009)&lt;/code>, printing a short path of eligible control comparisons and showing the GMM weights via &lt;code>as.data.frame(cr, what = &amp;quot;gmm_weights&amp;quot;)&lt;/code>.&lt;/p>
&lt;hr>
&lt;h2 id="4-practical-recommendations">4. Practical Recommendations&lt;/h2>
&lt;ol>
&lt;li>&lt;strong>Keep biennial or irregular waves in the data:&lt;/strong> &lt;code>cdid&lt;/code> chains over arbitrary stored calendar dates—so transitions from annual to biennial survey waves do not require dropping post-transition periods.&lt;/li>
&lt;li>&lt;strong>Always retain unit identifiers (&lt;code>idname&lt;/code>):&lt;/strong> When panel attrition correlates with persistent outcome levels $\alpha_i$, cohort-fixed-effect regressions confound changing cohort composition with treatment effects, while within-unit differencing cancels those persistent levels. The pair-representativeness and parallel-trends assumptions still apply.&lt;/li>
&lt;li>&lt;strong>Prefer &lt;code>gmm_weighting = &amp;quot;optimal&amp;quot;&lt;/code> and &lt;code>pt_assumption = &amp;quot;post&amp;quot;&lt;/code> in empirical work:&lt;/strong> Use &lt;code>gmm_weighting = &amp;quot;within&amp;quot;, pt_assumption = &amp;quot;ctrl&amp;quot;&lt;/code> when benchmarking directly against stacked target-slice regressions, and use &lt;code>gmm_weighting = &amp;quot;optimal&amp;quot;&lt;/code> and &lt;code>pt_assumption = &amp;quot;post&amp;quot;&lt;/code> to gain two-step GMM efficiency under serial correlation/heteroskedasticity while avoiding bias from pre-reference control trend shifts.&lt;/li>
&lt;li>&lt;strong>Adjust for covariates and non-random missingness with full &lt;code>cdid&lt;/code> generality:&lt;/strong> Baseline and reference-date covariate differences (&lt;code>xformla&lt;/code>, &lt;code>fix_weights&lt;/code>) across early and late adopters are handled via built-in &lt;code>&amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>&amp;quot;reg&amp;quot;&lt;/code>, or &lt;code>&amp;quot;dr&amp;quot;&lt;/code> (&lt;code>outcome_pooling = &amp;quot;separate&amp;quot;&lt;/code> or &lt;code>&amp;quot;pooled&amp;quot;&lt;/code>), and covariate-dependent attrition (&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>) is supported across &lt;code>&amp;quot;ipw&amp;quot;&lt;/code>, &lt;code>&amp;quot;imputation&amp;quot;&lt;/code>, and &lt;code>&amp;quot;dr&amp;quot;&lt;/code> (&lt;code>selection_est_method&lt;/code>) with all observation-logit and imputation pooling modes—propagating exact full-roster ($N = |F|$) M-estimation nuisance derivatives into unit- and cluster-robust standard errors, simultaneous confidence bands, and &lt;code>aggte()&lt;/code> aggregations.&lt;/li>
&lt;/ol>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 22 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a> · Last step; back to the &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">guide home&lt;/a>&lt;/p>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p></description></item><item><title>Treatment adjustment: IPW, OR and DR</title><link>https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/methods/treatment/</guid><description>&lt;p>Results below were produced on October 29, 2026 with &lt;code>cdid&lt;/code> 1.1.0.0, &lt;code>did&lt;/code> 2.5.1 and &lt;code>DRDID&lt;/code> 1.3.0 under R 4.5.2, using the displayed seeds where applicable. These are individual examples; they do not establish repeated-sample coverage. Their OR/DR calls explicitly request the historical pooled specification.&lt;/p>
&lt;p>&lt;code>est_method&lt;/code> decides how each treatment cohort is made comparable with its controls. The same choice applies to every short comparison in the chain. It is separate from the choice of how to handle missing outcomes, which has its own arguments and is described in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>.&lt;/p>
&lt;h2 id="what-is-adjusted">What is adjusted&lt;/h2>
&lt;p>A chained comparison involves a target cohort g, a control group and two dates s and t at which units are observed. The control group consists of units never treated or units not yet treated, according to &lt;code>control_group&lt;/code>. With baseline observation assumptions or observation weighting, the outcome changes come from units observed at both dates. Pure imputation and augmented correction instead reconstruct actual changes over the study population before treatment adjustment. A comparison contrasts adjusted cohort and control changes; it can represent a treatment-effect increment or an unrestricted pre-reference differential. The package combines the valid catalog comparisons into the effects ATT(g,t) with the generalized method of moments (GMM); &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a> explains which comparisons are used.&lt;/p>
&lt;p>Treatment adjustment matters when the cohort and its controls differ in characteristics that are related to their outcome changes. Those characteristics enter through the covariate formula &lt;code>xformla&lt;/code>.&lt;/p>
&lt;p>All three methods rely on the same assumptions:&lt;/p>
&lt;ul>
&lt;li>parallel trends, conditional on the covariates in &lt;code>xformla&lt;/code> when it has any (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>);&lt;/li>
&lt;li>no anticipation beyond the periods allowed by &lt;code>anticipation&lt;/code>;&lt;/li>
&lt;li>overlap: in every comparison, the controls include units comparable to the cohort, so the probability of belonging to the cohort stays below one;&lt;/li>
&lt;li>a valid way of handling missing outcomes (&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>);&lt;/li>
&lt;li>covariates that are fixed within each unit or read at a reference date (&lt;a href="#covariates">Covariates&lt;/a>).&lt;/li>
&lt;/ul>
&lt;h2 id="treatment-weighting-ipw">Treatment weighting (IPW)&lt;/h2>
&lt;p>&lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code> uses inverse probability weighting. For each distinct risk set, a logit model of membership in the target cohort, against membership in the control group, uses the design of &lt;code>xformla&lt;/code> and the weights of the requested observation route. Baseline and observation-weighted routes use observed pairs; imputation and augmented routes use the system of reconstructed changes for all study units. Controls are weighted by their fitted odds so that their covariate distribution resembles the cohort&amp;rsquo;s, and the weights within each group are normalized to sum to one before the mean changes are compared. Identical models are fitted once and shared by the comparisons that use them. This chained IPW estimator follows the original chained DiD paper.&lt;/p>
&lt;p>What must be correct is the logit model of cohort membership in the population that the comparison represents, after any adjustment for missing outcomes. With units not yet treated as controls, the control group mixes several cohorts, and its odds can be nonlinear in the covariates even when the odds of each cohort are linear.&lt;/p>
&lt;h2 id="outcome-regression-or">Outcome regression (OR)&lt;/h2>
&lt;p>&lt;code>est_method = &amp;quot;reg&amp;quot;&lt;/code> models untreated outcome changes using weighted least squares on control units. &lt;code>outcome_pooling = &amp;quot;separate&amp;quot;&lt;/code>, the default, gives each comparison block its own coefficients:&lt;/p>
&lt;pre>&lt;code>change(i, e) = alpha(b) + L(e) * z(i)' beta(b) + error for control units i
&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>&lt;code>e = (s, t)&lt;/code> is a date pair and &lt;code>change(i, e)&lt;/code> is the outcome change of unit i from s to t.&lt;/li>
&lt;li>&lt;code>z(i)&lt;/code> holds the covariates of &lt;code>xformla&lt;/code>, without the intercept.&lt;/li>
&lt;li>A block b is a distinct date pair and control group, with its reference covariates and sampling weights. Comparisons that use the same fit reuse it; sharing observations does not force different blocks to have equal coefficients.&lt;/li>
&lt;li>&lt;code>beta(b)&lt;/code> is the block&amp;rsquo;s slope vector. &lt;code>alpha(b)&lt;/code> is its intercept when &lt;code>xformla&lt;/code> has one.&lt;/li>
&lt;li>&lt;code>L(e)&lt;/code> counts steps between the two dates in the stored calendar. It uses their positions, never the difference between their labels.&lt;/li>
&lt;/ul>
&lt;p>The separate specification can also be written as one stacked regression with block-specific covariate slopes and, when requested, intercepts. This is a way to organize the calculation, not a restriction that the coefficients are equal. On eligible complete panels, &lt;code>cdid&lt;/code> reuses common design factorizations across comparisons while keeping their coefficients separate. Inference still combines contributions from the same original unit across all its comparisons. For incomplete panels, fitted treatment models and inference calculations are also reused when their complete fitting inputs agree. This does not pool coefficients across different designs, samples or weights. Temporary storage is bounded by the configured workspace, and the returned influence functions remain aligned with the original study units.&lt;/p>
&lt;p>&lt;code>outcome_pooling = &amp;quot;pooled&amp;quot;&lt;/code> instead fits one slope vector &lt;code>beta&lt;/code> across all blocks, with a local intercept for each block. This is the outcome model used in earlier versions. The fit includes the comparisons reported before treatment as well as those used for treatment effects.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;code>outcome_pooling&lt;/code>&lt;/th>
&lt;th>Outcome-model restriction&lt;/th>
&lt;th>Practical consequence&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>&amp;quot;separate&amp;quot;&lt;/code> (default)&lt;/td>
&lt;td>each block has its own slopes&lt;/td>
&lt;td>covariate effects may differ across comparisons; each control design must support its required predictions&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;pooled&amp;quot;&lt;/code>&lt;/td>
&lt;td>slopes per calendar step are shared across blocks&lt;/td>
&lt;td>pooling may help when individual control samples are small, but the shared-slope restriction must be credible&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>For separate fits, &lt;code>L(e)&lt;/code> is constant within each block. Scaling its covariates by &lt;code>L(e)&lt;/code> therefore only rescales that block&amp;rsquo;s coefficients; it imposes no equality across short and long changes. For pooled fits, the scaling matters: a two-step change has twice the covariate slope of a one-step change. With dates 2001, 2003 and 2004, the successive pairs each have one step and the pair 2001 to 2004 has two.&lt;/p>
&lt;p>For a baseline or observation-weighted comparison of cohort g, OR averages the observed change minus its predicted untreated change over the weighted target cohort. Imputation and augmented correction apply the same treatment adjustment to reconstructed changes. Treatment OR fits no treatment propensity model. Actual-change imputation, when requested, is a separate model.&lt;/p>
&lt;p>Pooling changes the working outcome model, not the parallel-trends assumption. The package never switches a failed separate fit to pooling automatically. Neither choice has a uniform precision advantage.&lt;/p>
&lt;p>The covariate formula determines the fitted model:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;code>xformla&lt;/code>&lt;/th>
&lt;th>Fitted model&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>NULL&lt;/code> or &lt;code>~ 1&lt;/code>&lt;/td>
&lt;td>a local intercept for each block and no slopes&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>~ x1 + x2&lt;/code>&lt;/td>
&lt;td>local intercepts and slopes on &lt;code>L(e) * x1&lt;/code> and &lt;code>L(e) * x2&lt;/code>, separate or pooled as requested&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>~ 0 + x1&lt;/code>&lt;/td>
&lt;td>slopes on &lt;code>L(e) * x1&lt;/code>, separate or pooled as requested, and no intercepts&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>~ 0&lt;/code>&lt;/td>
&lt;td>refused, because &lt;code>xformla&lt;/code> needs at least one column&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Before fitting, the package looks for columns of the design that are exact combinations of other columns. Such a column is removed only when predictions for every relevant control and treated unit stay the same. Near dependencies that cannot be removed at arithmetic roundoff are retained for the separate rank check. An exact control null direction that fails to reconstruct required treated predictions is refused, as is a required regression design that remains rank deficient. Removing a column only changes the parameterization: the fitted predictions are unchanged, and nothing is assumed about the coefficient of the removed column. The original, retained and removed columns are recorded in &lt;code>fit$chained$outcome_design&lt;/code> and the route-specific records of &lt;code>fit$chained$nuisance_diagnostics&lt;/code>. Inspect them with &lt;code>str()&lt;/code> rather than assuming one common &lt;code>basis&lt;/code> subfield.&lt;/p>
&lt;p>Baseline OR with static covariates needs the design on repeat observers. Dated covariates are read at the route&amp;rsquo;s required reference rows. Imputation and augmented correction need their outcome design on every relevant row of the complete unit table.&lt;/p>
&lt;p>This is a difference from &lt;code>did&lt;/code> only when coefficient restrictions or fitting procedures differ. Separate fits, the default, allow comparison-specific coefficients as in &lt;code>did&lt;/code>. Explicit pooling changes that restriction even with the same formula notation. If the complete specification and fitted procedure coincide, OR/DR labels alone cannot explain different estimates. The &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/#why-can-balanced-results-differ-and-which-should-i-use">balanced-panel decision guide&lt;/a> separates this issue from additional NYT moments and explains the conditional tradeoffs.&lt;/p>
&lt;h2 id="doubly-robust-treatment-estimation-dr">Doubly robust treatment estimation (DR)&lt;/h2>
&lt;p>&lt;code>est_method = &amp;quot;dr&amp;quot;&lt;/code>, the default, combines the two models. The chosen control regression predicts each unit&amp;rsquo;s untreated change, and IPW then compares the remaining changes (observed change minus prediction) of the cohort and its weighted controls, with separately normalized weights. For each comparison this gives&lt;/p>
&lt;pre>&lt;code>DR = IPW - (mean design of the cohort - weighted mean design of the controls)' beta(b)
&lt;/code>&lt;/pre>
&lt;p>where the design of a unit is &lt;code>L(e) * z(i)&lt;/code> and pooled fits use the same &lt;code>beta&lt;/code> for every block. The local intercept cancels because both sets of weights sum to one. With an intercept only formula, DR therefore equals IPW exactly, including its influence function.&lt;/p>
&lt;p>&lt;strong>What DR protects.&lt;/strong> Suppose missing outcomes are handled validly and parallel trends, no anticipation, overlap and the regularity conditions hold. Then each comparison is consistent if either the treatment propensity model or the chosen outcome regression is correct. With separate regressions, correctness is required in the relevant comparison. With pooled regressions, it must hold across the blocks sharing coefficients: misspecification in one block can move the shared slope. The guarantee is a large sample property. DR estimates are not unbiased in finite samples, and when both models are wrong they are generally biased, although the errors can cancel in special cases.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Treatment propensity model&lt;/th>
&lt;th>Outcome regression&lt;/th>
&lt;th>IPW&lt;/th>
&lt;th>OR&lt;/th>
&lt;th>DR&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>correct&lt;/td>
&lt;td>correct&lt;/td>
&lt;td>consistent&lt;/td>
&lt;td>consistent&lt;/td>
&lt;td>consistent&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>correct&lt;/td>
&lt;td>misspecified&lt;/td>
&lt;td>consistent&lt;/td>
&lt;td>generally biased&lt;/td>
&lt;td>consistent&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>misspecified&lt;/td>
&lt;td>correct&lt;/td>
&lt;td>generally biased&lt;/td>
&lt;td>consistent&lt;/td>
&lt;td>consistent&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>misspecified&lt;/td>
&lt;td>misspecified&lt;/td>
&lt;td>generally biased&lt;/td>
&lt;td>generally biased&lt;/td>
&lt;td>generally biased&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Every entry assumes that the remaining assumptions hold. In particular, treatment DR does not by itself protect against a wrong model for missing outcomes: if observed changes are reweighted or imputed incorrectly, a correct treatment model does not repair the estimate.&lt;/p>
&lt;h2 id="change-imputation-uses-a-different-regression">Change imputation uses a different regression&lt;/h2>
&lt;p>When missing outcomes are handled by change imputation (&lt;code>selection_est_method = &amp;quot;imputation&amp;quot;&lt;/code>) or by the augmented correction (&lt;code>selection_est_method = &amp;quot;dr&amp;quot;&lt;/code>), the package fits a second regression. It predicts actual changes, including any treatment effects, separately for each cohort and date pair, and averages the predictions over the study population. That model and its pooling argument &lt;code>imputation_pooling&lt;/code> are described in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/#change-imputation">Handling missing outcomes&lt;/a>. The counterfactual OR on this page is a different model, although both use &lt;code>xformla&lt;/code>. &lt;code>outcome_pooling&lt;/code> controls only this counterfactual regression. It is independent of &lt;code>imputation_pooling&lt;/code> for actual changes and &lt;code>selection_pooling&lt;/code> for observation probabilities.&lt;/p>
&lt;p>With change imputation, the treatment methods work on the reconstructed changes: IPW fits the treatment logits with the corresponding weights and no counterfactual regression, OR fits the chosen counterfactual regression to the imputed changes of the controls and no treatment logit, and DR fits both.&lt;/p>
&lt;h2 id="covariates">Covariates&lt;/h2>
&lt;p>&lt;code>xformla&lt;/code> is a one sided formula, such as &lt;code>~ x1 + x2&lt;/code>. Covariates that are constant within each unit (and agree with the unit table when you supply one) are used as unit characteristics.&lt;/p>
&lt;p>Covariates that change within a unit, or a formula that uses the time variable, are read at a reference date. Every comparison used for the effects of cohort g reads each unit&amp;rsquo;s values at the cohort&amp;rsquo;s reference period, and a comparison reported before treatment reads them at its earlier date. A required value that is missing is refused with its unit, date and variable; values are never carried forward. &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/#changing-covariates-and-weights">Changing covariates and weights&lt;/a> gives the complete rules.&lt;/p>
&lt;h2 id="custom-ipw-functions">Custom IPW functions&lt;/h2>
&lt;p>&lt;code>est_method&lt;/code> can also be a function with &lt;code>did&lt;/code>&amp;rsquo;s panel IPW interface, &lt;code>f(y1, y0, D, covariates, i.weights, inffunc = TRUE, ...)&lt;/code>. It must return a list with a finite scalar &lt;code>ATT&lt;/code> and a finite vector or one-column matrix &lt;code>att.inf.func&lt;/code> with one entry per supplied row, in the supplied order. Chained mode calls it on the units of each comparison, with weights that already include the cohort&amp;rsquo;s response rate, and passes any extra arguments given through &lt;code>...&lt;/code>.&lt;/p>
&lt;p>With &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code> and observation weighting, the function must also return &lt;code>log_weight_gradient&lt;/code>, the derivative of &lt;code>ATT&lt;/code> with respect to the logarithm of each weight; requests without it are refused. The function must implement the IPW criterion and its complete influence function correctly. Return-shape and finiteness checks cannot establish that scientific validity. Custom functions are not available with change imputation or the augmented correction, and &lt;code>conditional_did_pretest()&lt;/code> returns a result with status &lt;code>&amp;quot;not_applicable&amp;quot;&lt;/code> for them.&lt;/p>
&lt;h2 id="example-adjust-for-a-covariate-in-a-complete-panel">Example: adjust for a covariate in a complete panel&lt;/h2>
&lt;p>In this simulated design a fixed covariate &lt;code>x&lt;/code> raises both the probability of treatment and the untreated trend, so parallel trends hold only conditional on &lt;code>x&lt;/code>.&lt;/p>
&lt;pre>&lt;code class="language-r">set.seed(20261025)
n_units &amp;lt;- 2000
n_periods &amp;lt;- 6
x &amp;lt;- rnorm(n_units)
first_treat &amp;lt;- ifelse(runif(n_units) &amp;lt; plogis(0.8 * x), 3, 0)
unit_effect &amp;lt;- rnorm(n_units)
cov_panel &amp;lt;- data.frame(
id = rep(seq_len(n_units), each = n_periods),
period = rep(seq_len(n_periods), times = n_units),
first_treat = rep(first_treat, each = n_periods),
x = rep(x, each = n_periods)
)
treated_now &amp;lt;- cov_panel$first_treat &amp;gt; 0 &amp;amp;
cov_panel$period &amp;gt;= cov_panel$first_treat
effect &amp;lt;- ifelse(treated_now,
1 + 0.25 * (cov_panel$period - cov_panel$first_treat), 0)
# Untreated outcomes rise by 0.5 + 0.3 * x per period.
cov_panel$y &amp;lt;- rep(unit_effect, each = n_periods) +
(0.5 + 0.3 * cov_panel$x) * cov_panel$period +
effect +
rnorm(nrow(cov_panel))
fit_unadjusted &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
data = cov_panel, control_group = &amp;quot;nevertreated&amp;quot;,
est_method = &amp;quot;ipw&amp;quot;, bstrap = FALSE, cband = FALSE
)
fit_ipw &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
xformla = ~ x, data = cov_panel, control_group = &amp;quot;nevertreated&amp;quot;,
est_method = &amp;quot;ipw&amp;quot;, bstrap = FALSE, cband = FALSE
)
fit_or &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
xformla = ~ x, data = cov_panel, control_group = &amp;quot;nevertreated&amp;quot;,
est_method = &amp;quot;reg&amp;quot;, outcome_pooling = &amp;quot;pooled&amp;quot;, bstrap = FALSE, cband = FALSE
)
fit_dr &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;period&amp;quot;, idname = &amp;quot;id&amp;quot;, gname = &amp;quot;first_treat&amp;quot;,
xformla = ~ x, data = cov_panel, control_group = &amp;quot;nevertreated&amp;quot;,
est_method = &amp;quot;dr&amp;quot;, outcome_pooling = &amp;quot;pooled&amp;quot;, bstrap = FALSE, cband = FALSE
)
fits &amp;lt;- list(unadjusted = fit_unadjusted, ipw = fit_ipw, or = fit_or, dr = fit_dr)
simple &amp;lt;- lapply(fits, cdid::aggte, type = &amp;quot;simple&amp;quot;)
data.frame(
fit = names(simple),
estimate = vapply(simple, function(a) a$overall.att, numeric(1)),
std.error = vapply(simple, function(a) a$overall.se, numeric(1))
)
&lt;/code>&lt;/pre>
&lt;p>Output:&lt;/p>
&lt;pre>&lt;code class="language-text">fit estimate std.error
unadjusted unadjusted 1.846435 0.05929326
ipw ipw 1.348377 0.06046122
or or 1.324931 0.05151023
dr dr 1.326676 0.05714047
&lt;/code>&lt;/pre>
&lt;p>&lt;code>bstrap = FALSE, cband = FALSE&lt;/code> requests analytical standard errors with pointwise intervals, which keeps the comparison simple; &lt;code>aggte()&lt;/code> inherits these settings.&lt;/p>
&lt;p>&lt;strong>What the design implies.&lt;/strong> The average effect over periods 3 to 6 is 1.375, as in &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>. Cohort 3 has larger values of &lt;code>x&lt;/code> on average, so its untreated outcomes rise faster than those of the units never treated. The unadjusted fit is therefore expected to overstate the effects, by more at later periods. With &lt;code>xformla = ~ x&lt;/code> the treatment logit is correctly specified, because the probability of treatment is a logit in &lt;code>x&lt;/code>, and so is the pooled regression, because the untreated change over a pair of dates is &lt;code>0.5 * L(e) + 0.3 * L(e) * x&lt;/code>: a block intercept plus a shared slope on &lt;code>L(e) * x&lt;/code>. IPW, OR and DR therefore all target the effects, and their estimates will differ somewhat in a finite sample.&lt;/p>
&lt;p>A variation shows what DR protects. Replace &lt;code>0.3 * cov_panel$x&lt;/code> by &lt;code>0.3 * cov_panel$x^2&lt;/code> in the outcome and keep &lt;code>xformla = ~ x&lt;/code>. The outcome regression is then misspecified while the treatment logit stays correct, so the design implies that OR is generally biased while IPW and DR still target the effects.&lt;/p>
&lt;h2 id="where-the-result-records-the-choice">Where the result records the choice&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Location&lt;/th>
&lt;th>Contents&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>fit$DIDparams$est_method&lt;/code>, &lt;code>fit$DIDparams$xformla&lt;/code>&lt;/td>
&lt;td>the requested method and the formula with its environment&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>fit$chained$estimator&lt;/code>&lt;/td>
&lt;td>the estimator label: &lt;code>&amp;quot;chained IPW-GMM&amp;quot;&lt;/code>, &lt;code>&amp;quot;chained outcome regression/control-mean GMM&amp;quot;&lt;/code> or &lt;code>&amp;quot;chained doubly robust GMM&amp;quot;&lt;/code>, with a suffix for change imputation or the augmented correction&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>fit$chained$selection&lt;/code>&lt;/td>
&lt;td>for OR and DR, the outcome and treatment model descriptions, the step convention, the assumptions and model counts such as &lt;code>n_regression_fits&lt;/code>, &lt;code>n_regression_blocks&lt;/code>, &lt;code>n_local_intercepts&lt;/code>, &lt;code>n_shared_slopes&lt;/code> and &lt;code>n_treatment_fits&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>fit$chained$nuisance_diagnostics&lt;/code>&lt;/td>
&lt;td>for OR and DR, the separate or shared slopes, block intercepts, fitted comparisons and step convention&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>fit$chained$outcome_design&lt;/code>&lt;/td>
&lt;td>original, retained and removed design columns&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;code>tidy()&lt;/code> and &lt;code>ggdid()&lt;/code> show the estimator label for OR and DR fits and for the imputation and augmented routes.&lt;/p>
&lt;hr>
&lt;p>&lt;strong>Reading path, step 7 of 22&lt;/strong> · Previous: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a> · Next: &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/p>
&lt;details>
&lt;summary>All steps of the reading path&lt;/summary>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Step&lt;/th>
&lt;th>Page&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/get-started/">Get started&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/from-did/">Moving from did&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/incomplete-panels/">Incomplete panels&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/identification/">Identify effects when the observed units change composition&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/precision/">How to compare precision&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/prepare-data/">Prepare your panel and unit table&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>&lt;strong>Treatment adjustment&lt;/strong> (this page)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/treatment-choice/">Choose IPW, OR or DR in an incomplete panel&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>10&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/sampling-information/">Sampling information for the observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>11&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/observation-models/">Choose an observation model&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>12&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/change-imputation/">Impute actual changes&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>13&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/parallel-trends/">Parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>14&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/pt-all-comparison/">Add PT-all restrictions&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>15&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/gmm/">GMM weighting and covariance regularization&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>16&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/robustness/">Robustness&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>17&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/inference/">Inference&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>18&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>19&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/results/">Results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>20&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/help/troubleshooting/">Diagnose errors and unavailable results&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>21&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/cross-pair-chaining/">Cross-pair chaining and control parallel trends&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>22&lt;/td>
&lt;td>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/examples/short-pretreatment-windows/">Short pre-treatment windows&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p>
&lt;/details></description></item><item><title>When treatment can stop and restart</title><link>https://www.davidbenatia.com/tools/cdid/guide/methods/static-entry-exit/</link><pubDate>Mon, 16 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.davidbenatia.com/tools/cdid/guide/methods/static-entry-exit/</guid><description>&lt;p>A unit may enter treatment, leave it and be treated again. A single first-treatment date cannot describe that history. In &lt;code>cdid&lt;/code> 1.3.0.0, supply the binary treatment indicator through &lt;code>dname&lt;/code> to estimate effects at those changes in treatment status.&lt;/p>
&lt;p>This is a &lt;strong>static model without carryover&lt;/strong>: earlier treatment must have no lingering effect beyond current treatment status. Effects may differ across units and dates. If an earlier treatment episode continues to affect the outcome after it ends, this route does not identify the intended static effects under its maintained assumptions.&lt;/p>
&lt;h2 id="first-treatment-date-or-current-treatment-status">First treatment date or current treatment status?&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;/th>
&lt;th>&lt;code>gname&lt;/code>&lt;/th>
&lt;th>&lt;code>dname&lt;/code>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Typical history&lt;/td>
&lt;td>&lt;code>0 0 1 1 1&lt;/code>&lt;/td>
&lt;td>&lt;code>0 1 1 0 1&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Input column&lt;/td>
&lt;td>First treatment date for each unit; &lt;code>0&lt;/code> if never treated&lt;/td>
&lt;td>Binary treatment status at each date&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Question&lt;/td>
&lt;td>What is the effect at date &lt;code>t&lt;/code> for the cohort first treated at &lt;code>g&lt;/code>?&lt;/td>
&lt;td>What is the effect at a switching date for the units entering or leaving treatment?&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Past treatment&lt;/td>
&lt;td>Effects may evolve with time since adoption&lt;/td>
&lt;td>No lingering effect of past treatment beyond current status&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Aggregate&lt;/td>
&lt;td>&lt;code>aggte(fit, ...)&lt;/code>, including event-study summaries&lt;/td>
&lt;td>&lt;code>fit$aggregate&lt;/code>, a switcher-weighted average&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Use &lt;code>gname&lt;/code> for permanent adoption and cohort effects over time. Use &lt;code>dname&lt;/code> for switching-date effects under the static assumption. Absorbing data can also be supplied through &lt;code>dname&lt;/code>, but that still requests the static model and its targets. Treatment being absorbing does not imply that earlier exposure has no lingering effect. In chained panel mode, the package uses the argument you supply; supplying both is an error. Explicit &lt;code>mode = &amp;quot;ordinary&amp;quot;&lt;/code> delegates to &lt;code>did&lt;/code> and ignores the static arguments.&lt;/p>
&lt;p>Entrants are compared with units that remain untreated at that transition. Exiters are compared with units that remain treated. Each comparison needs the corresponding conditional parallel-trends assumption. An exit estimate is reported as the effect of treatment, &lt;code>Y(1) - Y(0)&lt;/code>, for the units leaving treatment; the raw exit contrast is sign-reversed. Positive entry and exit estimates can therefore both describe a beneficial treatment.&lt;/p>
&lt;h2 id="what-your-input-needs">What your input needs&lt;/h2>
&lt;p>Supply long data with unit ID, date, binary treatment and outcome columns. Keep a row for each unit and study date, including dates where the outcome is &lt;code>NA&lt;/code>:&lt;/p>
&lt;ul>
&lt;li>Treatment must be known at every study date. Missing treatment values or absent unit-date rows are refused; they are never interpreted as untreated.&lt;/li>
&lt;li>The required covariates must be available at each transition&amp;rsquo;s reference date, the preceding stored panel date. Observation and outcome models may use different formulas.&lt;/li>
&lt;li>Outcomes may be missing in consecutive or intermittent patterns. Observed outcome changes need to connect the reference and switching dates for both switchers and their stayers, under the assumptions below.&lt;/li>
&lt;/ul>
&lt;p>Units with zero or one observed outcome contribute no observed change. They remain in the study population and the relevant role counts, observation-model fits, imputed-change evaluations and full-unit inference. They are not additional observed pairs.&lt;/p>
&lt;h2 id="a-runnable-example">A runnable example&lt;/h2>
&lt;p>The example keeps treatment and &lt;code>x&lt;/code> known, then makes some outcomes missing with a probability depending on &lt;code>x&lt;/code>. The conditional augmented fit addresses that dependence. The no-equation fit is a comparator: this data-generating process does not establish its stronger baseline missingness assumption.&lt;/p>
&lt;pre>&lt;code class="language-r">library(cdid)
set.seed(20261106)
n_units &amp;lt;- 400
n_dates &amp;lt;- 4
unit_id &amp;lt;- seq_len(n_units)
x_unit &amp;lt;- rnorm(n_units)
alpha_unit &amp;lt;- rnorm(n_units, sd = 0.5)
# Assign 5 binary treatment paths, including stayers in both treatment states
d_paths &amp;lt;- rbind(
c(0L, 0L, 0L, 0L), # never treated stayer
c(0L, 1L, 1L, 0L), # entry at t=2, stayer at t=3, exit at t=4
c(1L, 1L, 0L, 1L), # stayer at t=2, exit at t=3, re-entry at t=4
c(1L, 0L, 0L, 1L), # exit at t=2, stayer at t=3, re-entry at t=4
c(1L, 1L, 1L, 1L) # treated stayer, including at t=4
)
path_id &amp;lt;- sample.int(nrow(d_paths), size = n_units, replace = TRUE)
panel_static &amp;lt;- data.frame(
id = rep(unit_id, each = n_dates),
time = rep(seq_len(n_dates), times = n_units),
x = rep(x_unit, each = n_dates),
d = as.integer(t(d_paths[path_id, ]))
)
# Static no-carryover outcome Y_{it}(d_t) with true effect tau = 1.5 * d_{it}
y_latent &amp;lt;- rep(alpha_unit, each = n_dates) +
(0.3 + 0.2 * panel_static$x) * panel_static$time +
1.5 * panel_static$d +
rnorm(nrow(panel_static), sd = 0.4)
# Missing outcomes depending on x (complete binary d and x are retained on all rows)
obs_prob &amp;lt;- plogis(0.8 + 0.4 * panel_static$x)
panel_static$y &amp;lt;- ifelse(runif(nrow(panel_static)) &amp;lt; obs_prob, y_latent, NA_real_)
# 1. Baseline comparator (no observation-probability or imputation equation)
# Observation depends on x here, so the baseline sufficient assumption is not
# established by this DGP. The conditional correction below addresses that dependence.
fit_base &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, dname = &amp;quot;d&amp;quot;,
xformla = ~ x, data = panel_static,
est_method = &amp;quot;dr&amp;quot;, selection = &amp;quot;none&amp;quot;,
bstrap = FALSE, cband = FALSE
)
summary(fit_base)
cdid::tidy(fit_base)
cdid::glance(fit_base)
fit_base$aggregate
fit_base$references
# 2. Conditional-MTAR augmented correction with treatment DR, IPW, or OR
fit_aug_dr &amp;lt;- cdid::att_gt(
yname = &amp;quot;y&amp;quot;, tname = &amp;quot;time&amp;quot;, idname = &amp;quot;id&amp;quot;, dname = &amp;quot;d&amp;quot;,
xformla = ~ x, data = panel_static,
est_method = &amp;quot;dr&amp;quot;,
selection = &amp;quot;conditional_mtar&amp;quot;,
selection_est_method = &amp;quot;dr&amp;quot;,
selection_model = &amp;quot;pair_logit&amp;quot;,
selection_pooling = &amp;quot;within_group&amp;quot;,
imputation_pooling = &amp;quot;within_group&amp;quot;,
imputation_scale = &amp;quot;per_period&amp;quot;,
outcome_pooling = &amp;quot;separate&amp;quot;,
switchers = &amp;quot;both&amp;quot;,
bstrap = FALSE, cband = FALSE
)
summary(fit_aug_dr)
&lt;/code>&lt;/pre>
&lt;p>The code above was run with &lt;code>cdid&lt;/code> 1.3.0.0, R 4.5.2, &lt;code>did&lt;/code> 2.5.1 and &lt;code>DRDID&lt;/code> 1.4.0, using the stated seed. The augmented fit returns the following rounded results. These are one simulated dataset, not a coverage study.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Date&lt;/th>
&lt;th>Direction&lt;/th>
&lt;th style="text-align:right">Estimate&lt;/th>
&lt;th style="text-align:right">Standard error&lt;/th>
&lt;th style="text-align:right">95% lower&lt;/th>
&lt;th style="text-align:right">95% upper&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>entry&lt;/td>
&lt;td style="text-align:right">1.4398&lt;/td>
&lt;td style="text-align:right">0.1099&lt;/td>
&lt;td style="text-align:right">1.2244&lt;/td>
&lt;td style="text-align:right">1.6552&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>exit&lt;/td>
&lt;td style="text-align:right">1.5741&lt;/td>
&lt;td style="text-align:right">0.0982&lt;/td>
&lt;td style="text-align:right">1.3817&lt;/td>
&lt;td style="text-align:right">1.7665&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>exit&lt;/td>
&lt;td style="text-align:right">1.5739&lt;/td>
&lt;td style="text-align:right">0.0908&lt;/td>
&lt;td style="text-align:right">1.3959&lt;/td>
&lt;td style="text-align:right">1.7518&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>entry&lt;/td>
&lt;td style="text-align:right">1.6457&lt;/td>
&lt;td style="text-align:right">0.0821&lt;/td>
&lt;td style="text-align:right">1.4847&lt;/td>
&lt;td style="text-align:right">1.8067&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>exit&lt;/td>
&lt;td style="text-align:right">1.5060&lt;/td>
&lt;td style="text-align:right">0.0943&lt;/td>
&lt;td style="text-align:right">1.3211&lt;/td>
&lt;td style="text-align:right">1.6908&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The switcher-weighted estimate is &lt;strong>1.5620&lt;/strong>, with standard error &lt;strong>0.0454&lt;/strong> and 95% interval &lt;strong>[1.4730, 1.6510]&lt;/strong>.&lt;/p>
&lt;pre>&lt;code class="language-r">cdid::ggdid(fit_aug_dr)
&lt;/code>&lt;/pre>
&lt;p>
&lt;figure >
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img src="https://www.davidbenatia.com/tools/cdid/assets/r/docs/outputs/static-entry-exit.png" alt="Entry and exit treatment effects with 95% pointwise intervals" loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/p>
&lt;h2 id="read-the-result">Read the result&lt;/h2>
&lt;p>&lt;code>tidy(fit_aug_dr)&lt;/code> gives one row per requested entry or exit date, with the estimate, standard error and availability information. &lt;code>summary(fit_aug_dr)&lt;/code> displays these effects and their references. The switcher-weighted average is &lt;code>fit_aug_dr$aggregate&lt;/code>; use that field rather than &lt;code>aggte()&lt;/code>, whose targets are cohort effects.&lt;/p>
&lt;p>With the default &lt;code>switchers = &amp;quot;both&amp;quot;&lt;/code>, the fit includes entry and exit cells with switchers in the study population. Use &lt;code>switchers = &amp;quot;entry&amp;quot;&lt;/code> or &lt;code>&amp;quot;exit&amp;quot;&lt;/code> to choose a direction. An explicit &lt;code>switch_times&lt;/code> retains the requested cells even when they cannot be estimated. An unavailable effect is reported as &lt;code>NA&lt;/code> with a reason, never silently removed. If any declared cell is unavailable, the declared aggregate is unavailable too, rather than reweighted over the remaining cells.&lt;/p>
&lt;h2 id="choose-the-two-adjustments-separately">Choose the two adjustments separately&lt;/h2>
&lt;p>&lt;code>est_method&lt;/code> selects treatment IPW (&lt;code>&amp;quot;ipw&amp;quot;&lt;/code>), outcome regression (&lt;code>&amp;quot;reg&amp;quot;&lt;/code>) or treatment DR (&lt;code>&amp;quot;dr&amp;quot;&lt;/code>). This choice makes switchers comparable with stayers. It is separate from how missing outcomes are handled:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Missing-outcome approach&lt;/th>
&lt;th>Arguments&lt;/th>
&lt;th>What it adds&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>No observation equation&lt;/td>
&lt;td>&lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>&lt;/td>
&lt;td>Normalized observed-pair changes, under the baseline representativeness assumptions&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Observation weighting&lt;/td>
&lt;td>&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, &lt;code>selection_est_method = &amp;quot;ipw&amp;quot;&lt;/code>&lt;/td>
&lt;td>A model for the probability of observing both outcomes&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Change imputation&lt;/td>
&lt;td>&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, &lt;code>selection_est_method = &amp;quot;imputation&amp;quot;&lt;/code>&lt;/td>
&lt;td>A regression predicting actual outcome changes&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Augmented correction&lt;/td>
&lt;td>&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, &lt;code>selection_est_method = &amp;quot;dr&amp;quot;&lt;/code>&lt;/td>
&lt;td>Observation weighting combined with change imputation&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>All three treatment methods support these four missing-outcome approaches. The two meanings of DR remain distinct: augmenting missing-outcome correction does not make treatment IPW or OR doubly robust at the treatment layer.&lt;/p>
&lt;p>Set &lt;code>control = list(keep_nuisance = TRUE)&lt;/code> to keep compact coefficient
reports for the fits used in estimation. Use &lt;code>nuisance_models(fit)&lt;/code> to
list the active models and
&lt;code>nuisance_models(fit, &amp;quot;outcome&amp;quot;, block = 1)&lt;/code> to inspect a particular
stayer regression. The report shows the fitted equation, populations,
coefficients and standard errors. Reconstructed outcomes include the
uncertainty of their upstream adjustment. Capture is off by default.&lt;/p>
&lt;p>For observation probabilities, &lt;code>pair_logit&lt;/code> models the joint event directly. &lt;code>independent_period_logit&lt;/code> multiplies the two date probabilities and needs the additional conditional-independence assumption. Pooling slopes is a separate modeling choice. &lt;code>selection_pooling&lt;/code> and &lt;code>imputation_pooling&lt;/code> accept &lt;code>&amp;quot;separate&amp;quot;&lt;/code>, &lt;code>&amp;quot;within_group&amp;quot;&lt;/code> or &lt;code>&amp;quot;pooled&amp;quot;&lt;/code>; &lt;code>outcome_pooling&lt;/code> controls the stayer outcome regressions. The &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">options reference&lt;/a> and details below give the precise meanings.&lt;/p>
&lt;h2 id="how-chaining-handles-the-gaps">How chaining handles the gaps&lt;/h2>
&lt;p>For each transition, &lt;code>cdid&lt;/code> fixes the switcher and stayer populations before examining observed outcomes. Within each population it uses all date pairs with observed changes. Different units can connect different dates: a unit need not have outcomes at both dates of the final transition if other valid comparisons connect those dates.&lt;/p>
&lt;p>For an entry at date 3, the following population values illustrate the calculation. These are analytical values, not output from the simulated example:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Fixed population for the date-3 transition&lt;/th>
&lt;th style="text-align:right">Mean change, 1 to 2&lt;/th>
&lt;th style="text-align:right">Mean change, 1 to 3&lt;/th>
&lt;th style="text-align:right">Recovered change, 2 to 3&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Switchers&lt;/td>
&lt;td style="text-align:right">2&lt;/td>
&lt;td style="text-align:right">5&lt;/td>
&lt;td style="text-align:right">&lt;code>5 - 2 = 3&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Stayers&lt;/td>
&lt;td style="text-align:right">1&lt;/td>
&lt;td style="text-align:right">2&lt;/td>
&lt;td style="text-align:right">&lt;code>2 - 1 = 1&lt;/code>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The entry contrast is &lt;code>3 - 1 = 2&lt;/code>. Earlier changes differ between the two populations, but each cancels within its own chain. This identity does not require parallel trends before the reference date. The observed comparisons must still represent the same fixed populations, with the required missingness adjustment, and the transition needs its maintained parallel-trends assumption.&lt;/p>
&lt;p>The package combines those comparisons by GMM when outcomes are missing or a &lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code> adjustment is requested, retaining all supported pairs and connected components. On a complete panel (&lt;code>all(O == 1)&lt;/code>) with &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>, all-pair chaining reduces algebraically to the adjacent change between &lt;code>t - 1&lt;/code> and &lt;code>t&lt;/code>, so &lt;code>att_gt(dname = ...)&lt;/code> runs the direct complete-data baseline kernel without executing all-pair GMM. Graph connectivity checks whether the dates can be connected; it does not establish parallel trends, validate a missingness model or guarantee a successful nuisance fit. Those checks and assumptions remain separate. A disconnected switcher or stayer graph gives an unavailable target with a specific reason.&lt;/p>
&lt;h2 id="assumptions-behind-the-missing-outcome-choices">Assumptions behind the missing-outcome choices&lt;/h2>
&lt;p>Without a missing-outcome equation, a sufficient condition is that, within each fixed switcher or stayer population, pair observation does not change the reference-covariate composition and observed pairs are representative of conditional mean outcome changes. These are restrictions on population expectations, not equality of realized sample means. Without covariates, the condition reduces to representativeness of mean changes.&lt;/p>
&lt;p>Conditional correction permits observation to depend on covariates, subject to the relevant conditional mean-representativeness, overlap and model conditions. Observation weighting needs a valid probability model; imputation needs a valid actual-change model; the augmented route can use either valid arm. Treatment adjustment has its own conditions. Shared coefficients must be valid throughout their pooling blocks. All active fitted models must satisfy the package&amp;rsquo;s numerical and support requirements, even when a robustness argument permits one model to be misspecified.&lt;/p>
&lt;p>With direct-pair observation IPW, &lt;code>selection_universe = &amp;quot;A&amp;quot;&lt;/code> fits the
probability on units observed at least twice, and &lt;code>&amp;quot;B&amp;quot;&lt;/code> uses units observed at
least once. It fits within each switcher or same-prior-state stayer role.
Provide &lt;code>selection_justification&lt;/code> for transport within those roles. With
&lt;code>selection_rho = NULL&lt;/code>, it asserts that the fitting subset represents the
role&amp;rsquo;s reference-covariate distribution. A named ratio column in &lt;code>data&lt;/code>
provides fixed known values of the fitting-subset density divided by the
full-role density. Values must be constant within each fitting unit and
valid in all roles in which they are used. Selection covariates only need
to be available on the fitting subset. Treatment covariates still need
to cover the estimation population.&lt;/p>
&lt;p>For these normalized weighted means and covariances, each role&amp;rsquo;s overall
fitting rate cancels. Inverse weights retain the known density ratio and
the fitted pair probability, whose floor is applied before transport.
Independent-period logits, imputation and augmentation use the full
study-unit table.&lt;/p>
&lt;p>Inference uses full original-unit contributions, including estimated nuisance models and random aggregation shares. Clustered inference requires many independent clusters; no finite-sample coverage guarantee is implied. The precise clipping, graph, pooling and inference rules follow below.&lt;/p>
&lt;details>
&lt;summary>Mathematical definitions and detailed option behavior&lt;/summary>
&lt;h2 id="routing-dname-versus-gname">Routing: &lt;code>dname&lt;/code> versus &lt;code>gname&lt;/code>&lt;/h2>
&lt;p>In chained panel mode, &lt;code>att_gt()&lt;/code> chooses between the cohort and static transition routes from the treatment column argument you supply. Explicit &lt;code>mode = &amp;quot;ordinary&amp;quot;&lt;/code> delegates to &lt;code>did&lt;/code> before evaluating static arguments:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Argument supplied&lt;/th>
&lt;th>Route selected&lt;/th>
&lt;th>Returned class&lt;/th>
&lt;th>Aggregation&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>gname&lt;/code> (&lt;code>dname = NULL&lt;/code>, default)&lt;/td>
&lt;td>Absorbing cohort &lt;code>ATT(g, t)&lt;/code> (staggered adoption)&lt;/td>
&lt;td>&lt;code>cdid_MP&lt;/code> (or &lt;code>did&lt;/code>&amp;rsquo;s &lt;code>MP&lt;/code> in ordinary mode)&lt;/td>
&lt;td>&lt;code>cdid::aggte()&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>dname&lt;/code> (&lt;code>gname&lt;/code> omitted)&lt;/td>
&lt;td>Static no-carryover entry, exit and re-entry transitions&lt;/td>
&lt;td>&lt;code>cdid_static_att_gt&lt;/code>&lt;/td>
&lt;td>Stored in &lt;code>fit$aggregate&lt;/code> (&lt;code>aggte()&lt;/code> refuses &lt;code>cdid_static_att_gt&lt;/code>)&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;ul>
&lt;li>&lt;strong>In chained panel mode, &lt;code>dname&lt;/code> always selects the static route&lt;/strong>, even if the binary column in &lt;code>data&lt;/code> happens to be an absorbing staggered adoption indicator.&lt;/li>
&lt;li>&lt;strong>&lt;code>gname&lt;/code> retains the cohort route&lt;/strong> unchanged.&lt;/li>
&lt;li>In chained panel mode, specifying both &lt;code>gname&lt;/code> and &lt;code>dname&lt;/code> is refused before data inspection.&lt;/li>
&lt;li>The static &lt;code>dname&lt;/code> route runs in chained panel mode (&lt;code>panel = TRUE&lt;/code>, &lt;code>mode = NULL&lt;/code> or &lt;code>mode = &amp;quot;chained&amp;quot;&lt;/code>, &lt;code>allow_unbalanced_panel = NULL&lt;/code> or &lt;code>TRUE&lt;/code>). Cohort-only options (&lt;code>frame&lt;/code>, &lt;code>weightsname&lt;/code>, &lt;code>fix_weights&lt;/code>, &lt;code>control_group&lt;/code>, non-zero &lt;code>anticipation&lt;/code>, &lt;code>base_period = &amp;quot;universal&amp;quot;&lt;/code>, &lt;code>pt_assumption = &amp;quot;all&amp;quot;&lt;/code>, &lt;code>pt_start&lt;/code>, and custom function &lt;code>est_method&lt;/code> callbacks) are inapplicable and refused with diagnostic errors.&lt;/li>
&lt;/ul>
&lt;h2 id="causal-benchmark-static-potential-outcomes-without-carryover">Causal benchmark: static potential outcomes without carryover&lt;/h2>
&lt;p>The static &lt;code>dname&lt;/code> route relies on a &lt;strong>no-carryover (no treatment-history effects)&lt;/strong> potential-outcomes benchmark. At every panel date $t \in {t_1, \dots, t_T}$, unit $i$&amp;rsquo;s potential outcome depends only on its current binary treatment status $d_t \in {0, 1}$:
$$Y_{it}(d_1, \dots, d_t) = Y_{it}(d_t) \in {Y_{it}(0), Y_{it}(1)}.$$&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Entry, exit and re-entry are permitted:&lt;/strong> A unit&amp;rsquo;s observed binary treatment sequence $D_i = (D_{i1}, \dots, D_{iT}) \in {0, 1}^T$ may switch from $0$ to $1$ (entry), from $1$ to $0$ (exit), and back again (re-entry) across dates.&lt;/li>
&lt;li>&lt;strong>Lasting dynamic effects from past treatment are excluded:&lt;/strong> Past treatment status $D_{i,1:t-1}$ must not directly shift current outcomes $Y_{it}(0)$ or $Y_{it}(1)$. If earlier treatment has lasting dynamic or carryover effects in later periods, units with $D_{i,t-1} = 1$ (or units re-entering after earlier treatment episodes) can experience ongoing treatment-history trends between $t - 1$ and $t$, violating the static identification benchmark.&lt;/li>
&lt;/ul>
&lt;h3 id="transition-cells-and-sign-oriented-treatment-effects">Transition cells and sign-oriented treatment effects&lt;/h3>
&lt;p>Each transition cell $c = (t, d)$ is indexed by a transition date $t \in {t_2, \dots, t_T}$ (for $t=t_j$, anchored at the preceding stored date $t_{\text{prev}}=t_{j-1}$; below, $t-1$ denotes that preceding date, not subtraction of one calendar unit) and a prior treatment state $d = D_{i,t-1} \in {0, 1}$:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Risk set ($R_c$):&lt;/strong> Units with prior treatment state $D_{i,t-1} = d$, of size $n_{\text{risk}, c}$.&lt;/li>
&lt;li>&lt;strong>Switchers ($G_c$):&lt;/strong> Units that change treatment status at date $t$, $G_c = {i : D_{i,t-1} = d,; D_{it} = 1 - d}$, of size $n_{\text{switchers}, c}$.
&lt;ul>
&lt;li>When $d = 0$, $G_c$ is the &lt;strong>entry&lt;/strong> group ($0 \to 1$).&lt;/li>
&lt;li>When $d = 1$, $G_c$ is the &lt;strong>exit&lt;/strong> group ($1 \to 0$).&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>&lt;strong>Stayers ($C_c$):&lt;/strong> Units with the same prior state $d$ that keep status $d$ at date $t$, $C_c = {i : D_{i,t-1} = d,; D_{it} = d}$, of size $n_{\text{stayers}, c}$. Same-prior-state stayers serve as the control group for cell $c$.&lt;/li>
&lt;/ul>
&lt;p>Let $\theta_c$ denote the raw switcher-versus-stayer difference-in-differences contrast between $t - 1$ and $t$:
$$\theta_c = E[Y_{it} - Y_{i,t-1} \mid i \in G_c] - E[Y_{it}(d) - Y_{i,t-1}(d) \mid i \in G_c].$$
Under no carryover ($Y_{is} = Y_{is}(D_{is})$) and conditional parallel trends of status-$d$ potential outcome changes between $t - 1$ and $t$ within $R_c$, multiplying $\theta_c$ by the transition sign $\sigma_c = 1 - 2d \in {+1, -1}$ yields the sign-oriented switch-time treatment effect:
$$\tau_c = \sigma_c \theta_c = E[Y_{it}(1) - Y_{it}(0) \mid i \in G_c].$$
For entry cells ($d = 0$, $\sigma_c = +1$), $\theta_c = E[Y_{it}(1) - Y_{it}(0) \mid i \in G_c]$ directly. For exit cells ($d = 1$, $\sigma_c = -1$), switchers move from $Y_{i,t-1}(1)$ to $Y_{it}(0)$ while stayers remain at status $1$, so $\theta_c = -E[Y_{it}(1) - Y_{it}(0) \mid i \in G_c]$ and multiplying by $\sigma_c = -1$ orients $\tau_c$ as the effect of treatment ($1$ versus $0$) on the exiting switchers at date $t$. Both &lt;code>estimate&lt;/code> (&lt;code>att&lt;/code>) and &lt;code>theta.hat&lt;/code> (&lt;code>theta_hat&lt;/code>) are reported in &lt;code>cdid_static_att_gt&lt;/code> and &lt;code>tidy()&lt;/code>.&lt;/p>
&lt;h3 id="selecting-transition-directions-and-dates">Selecting transition directions and dates&lt;/h3>
&lt;p>Two arguments define the declared target set $A$:&lt;/p>
&lt;ul>
&lt;li>&lt;code>switchers&lt;/code>: &lt;code>&amp;quot;both&amp;quot;&lt;/code> (default, includes both entry $0 \to 1$ and exit $1 \to 0$ transitions), &lt;code>&amp;quot;entry&amp;quot;&lt;/code> ($d = 0$ only), or &lt;code>&amp;quot;exit&amp;quot;&lt;/code> ($d = 1$ only).&lt;/li>
&lt;li>&lt;code>switch_times&lt;/code>: &lt;code>NULL&lt;/code> (default) or a vector of panel transition dates in ${t_2, \dots, t_T}$.
&lt;ul>
&lt;li>When &lt;code>switch_times = NULL&lt;/code>, &lt;code>att_gt()&lt;/code> automatically includes every candidate transition cell in the requested direction(s) that has at least one switcher ($n_{\text{switchers}, c} \ge 1$) in the study population.&lt;/li>
&lt;li>When &lt;code>switch_times&lt;/code> is supplied explicitly, every requested direction at each requested date is retained in $A$. If an explicitly requested cell has zero switchers ($n_{\text{switchers}, c} = 0$), it is kept in the result with &lt;code>available = FALSE&lt;/code> and &lt;code>support_status = &amp;quot;empty_switchers&amp;quot;&lt;/code> rather than silently dropped.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;h2 id="panel-data-missing-outcomes-and-role-pair-graphs">Panel data, missing outcomes and role-pair graphs&lt;/h2>
&lt;h3 id="complete-binary-treatment-histories-and-reference-covariates">Complete binary treatment histories and reference covariates&lt;/h3>
&lt;p>Every study unit $i \in {1, \dots, n}$ in &lt;code>data&lt;/code> must have:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>A complete, known binary treatment path&lt;/strong> $D_i = (D_{i1}, \dots, D_{iT}) \in {0, 1}^T$ across all $T$ panel dates. Missing or absent unit-date treatment indicators are refused (&lt;code>cdid_static_missing_treatment_error&lt;/code>).&lt;/li>
&lt;li>&lt;strong>Complete required reference covariates&lt;/strong> (&lt;code>xformla&lt;/code> and, when active, &lt;code>selection_xformla&lt;/code>). Covariates are unit-constant or read at the transition cell&amp;rsquo;s reference date $t - 1$.&lt;/li>
&lt;/ol>
&lt;h3 id="general-missing-outcomes-and-retained-zerosingle-outcome-units">General missing outcomes and retained zero/single-outcome units&lt;/h3>
&lt;p>Outcome values $Y_{it}$ may be missing (&lt;code>NA&lt;/code>) in general patterns across dates (including non-monotone gaps, attrition, and re-entry into observation), provided the active missing-outcome, parallel-trends, overlap, and role-graph connectivity assumptions hold.&lt;/p>
&lt;p>Every unit in &lt;code>data&lt;/code> belongs to the study population of size $n$:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Unit outcome count&lt;/th>
&lt;th>Role in static estimation and inference&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Repeat-outcome units ($\sum_t O_{it} \ge 2$, &lt;code>n_repeat_outcome_units&lt;/code>)&lt;/td>
&lt;td>Supply observed outcome changes $\Delta Y_{i,s,u} = Y_{iu} - Y_{is}$ on pairs $(s, u)$ with $O_{is} O_{iu} = 1$, plus full-population role membership, covariates, and influence-function rows.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Single-outcome units ($\sum_t O_{it} = 1$, &lt;code>n_single_outcome_units&lt;/code>)&lt;/td>
&lt;td>Supply no observed pair differences, but are retained in the study population count $n$, role counts (&lt;code>n_risk&lt;/code>, &lt;code>n_switchers&lt;/code>, &lt;code>n_stayers&lt;/code>), active observation-probability fits and evaluation of imputed changes (but no observed-pair regression scores), and the $n$-row original-unit influence functions.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Zero-outcome units ($\sum_t O_{it} = 0$, &lt;code>n_zero_outcome_units&lt;/code>)&lt;/td>
&lt;td>Retained in the study population, role counts, active observation-probability fits and evaluation of imputed changes (but no observed-pair regression scores), and the $n$-row original-unit influence functions on the same basis as single-outcome units.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="all-positive-count-role-graphs-and-endpoint-connectivity">All-positive-count role graphs and endpoint connectivity&lt;/h3>
&lt;p>For each required cell $c = (t, d)$ and role $a \in {G, C}$ (switchers $G_c$ and stayers $C_c$), &lt;code>cdid&lt;/code> inspects all $\binom{T}{2}$ ordered date pairs $(s, u)$ with $s &amp;lt; u$ and retains &lt;strong>every date pair with at least one observed unit in that role&lt;/strong> ($n_{\text{observed, role}} \ge 1$). All connected components ($K_c^a \ge 1$), long gaps, earlier bridges, and multiple paths are retained without pruning disconnected components or selecting a single path.&lt;/p>
&lt;p>A declared target cell $c = (t, d)$ passes the graph-support check (&lt;code>support_status = &amp;quot;ok&amp;quot;&lt;/code>) if and only if:&lt;/p>
&lt;ol>
&lt;li>$n_{\text{switchers}, c} \ge 1$ (otherwise &lt;code>support_status = &amp;quot;empty_switchers&amp;quot;&lt;/code>),&lt;/li>
&lt;li>$n_{\text{stayers}, c} \ge 1$ (otherwise &lt;code>support_status = &amp;quot;empty_stayers&amp;quot;&lt;/code>),&lt;/li>
&lt;li>the retained positive-count pair graph for switchers $(c, G)$ connects the baseline date $t - 1$ and the transition date $t$ (otherwise &lt;code>support_status = &amp;quot;disconnected_switcher_graph&amp;quot;&lt;/code>), and&lt;/li>
&lt;li>the retained positive-count pair graph for stayers $(c, C)$ connects $t - 1$ and $t$ (otherwise &lt;code>support_status = &amp;quot;disconnected_stayer_graph&amp;quot;&lt;/code>).&lt;/li>
&lt;/ol>
&lt;p>Passing this support check does not replace the checks on active nuisance fits and the numerical system. Those must also succeed before an estimate can be reported.&lt;/p>
&lt;p>When multiple paths connect the dates in a role graph ($m_{\text{edges}} - (n_{\text{active dates}} - K_c^a) &amp;gt; 0$), the overidentified within-role pair equations are combined jointly with the transition equations by GMM using &lt;code>gmm_weighting = &amp;quot;optimal&amp;quot;&lt;/code> (alias &lt;code>&amp;quot;two_step&amp;quot;&lt;/code>, default, with &lt;code>gmm_covariance = &amp;quot;tikhonov&amp;quot;&lt;/code> ridge handling when singular or near-singular) or &lt;code>gmm_weighting = &amp;quot;identity&amp;quot;&lt;/code>.&lt;/p>
&lt;h2 id="treatment-and-missing-outcome-adjustments">Treatment and missing-outcome adjustments&lt;/h2>
&lt;p>The static route separates the &lt;strong>switch-time treatment adjustment&lt;/strong> (&lt;code>est_method&lt;/code>) from the &lt;strong>missing-outcome adjustment&lt;/strong> (&lt;code>selection&lt;/code> and &lt;code>selection_est_method&lt;/code>). All built-in combinations are supported:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;code>selection&lt;/code>&lt;/th>
&lt;th>&lt;code>selection_est_method&lt;/code>&lt;/th>
&lt;th>Route name (&lt;code>request$route&lt;/code>)&lt;/th>
&lt;th>&lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code>&lt;/th>
&lt;th>&lt;code>est_method = &amp;quot;reg&amp;quot;&lt;/code>&lt;/th>
&lt;th>&lt;code>est_method = &amp;quot;dr&amp;quot;&lt;/code>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>&amp;quot;none&amp;quot;&lt;/code> (default)&lt;/td>
&lt;td>&lt;code>&amp;quot;ipw&amp;quot;&lt;/code> (required)&lt;/td>
&lt;td>&lt;code>&amp;quot;baseline&amp;quot;&lt;/code>&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;conditional_mtar&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;ipw&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;weighting&amp;quot;&lt;/code>&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;conditional_mtar&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;imputation&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;imputation&amp;quot;&lt;/code>&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;conditional_mtar&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;dr&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;augmented&amp;quot;&lt;/code>&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;td>supported&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="1-baseline--no-equation-route-selection--none">1. Baseline / no-equation route (&lt;code>selection = &amp;quot;none&amp;quot;&lt;/code>)&lt;/h3>
&lt;p>With &lt;code>selection = &amp;quot;none&amp;quot;&lt;/code> (which requires &lt;code>selection_est_method = &amp;quot;ipw&amp;quot;&lt;/code>), no observation-probability logit or actual-change imputation model is fitted. When all outcomes are observed (&lt;code>all(O == 1)&lt;/code>), &lt;code>att_gt(dname = ...)&lt;/code> estimates the switcher effects directly from adjacent changes $\Delta Y_{i,t-1,t} = Y_{it} - Y_{i,t-1}$ and records &lt;code>diagnostics$backend_status = &amp;quot;accepted_static_complete_fit_integration&amp;quot;&lt;/code> and &lt;code>diagnostics$gmm_executed = FALSE&lt;/code>. When outcomes are missing, it uses normalized means of observed pair changes within each fixed switcher or stayer population and combines them by chained GMM (&lt;code>static_missing_fit&lt;/code>, &lt;code>diagnostics$backend_status = &amp;quot;accepted_static_missing_fit_integration&amp;quot;&lt;/code>, &lt;code>diagnostics$gmm_executed = TRUE&lt;/code>), with the active treatment adjustment.&lt;/p>
&lt;p>The accepted sufficient baseline assumption has two parts for every retained pair and role population: the pair-observation probability is constant across the reference covariates within that population, and observed pairs are representative of its mean outcome change conditional on those covariates. Thus the observed pairs preserve both the role population&amp;rsquo;s covariate composition and its conditional mean changes. With no covariates, this reduces to representativeness of the mean change. Conditional mean representativeness alone, when observation varies with the covariates, does not establish this baseline route; use an appropriate conditional correction below. These are population restrictions, not equality of realized sample means.&lt;/p>
&lt;h3 id="2-conditional-mtar-observation-weighting-selection--conditional_mtar-selection_est_method--ipw">2. Conditional-MTAR observation weighting (&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, &lt;code>selection_est_method = &amp;quot;ipw&amp;quot;&lt;/code>)&lt;/h3>
&lt;p>When observation on pair $k = (s, u)$ depends on covariates, &lt;code>selection_est_method = &amp;quot;ipw&amp;quot;&lt;/code> fits an observation-probability model $\hat{q}&lt;em>{c,a,k}(W_i)$ using &lt;code>selection_xformla&lt;/code> (which inherits &lt;code>xformla&lt;/code> when &lt;code>NULL&lt;/code>) over all units in role $(c, a)$ (including units with zero or one observed outcome) and weights observed pair changes by $1 / \max(\hat{q}&lt;/em>{c,a,k}(W_i), 10^{-6})$:&lt;/p>
&lt;ul>
&lt;li>&lt;code>selection_model = &amp;quot;pair_logit&amp;quot;&lt;/code> (default): fits a binary logit directly for the joint event $S_{ik} = O_{is} O_{iu} = 1$ on each active pair $k$ and role $(c, a)$. Observation at $s$ and $u$ may be dependent given $(c, a, W_i)$.&lt;/li>
&lt;li>&lt;code>selection_model = &amp;quot;independent_period_logit&amp;quot;&lt;/code>: fits binary logits for period observation $O_{it} = 1$ at active dates and forms the pair probability as the product $\hat{q}&lt;em>{c,a,k}(W_i) = \hat{p}&lt;/em>{c,a,s}(W_i)\hat{p}&lt;em>{c,a,u}(W_i)$, floored at $10^{-6}$ on the final product. This additionally requires conditional independence of $O&lt;/em>{is}$ and $O_{iu}$ given $(c, a, W_i)$.&lt;/li>
&lt;/ul>
&lt;h3 id="3-conditional-mtar-actual-change-imputation-selection--conditional_mtar-selection_est_method--imputation">3. Conditional-MTAR actual-change imputation (&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, &lt;code>selection_est_method = &amp;quot;imputation&amp;quot;&lt;/code>)&lt;/h3>
&lt;p>With &lt;code>selection_est_method = &amp;quot;imputation&amp;quot;&lt;/code>, &lt;code>cdid&lt;/code> fits a linear weighted least squares (WLS) regression of observed pair changes $\Delta Y_{ik}$ on the &lt;code>xformla&lt;/code> design among observed units ($S_{ik} = 1$) in role $(c, a)$:
$$\hat{j}&lt;em>{c,a,k}(X_i) = \hat{\alpha}&lt;/em>{c,a,k} + d_{k}(X_i)'\hat{\beta}&lt;em>{r(c,a,k)},$$
and evaluates the predicted change $\hat{j}&lt;/em>{c,a,k}(X_i)$ for every unit in the role population $(c, a)$. No observation-probability model is fitted (&lt;code>selection_model&lt;/code>, &lt;code>selection_pooling&lt;/code>, and &lt;code>selection_xformla&lt;/code> are inactive and never evaluated).&lt;/p>
&lt;p>&lt;code>imputation_scale&lt;/code> controls how pair duration enters the imputation covariate design $d_k(X_i)$:&lt;/p>
&lt;ul>
&lt;li>&lt;code>imputation_scale = &amp;quot;per_period&amp;quot;&lt;/code> (default): multiplies the non-intercept covariate columns by the panel index gap $L_k = u_{\text{idx}} - s_{\text{idx}}$ between stored calendar positions.&lt;/li>
&lt;li>&lt;code>imputation_scale = &amp;quot;per_change&amp;quot;&lt;/code>: uses the unscaled covariate columns on each pair change regardless of index gap.&lt;/li>
&lt;/ul>
&lt;p>When &lt;code>imputation_pooling = &amp;quot;separate&amp;quot;&lt;/code>, the two scales are a linear reparameterization of the same pair-specific fit; when slopes are shared across pairs of different index lengths (&lt;code>&amp;quot;within_group&amp;quot;&lt;/code> or &lt;code>&amp;quot;pooled&amp;quot;&lt;/code>), they impose different working-model restrictions.&lt;/p>
&lt;h3 id="4-conditional-mtar-augmented-observation-correction-selection--conditional_mtar-selection_est_method--dr">4. Conditional-MTAR augmented observation correction (&lt;code>selection = &amp;quot;conditional_mtar&amp;quot;&lt;/code>, &lt;code>selection_est_method = &amp;quot;dr&amp;quot;&lt;/code>)&lt;/h3>
&lt;p>With &lt;code>selection_est_method = &amp;quot;dr&amp;quot;&lt;/code>, every unit $i$ in role $(c, a)$ on pair $k = (s, u)$ receives the reconstructed pair change
$$\widehat{Z}&lt;em>{c,a,k,i} = \hat{j}&lt;/em>{c,a,k}(X_i) + \frac{S_{ik}{\Delta Y_{ik} - \hat{j}&lt;em>{c,a,k}(X_i)}}{\max(\hat{q}&lt;/em>{c,a,k}(W_i), 10^{-6})},$$
combining the actual-change WLS imputer $\hat{j}&lt;em>{c,a,k}(X_i)$ (&lt;code>imputation_pooling&lt;/code>, &lt;code>imputation_scale&lt;/code>, &lt;code>xformla&lt;/code>) with the fitted observation probability $\hat{q}&lt;/em>{c,a,k}(W_i)$ (&lt;code>selection_model&lt;/code>, &lt;code>selection_pooling&lt;/code>, &lt;code>selection_xformla&lt;/code>).&lt;/p>
&lt;p>The augmented observation correction works with &lt;strong>all three built-in treatment methods&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>&lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code>: fits the risk-set treatment propensity logit on $R_c = G_c \cup C_c$ and uses the reconstructed pair changes $\widehat{Z}$ without fitting a counterfactual stayer outcome regression.&lt;/li>
&lt;li>&lt;code>est_method = &amp;quot;reg&amp;quot;&lt;/code>: fits the counterfactual stayer outcome-change regression to the stayer reconstructions under &lt;code>outcome_pooling&lt;/code> without fitting a treatment propensity logit.&lt;/li>
&lt;li>&lt;code>est_method = &amp;quot;dr&amp;quot;&lt;/code>: fits both the risk-set treatment propensity logit and the counterfactual stayer outcome-change regression.&lt;/li>
&lt;/ul>
&lt;p>In each case, all active observation, imputation, rate, treatment-propensity, and counterfactual outcome-regression score paths are carried into the $n$-row original-unit influence functions. Every active model must pass its rank, convergence, and interior-root checks; a failed observation logit does not fall back to pure imputation, and a failed imputer does not fall back to observation weighting.&lt;/p>
&lt;h3 id="probability-clipping">Probability clipping&lt;/h3>
&lt;p>Package-owned static inverse-probability weights use the same $10^{-6}$ safeguard as cohort chained mode without trimming units or pairs:&lt;/p>
&lt;ul>
&lt;li>Risk-set treatment propensities $\hat{p}_c(X_i) = P(i \in G_c \mid i \in R_c, X_i)$ are capped above at $p^{\text{cap}}_c = \min(\hat{p}_c, 1 - 10^{-6})$, bounding control odds $p^{\text{cap}}_c / (1 - p^{\text{cap}}_c)$ by $10^6 - 1$.&lt;/li>
&lt;li>Inverse observation denominators ($\hat{q}&lt;em>{c,a,k}$ under &lt;code>&amp;quot;pair_logit&amp;quot;&lt;/code>, the final product $\hat{p}&lt;/em>{c,a,s}\hat{p}_{c,a,u}$ under &lt;code>&amp;quot;independent_period_logit&amp;quot;&lt;/code>) are floored at $10^{-6}$.&lt;/li>
&lt;li>Raw probabilities enter likelihood scores and information matrices; influence functions differentiate the clipped weights (zeroing direct probability derivatives where a cap or floor binds). The correctly specified observation-probability branch requires its floor to be inactive in population; the correctly specified treatment-propensity branch similarly requires its cap to be inactive. A correct imputation or counterfactual outcome-regression branch can instead establish consistency under the corresponding robustness conditions, even when the other probability branch is misspecified or clipped. Inference still requires the stated regularity conditions. Baseline normalized observed-pair means do not apply an observation-probability floor.&lt;/li>
&lt;/ul>
&lt;h2 id="slope-pooling-on-the-static-route">Slope pooling on the static route&lt;/h2>
&lt;p>The static route provides independent pooling controls for observation logits (&lt;code>selection_pooling&lt;/code>), actual-change imputation (&lt;code>imputation_pooling&lt;/code>), and stayer counterfactual outcome regressions (&lt;code>outcome_pooling&lt;/code>).&lt;/p>
&lt;h3 id="observation-and-imputation-pooling-selection_pooling-imputation_pooling">Observation and imputation pooling (&lt;code>selection_pooling&lt;/code>, &lt;code>imputation_pooling&lt;/code>)&lt;/h3>
&lt;p>Both arguments accept the same three static keywords:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Value&lt;/th>
&lt;th>Meaning on the static &lt;code>dname&lt;/code> route&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>&amp;quot;separate&amp;quot;&lt;/code> (default)&lt;/td>
&lt;td>Separate slope vector for each observation pair (or date) and fixed role population $(c, a)$.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;within_group&amp;quot;&lt;/code>&lt;/td>
&lt;td>One shared slope vector across observation pairs (or dates) within each fixed role population $(c, a)$ (a single transition cell $c = (t, d)$ and role $a \in {G, C}$).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;pooled&amp;quot;&lt;/code>&lt;/td>
&lt;td>One shared slope vector across all active role populations and observation pairs (or dates).&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Every observation pair (or date) and role population retains its own local intercept whenever the formula includes an intercept. Here a &amp;ldquo;group&amp;rdquo; is a role population $(c, a)$ indexed by transition date $t$, prior state $d$, and switcher/stayer status $a$, not an absorbing adoption cohort.&lt;/p>
&lt;h3 id="counterfactual-stayer-outcome-regression-pooling-outcome_pooling">Counterfactual stayer outcome-regression pooling (&lt;code>outcome_pooling&lt;/code>)&lt;/h3>
&lt;p>When &lt;code>est_method&lt;/code> is &lt;code>&amp;quot;reg&amp;quot;&lt;/code> or &lt;code>&amp;quot;dr&amp;quot;&lt;/code> (inactive and never evaluated when &lt;code>est_method = &amp;quot;ipw&amp;quot;&lt;/code>), &lt;code>outcome_pooling&lt;/code> controls how stayer ($C_c$) counterfactual outcome-change regressions share slopes across transition cells:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;code>outcome_pooling&lt;/code>&lt;/th>
&lt;th>Meaning on the static &lt;code>dname&lt;/code> route&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>&amp;quot;separate&amp;quot;&lt;/code> (default)&lt;/td>
&lt;td>One stayer slope vector $\beta_c$ and local intercept $\alpha_c$ per transition cell $c \in A$.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>&amp;quot;pooled&amp;quot;&lt;/code>&lt;/td>
&lt;td>One shared stayer slope vector $\beta$ across all declared transition cells $c \in A$, with cell-specific intercepts $\alpha_c$.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Explicit named character vector or named list&lt;/td>
&lt;td>Maps each transition &lt;code>cell_id&lt;/code> (e.g., &lt;code>&amp;quot;t2_entry&amp;quot;&lt;/code>, &lt;code>&amp;quot;t3_exit&amp;quot;&lt;/code>) to a block label, or supplies a named list of &lt;code>cell_id&lt;/code> character vectors defining disjoint regression blocks. May include extra candidate transition cells outside $A$ (&lt;code>non_target_or_cells&lt;/code>) whose stayers $C_c$ contribute to estimating shared block slopes. Explicit intermediate partitions are supported only on the static &lt;code>dname&lt;/code> route.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="result-owned-aggregation-inference-and-qualifications">Result-owned aggregation, inference and qualifications&lt;/h2>
&lt;h3 id="switcher-frequency-aggregate-fitaggregate">Switcher-frequency aggregate (&lt;code>fit$aggregate&lt;/code>)&lt;/h3>
&lt;p>A &lt;code>cdid_static_att_gt&lt;/code> object stores its own switcher-frequency weighted aggregate across the declared transition set $A$ in &lt;code>fit$aggregate&lt;/code>:
$$\hat{\delta}&lt;em>{A,s} = \sum&lt;/em>{c \in A} \hat{\omega}&lt;em>c \hat{\tau}&lt;em>c, \qquad \hat{\omega}&lt;em>c = \frac{n&lt;/em>{\text{switchers}, c}}{\sum&lt;/em>{c' \in A} n&lt;/em>{\text{switchers}, c'}}.$$&lt;/p>
&lt;ul>
&lt;li>Its $n$-row original-unit influence function (&lt;code>fit$aggregate$inffunc&lt;/code>) includes both the cell-effect influence functions $\hat{\phi}_{\tau, c}$ and the random switcher-share estimation contribution.&lt;/li>
&lt;li>If any declared cell $c \in A$ is unavailable (&lt;code>available = FALSE&lt;/code>), &lt;code>fit$aggregate$available&lt;/code> is &lt;code>FALSE&lt;/code> and &lt;code>fit$aggregate$estimate&lt;/code> is &lt;code>NA_real_&lt;/code>; the aggregate is never silently renormalized over a subset of surviving cells.&lt;/li>
&lt;li>&lt;code>cdid::aggte()&lt;/code> is designed for cohort &lt;code>ATT(g, t)&lt;/code> (&lt;code>MP&lt;/code> / &lt;code>cdid_MP&lt;/code>) objects and refuses &lt;code>cdid_static_att_gt&lt;/code> results.&lt;/li>
&lt;/ul>
&lt;h3 id="inference-and-references">Inference and references&lt;/h3>
&lt;ul>
&lt;li>&lt;strong>Analytical and multiplier bootstrap inference:&lt;/strong> Let $\Psi_i$ be the full original-unit influence-function row, $S_h=\sum_{i\in h}\Psi_i$ the sum in cluster $h$, and $\bar S$ the mean of these cluster sums. The analytical covariance is $\widehat V=n^{-2}\sum_h(S_h-\bar S)(S_h-\bar S)^\prime$, where $n$ counts all study units. Without clustering each unit is its own cluster. &lt;code>fit$analytical_se&lt;/code> is the square root of the diagonal of &lt;code>fit$V_analytical&lt;/code>. When &lt;code>bstrap = TRUE&lt;/code>, &lt;code>chained_cluster_multiplier()&lt;/code> computes common-sign Rademacher multiplier bootstrap IQR standard errors (&lt;code>fit$bootstrap_se&lt;/code>) and, when &lt;code>cband = TRUE&lt;/code> and all declared cells in $A$ are available, a simultaneous sup-$t$ critical value (&lt;code>fit$cband_crit_val&lt;/code>) over $A$. With &lt;code>bstrap = FALSE&lt;/code>, pointwise normal intervals are reported (including when &lt;code>cband = TRUE&lt;/code>). Setting &lt;code>compute_inffunc = FALSE&lt;/code> returns point estimates only.&lt;/li>
&lt;li>&lt;strong>Route-specific references:&lt;/strong> &lt;code>summary(fit)&lt;/code>, &lt;code>print(fit)&lt;/code>, and &lt;code>fit$references&lt;/code> cite Bellégo, Benatia and Dortet-Bernadet (2025) alongside de Chaisemartin, D&amp;rsquo;Haultfoeuille, Pasquier, Sow and Vazquez-Bare (2026, &lt;code>arXiv:2201.06898v7&lt;/code>), without citing Callaway and Sant&amp;rsquo;Anna (2021) (which remains the reference for the cohort &lt;code>gname&lt;/code> and &lt;code>mode = &amp;quot;ordinary&amp;quot;&lt;/code> routes).&lt;/li>
&lt;/ul>
&lt;h3 id="qualifications">Qualifications&lt;/h3>
&lt;ul>
&lt;li>&lt;strong>No blanket equivalence claim:&lt;/strong> Exact finite-sample agreement with other implementations (such as the &lt;code>did_multiplegt_stat&lt;/code> Stata command) holds only when the target, complete/incomplete data handling, covariate specification, propensity/regression fitting, weight normalization, directional sample definition, and variance convention match. For example, &lt;code>cdid&lt;/code> evaluates influence functions on all $n$ original study units with a $1/n$ population-moment variance convention, fits logistic treatment propensities with $1 - 10^{-6}$ capping and $10^{-6}$ inverse-observation flooring, and supports multi-pair chained GMM and missing-outcome corrections that have no counterpart in pairwise complete-record implementations.&lt;/li>
&lt;li>&lt;strong>Asymptotic conditions and no coverage guarantee:&lt;/strong> Validity requires the static no-carryover potential-outcomes benchmark, conditional parallel trends and mean trend-MAR on every used role pair, overlap, regular nuisance fits and the branch-specific clipping conditions above, fixed finite support ($T, |A|, m_R$), and many independent units or clusters ($G \to \infty$). No finite-sample unbiasedness, few-cluster validity, or Monte Carlo coverage guarantee is claimed.&lt;/li>
&lt;/ul>
&lt;/details>
&lt;h2 id="references">References&lt;/h2>
&lt;ul>
&lt;li>Bellégo, C., Benatia, D. and Dortet-Bernadet, V. (2025). The Chained Difference-in-Differences. &lt;em>Journal of Econometrics&lt;/em>, 248, article 105783. &lt;a href="https://doi.org/10.1016/j.jeconom.2024.105783" target="_blank" rel="noopener">https://doi.org/10.1016/j.jeconom.2024.105783&lt;/a>.&lt;/li>
&lt;li>de Chaisemartin, C., D&amp;rsquo;Haultfoeuille, X., Pasquier, F., Sow, D. and Vazquez-Bare, G. (2026). Difference-in-Differences Estimators for Treatments Continuously Distributed at Every Period. Working paper, &lt;code>arXiv:2201.06898v7&lt;/code> (revised 2026-07-22), static binary specialization. &lt;a href="https://arxiv.org/abs/2201.06898v7" target="_blank" rel="noopener">https://arxiv.org/abs/2201.06898v7&lt;/a>.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;p>&lt;a href="https://www.davidbenatia.com/tools/cdid/guide/">Guide home&lt;/a> · &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/reference/options/">Options reference&lt;/a> · &lt;a href="https://www.davidbenatia.com/tools/cdid/guide/methods/missing-outcomes/">Handling missing outcomes&lt;/a> · &lt;a href="https://github.com/dvbn/cdid/blob/b595cffabf9739d04d6b335604195450894ce958/README.md" target="_blank" rel="noopener">Package overview&lt;/a>&lt;/p></description></item></channel></rss>