Panel.Estimand­Characterization.Staggered­TWFEDecomposition

The Goodman-Bacon decomposition: TWFE-DiD as a weighted average of 2x2 comparisons, with the weight formulas.

Support 20 core · 26 supporting · 5 submodules Support layer for the Goodman-Bacon decomposition: saturated cohort-period classes, cell-mass identities, orthogonality lemmas, residualization witnesses, and per-cell numerator and denominator formulas. Pairwise 5 core · 15 supporting · 2 submodules This file reduces Goodman-Bacon denominator and numerator terms to ordered-pair centered-treatment contributions.
Finite­Panel 34 core · 4 supporting This file provides the finite cohort-period primitives for the Goodman-Bacon two-way fixed-effect decomposition. ★ Dtilde_eq

Goodman-Bacon Panel Algebra

This file provides the finite cohort-period primitives for the Goodman-Bacon two-way fixed-effect decomposition. It defines staggered adoption panels, absorbing treatment, residualized treatment, the TWFE coefficient, comparison windows, pairwise comparison contrasts, and the raw and normalized weights for treated-versus-never, early-versus-late, and late-versus-early comparisons.

inductive CompTag reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

The three-category comparison label classifies each admissible two-by-two comparison as a treated cohort against a never-treated cohort, an early-adopting cohort against a later-adopting cohort before the latter adopts, or a later-adopting cohort against an early-adopting cohort after the latter adopts.

Definition (Lean source)
CompTag :
Type
TN :
EL :
LE :
deriving DecidableEq
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.CompTag · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:61
structure CohortPanel reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

A staggered-adoption cohort panel: a cell-statistics record carrying, per cohort, a population share, an adoption date — a finite period, or ⊤ for the never-treated case, and the cohort-period factual outcome mean, subject to a positive number of periods, strictly positive cohort shares, and cohort shares summing to one.

Definition (Lean source)
𝒢 :
Type*
T :
ℕ
Fintype 𝒢
Cohort population share `p_g`.
p :
𝒢 → ℝ
Adoption date `A_g ∈ 𝒯 ∪ {∞}`, encoded with `⊤ = ∞`.
A :
𝒢 → WithTop (Fin T)
Cohort-period factual outcome mean `Y_{gt}`.
Y :
𝒢 → Fin T → ℝ
The number of periods is positive.
T_pos :
0 < T
Cohort shares are strictly positive.
p_pos :
∀ g, 0 < p g
Cohort shares sum to one.
p_sum_one :
∑ g, p g = 1
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.CohortPanel · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:68
def D reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, a cohort, and a period, the treatment indicator equals one if the cohort has adopted by that period and zero otherwise, and is therefore binary and absorbing.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
g :
𝒢
t :
Fin T
D P g t :
ℝ
if AdoptionPath.le (P.A g) t then 1 else 0
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.D · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:90 · uses CohortPanel
def barD reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel and a cohort, the cohort treatment share is that cohort's treatment indicator averaged over all panel periods.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
g :
𝒢
barD P g :
ℝ
(T : ℝ)⁻¹ * ∑ t, D P g t
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.barD · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:96 · uses CohortPanel
def pCohort reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, the overall treatment share is the sum of each cohort's population share times its average treatment indicator.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
pCohort P :
ℝ
∑ g, P.p g * barD P g
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.pCohort · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:100 · uses CohortPanel
def cohortWeights reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, the cohort weight system assigns each cohort its population share and carries the panel's positivity and unit-sum conditions.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
cohortWeights P :
WeightedTwoWayPanel.UnitWeights 𝒢
⟨P.p, P.p_pos, P.p_sum_one⟩
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.cohortWeights · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:104 · uses CohortPanel , UnitWeights
def Dtilde reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, a cohort, and a period, the residualized treatment is the treatment indicator minus its cohort mean and its cross-cohort period mean, plus the grand mean.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
g :
𝒢
t :
Fin T
Dtilde P g t :
ℝ
WeightedTwoWayPanel.ddot (cohortWeights P) (D P) g t
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.Dtilde · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:121 · uses CohortPanel
theorem Dtilde_eq reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel and a cohort-period cell, the double-demeaned residualized treatment Dtilde P g t equals the original Goodman-Bacon closed form: the raw treatment minus the cohort mean, minus the period cross-cohort mean, plus the grand mean.

Formal statement
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
g :
𝒢
t :
Fin T
Dtilde P g t = D P g t - barD P g - (∑ g', P.p g' * D P g' t) + pCohort P
Proof (Lean source)
theorem Dtilde_eq (P : CohortPanel 𝒢 T) (g : 𝒢) (t : Fin T) : Dtilde P g t = D P g t - barD P g - (∑ g', P.p g' * D P g' t) + pCohort P := by unfold Dtilde WeightedTwoWayPanel.ddot rw [← barD_eq_unitMean P g, ← pCohort_eq_grandMean P] unfold WeightedTwoWayPanel.timeMean cohortWeights simp
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.Dtilde_eq · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:126 · uses CohortPanel , D , Dtilde , barD , pCohort
def VD reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, the residualized-treatment variance is the sum, over cohorts and periods, of the cohort share divided by the number of periods times squared residualized treatment.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
VD P :
ℝ
∑ g, ∑ t, (P.p g / (T : ℝ)) * (Dtilde P g t)^2
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.VD · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:137 · uses CohortPanel
def betaTWFE reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, the finite-cell population two-way-fixed-effects coefficient is the weighted covariance of residualized treatment and factual outcomes divided by residualized-treatment variance; it is defined even when that denominator is zero.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
betaTWFE P :
ℝ
(∑ g, ∑ t, (P.p g / (T : ℝ)) * Dtilde P g t * P.Y g t) / VD P
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.betaTWFE · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:141 · uses CohortPanel
def Ybar reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, a cohort, and a set of periods, the factual-outcome window mean is the average factual outcome for that cohort over the specified periods, and is defined as zero when the set is empty.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
g :
𝒢
S :
Ybar P g S :
ℝ
(S.card : ℝ)⁻¹ * ∑ t ∈ S, P.Y g t
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.Ybar · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:147 · uses CohortPanel
def S0_TN reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel and a cohort, the treated-versus-never untreated window is the set of all panel periods before that cohort's adoption date.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
g :
𝒢
S0_TN P g :
Finset.univ.filter (fun t => AdoptionPath.lt (P.A g) t)
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.S0_TN · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:154 · uses CohortPanel
def S1_TN reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel and a cohort, the treated-versus-never treated window is the set of all panel periods at or after that cohort's adoption date.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
g :
𝒢
S1_TN P g :
Finset.univ.filter (fun t => AdoptionPath.le (P.A g) t)
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.S1_TN · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:159 · uses CohortPanel
def S0_EL reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel and an early-adopting cohort, the early-versus-late untreated window is the set of all periods before the early cohort's adoption date.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
e :
𝒢
S0_EL P e :
Finset.univ.filter (fun t => AdoptionPath.lt (P.A e) t)
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.S0_EL · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:164 · uses CohortPanel
def S1_EL reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, an early cohort, and a late cohort, the early-versus-late treated window is the set of periods from the early cohort's adoption through the period before the late cohort's adoption.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
e ℓ :
𝒢
S1_EL P e ℓ :
Finset.univ.filter (fun t => AdoptionPath.le (P.A e) t ∧ AdoptionPath.lt (P.A ℓ) t)
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.S1_EL · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:169 · uses CohortPanel
def S0_LE reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, an early cohort, and a late cohort, the late-versus-early early-treated window is the set of periods from the early cohort's adoption through the period before the late cohort's adoption.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
e ℓ :
𝒢
S0_LE P e ℓ :
S1_EL P e ℓ
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.S0_LE · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:174 · uses CohortPanel
def S1_LE reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel and a late cohort, the late-versus-early both-treated window is the set of all periods at or after the late cohort's adoption date.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
ℓ :
𝒢
S1_LE P ℓ :
Finset.univ.filter (fun t => AdoptionPath.le (P.A ℓ) t)
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.S1_LE · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:179 · uses CohortPanel
def Δ_TN reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, a treated cohort, and a never-treated comparison cohort, the treated-versus-never two-by-two difference-in-differences contrast is the treated cohort's outcome change between its treated and untreated windows minus the comparison cohort's change over those same windows.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
g u :
𝒢
Δ_TN P g u :
ℝ
(Ybar P g (S1_TN P g) - Ybar P g (S0_TN P g))
- (Ybar P u (S1_TN P g) - Ybar P u (S0_TN P g))
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.Δ_TN · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:185 · uses CohortPanel
def Δ_EL reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, an early cohort, and a late cohort, the early-versus-late two-by-two difference-in-differences contrast is the early cohort's outcome change from its untreated to its treated-before-late window minus the late cohort's change over those same windows.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
e ℓ :
𝒢
Δ_EL P e ℓ :
ℝ
(Ybar P e (S1_EL P e ℓ) - Ybar P e (S0_EL P e))
- (Ybar P ℓ (S1_EL P e ℓ) - Ybar P ℓ (S0_EL P e))
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.Δ_EL · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:190 · uses CohortPanel
def Δ_LE reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, an early cohort, and a late cohort, the late-versus-early two-by-two difference-in-differences contrast is the late cohort's outcome change from the early-treated window to the both-treated window minus the early cohort's change over those same windows.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
e ℓ :
𝒢
Δ_LE P e ℓ :
ℝ
(Ybar P ℓ (S1_LE P ℓ) - Ybar P ℓ (S0_LE P e ℓ))
- (Ybar P e (S1_LE P ℓ) - Ybar P e (S0_LE P e ℓ))
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.Δ_LE · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:195 · uses CohortPanel
def lambdaTN reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, a treated cohort, and a never-treated cohort, the treated-versus-never raw weight is the product of their population shares and the treated cohort's average treatment indicator times one minus that indicator.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
g u :
𝒢
lambdaTN P g u :
ℝ
P.p g * P.p u * (barD P g * (1 - barD P g))
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.lambdaTN · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:202 · uses CohortPanel
def q reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, an early cohort, and a late cohort, the treatment-share gap is the early cohort's average treatment indicator minus the late cohort's average treatment indicator.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
e ℓ :
𝒢
q P e ℓ :
ℝ
barD P e - barD P ℓ
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.q · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:206 · uses CohortPanel
def mu reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, an early cohort, and a late cohort, the comparison splitting fraction is one minus the early cohort's treatment share divided by one minus their treatment-share gap, with the usual zero-denominator convention.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
e ℓ :
𝒢
mu P e ℓ :
ℝ
(1 - barD P e) / (1 - q P e ℓ)
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.mu · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:210 · uses CohortPanel
def lambdaEL reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, an early cohort, and a late cohort, the early-versus-late raw weight is the product of their shares, their treatment-share gap, one minus that gap, and the comparison splitting fraction.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
e ℓ :
𝒢
lambdaEL P e ℓ :
ℝ
P.p e * P.p ℓ * q P e ℓ * (1 - q P e ℓ) * mu P e ℓ
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.lambdaEL · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:214 · uses CohortPanel
def lambdaLE reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, an early cohort, and a late cohort, the late-versus-early raw weight is the product of their shares, their treatment-share gap, one minus that gap, and one minus the comparison splitting fraction.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
e ℓ :
𝒢
lambdaLE P e ℓ :
ℝ
P.p e * P.p ℓ * q P e ℓ * (1 - q P e ℓ) * (1 - mu P e ℓ)
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.lambdaLE · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:218 · uses CohortPanel
def Lambda reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, the aggregate raw-weight denominator is the sum of treated-versus-never raw weights for finite-versus-never-treated pairs and the two timing-comparison raw weights for ordered finite adoption-date pairs.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
Lambda P :
ℝ
(∑ g, ∑ u, if AdoptionPath.isFinite (P.A g) ∧ AdoptionPath.isInfinite (P.A u) then lambdaTN P g u else 0)
+ (∑ e, ∑ ℓ, if P.A e < P.A ℓ ∧ AdoptionPath.isFinite (P.A ℓ) then lambdaEL P e ℓ + lambdaLE P e ℓ else 0)
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.Lambda · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:223 · uses CohortPanel
def w_TN reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, a treated cohort, and a never-treated cohort, the normalized treated-versus-never weight is its raw weight divided by the aggregate raw-weight denominator.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
g u :
𝒢
w_TN P g u :
ℝ
lambdaTN P g u / Lambda P
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.w_TN · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:230 · uses CohortPanel
def w_EL reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, an early cohort, and a late cohort, the normalized early-versus-late weight is its raw weight divided by the aggregate raw-weight denominator.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
e ℓ :
𝒢
w_EL P e ℓ :
ℝ
lambdaEL P e ℓ / Lambda P
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.w_EL · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:234 · uses CohortPanel
def w_LE reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, an early cohort, and a late cohort, the normalized late-versus-early weight is its raw weight divided by the aggregate raw-weight denominator.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
e ℓ :
𝒢
w_LE P e ℓ :
ℝ
lambdaLE P e ℓ / Lambda P
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.w_LE · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:238 · uses CohortPanel
def admissible reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel and a tagged ordered cohort pair, the admissibility condition holds precisely when a treated-versus-never tag pairs an eventually treated cohort with a never-treated cohort, or either timing-comparison tag orders two finitely adopting cohorts by adoption date, and in every case both cohort shares are positive.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
k :
CompTag × 𝒢 × 𝒢
admissible P k :
Prop
match k.1 with | CompTag.TN => AdoptionPath.isFinite (P.A k.2.1) ∧
AdoptionPath.isInfinite (P.A k.2.2) ∧
0 < P.p k.2.1 ∧
0 < P.p k.2.2 | CompTag.EL => P.A k.2.1 < P.A k.2.2 ∧
AdoptionPath.isFinite (P.A k.2.2) ∧
0 < P.p k.2.1 ∧
0 < P.p k.2.2 | CompTag.LE => P.A k.2.1 < P.A k.2.2 ∧
AdoptionPath.isFinite (P.A k.2.2) ∧
0 < P.p k.2.1 ∧
0 < P.p k.2.2
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.admissible · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:244 · uses CohortPanel , CompTag
def 𝒦 reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel, the comparison index set is the finite set of every tagged ordered cohort pair satisfying the admissibility condition.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
𝒦 P :
Finset (CompTag × 𝒢 × 𝒢)
(Finset.univ : Finset (CompTag × 𝒢 × 𝒢)).filter (fun k => admissible P k)
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.𝒦 · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:258 · uses CohortPanel , CompTag
def weight reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel and a tagged ordered cohort pair, the unified normalized weight is the normalized weight associated with that pair's comparison tag when the pair is admissible, and zero otherwise.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
k :
CompTag × 𝒢 × 𝒢
weight P k :
ℝ
if admissible P k then match k.1 with | CompTag.TN
=> w_TN P k.2.1 k.2.2 | CompTag.EL => w_EL P k.2.1 k.2.2 | CompTag.LE => w_LE P k.2.1 k.2.2 else 0
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.weight · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:263 · uses CohortPanel , CompTag
def contrast reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel and a tagged ordered cohort pair, the unified two-by-two contrast is the contrast associated with that pair's comparison tag when the pair is admissible, and zero otherwise.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
k :
CompTag × 𝒢 × 𝒢
contrast P k :
ℝ
if admissible P k then match k.1 with | CompTag.TN
=> Δ_TN P k.2.1 k.2.2 | CompTag.EL => Δ_EL P k.2.1 k.2.2 | CompTag.LE => Δ_LE P k.2.1 k.2.2 else 0
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.contrast · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:273 · uses CohortPanel , CompTag
def lambdaWeight reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a cohort panel and a tagged ordered cohort pair, the unified raw weight is the raw weight associated with that pair's comparison tag when the pair is admissible, and zero otherwise.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
k :
CompTag × 𝒢 × 𝒢
lambdaWeight P k :
ℝ
if admissible P k then match k.1 with | CompTag.TN
=> lambdaTN P k.2.1 k.2.2 | CompTag.EL => lambdaEL P k.2.1 k.2.2 | CompTag.LE => lambdaLE P k.2.1 k.2.2 else 0
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.lambdaWeight · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/FinitePanel.lean:283 · uses CohortPanel , CompTag
4 supporting declarations (lemmas, instances)
Causal 6 core · 9 supporting This file gives the causal layer of the Goodman-Bacon staggered-timing decomposition. ★ Δ_TN_eq_ATT★ Δ_EL_eq_ATT★ Δ_LE_eq_bad_comparison

Goodman-Bacon Causal Characterization

This file gives the causal layer of the Goodman-Bacon staggered-timing decomposition. Under two-state potential-outcome assumptions, consistency, no anticipation, and pairwise untreated parallel trends, it identifies the treated-versus-never and early-versus-late contrasts with window-specific average treatment effects and expresses the late-versus-early contrast with its bad-comparison adjustment.

def Ybar0 reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

The never-treated mean outcome over a period window averages a cohort's never-treated potential outcomes across the selected periods and is zero for an empty window.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
Y0 :
𝒢 → Fin T → ℝ
g :
𝒢
S :
Ybar0 Y0 g S :
ℝ
(S.card : ℝ)⁻¹ * ∑ t ∈ S, Y0 g t
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.Ybar0 · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Causal.lean:103
def ATT_window reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

The window-specific average treatment effect on the treated averages the difference between own-adoption potential outcomes and never-treated potential outcomes for a cohort across the selected periods, and is zero for an empty window.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
Y0 Y1 :
𝒢 → Fin T → ℝ
g :
𝒢
S :
ATT_window Y0 Y1 g S :
ℝ
(S.card : ℝ)⁻¹ * ∑ t ∈ S, (Y1 g t - Y0 g t)
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.ATT_window · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Causal.lean:109
structure CausalAssumptions reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

The causal model for a cohort panel, never-treated potential outcomes, and own-adoption potential outcomes combines consistency after adoption, consistency with never treatment before adoption, no anticipation across the two potential-outcome paths, and untreated parallel trends for treated-versus-never comparisons, early-versus-late comparisons, and late-versus-early comparisons.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
Y0 Y1 :
𝒢 → Fin T → ℝ
consistencyTreated :
∀ g t
if
AdoptionPath.le (P.A g) t
then
P.Y g t = Y1 g t

Consistency on treated cells: when A_g ≤ t, the factual outcome equals the post-adoption potential outcome.

consistencyUntreated :
∀ g t
if
AdoptionPath.lt (P.A g) t
then
P.Y g t = Y0 g t

Consistency on untreated cells: when t < A_g, the factual outcome equals the never-treated potential outcome.

noAnticipation :
∀ g t
if
AdoptionPath.lt (P.A g) t
then
Y1 g t = Y0 g t

No anticipation: pre-adoption potential outcomes coincide.

parallelTrends_TN :
∀ g u
if
AdoptionPath.isFinite (P.A g)
and
AdoptionPath.isInfinite (P.A u)
then
Ybar0 Y0 g (S1_TN P g) - Ybar0 Y0 g (S0_TN P g)
= Ybar0 Y0 u (S1_TN P g) - Ybar0 Y0 u (S0_TN P g)

Pairwise untreated parallel trends for treated-vs-never (TN).

parallelTrends_EL :
∀ e ℓ
if
P.A e < P.A ℓ
and
AdoptionPath.isFinite (P.A ℓ)
then
Ybar0 Y0 e (S1_EL P e ℓ) - Ybar0 Y0 e (S0_EL P e)
= Ybar0 Y0 ℓ (S1_EL P e ℓ) - Ybar0 Y0 ℓ (S0_EL P e)

Pairwise untreated parallel trends for early-vs-late before late (EL).

parallelTrends_LE :
∀ e ℓ
if
P.A e < P.A ℓ
and
AdoptionPath.isFinite (P.A ℓ)
then
Ybar0 Y0 e (S1_LE P ℓ) - Ybar0 Y0 e (S0_LE P e ℓ)
= Ybar0 Y0 ℓ (S1_LE P ℓ) - Ybar0 Y0 ℓ (S0_LE P e ℓ)

Pairwise untreated parallel trends for late-vs-early after early (LE).

Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.CausalAssumptions · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Causal.lean:117 · uses CohortPanel
theorem Δ_TN_eq_ATT reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

Under the packaged causal assumptions linking a cohort panel to never-treated and own-adoption potential-outcome paths, the DID comparison of a treated and a never-treated cohort identifies the treated cohort's post-adoption window effect when their adoption dates are respectively finite and infinite, and the treated cohort has a pre-treatment period.

Formal statement
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
Y0 Y1 :
𝒢 → Fin T → ℝ
hA :
g u :
𝒢
h_g_fin :
AdoptionPath.isFinite (P.A g)
h_u_inf :
AdoptionPath.isInfinite (P.A u)
h_pre :
(S0_TN P g).Nonempty
Δ_TN P g u = ATT_window Y0 Y1 g (S1_TN P g)
Proof (Lean source)
theorem Δ_TN_eq_ATT (P : CohortPanel 𝒢 T) (Y0 Y1 : 𝒢 → Fin T → ℝ) (hA : CausalAssumptions P Y0 Y1) (g u : 𝒢) (h_g_fin : AdoptionPath.isFinite (P.A g)) (h_u_inf : AdoptionPath.isInfinite (P.A u)) (h_pre : (S0_TN P g).Nonempty) : Δ_TN P g u = ATT_window Y0 Y1 g (S1_TN P g) := by exact (fun _ : (S0_TN P g).Nonempty => Δ_TN_eq_ATT_totalized P Y0 Y1 hA g u h_g_fin h_u_inf) h_pre
theorem Δ_EL_eq_ATT reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

Under the packaged causal assumptions linking a cohort panel to never-treated and own-adoption potential-outcome paths, the DID comparison of an early and a late cohort identifies the early cohort's effect over the between-adoption window when the early cohort adopts first, the late cohort eventually adopts, and the early cohort has a pre-treatment period.

Formal statement
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
Y0 Y1 :
𝒢 → Fin T → ℝ
hA :
e ℓ :
𝒢
h_lt :
P.A e < P.A ℓ
h_ℓ_fin :
AdoptionPath.isFinite (P.A ℓ)
h_pre :
(S0_EL P e).Nonempty
Δ_EL P e ℓ = ATT_window Y0 Y1 e (S1_EL P e ℓ)
Proof (Lean source)
theorem Δ_EL_eq_ATT (P : CohortPanel 𝒢 T) (Y0 Y1 : 𝒢 → Fin T → ℝ) (hA : CausalAssumptions P Y0 Y1) (e ℓ : 𝒢) (h_lt : P.A e < P.A ℓ) (h_ℓ_fin : AdoptionPath.isFinite (P.A ℓ)) (h_pre : (S0_EL P e).Nonempty) : Δ_EL P e ℓ = ATT_window Y0 Y1 e (S1_EL P e ℓ) := by exact (fun _ : (S0_EL P e).Nonempty => Δ_EL_eq_ATT_totalized P Y0 Y1 hA e ℓ h_lt h_ℓ_fin) h_pre
theorem Δ_LE_eq_bad_comparison reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

Layer C corollary 3 — LE has a bad-comparison term. Fix a cohort panel P and potential-outcome maps Y0, Y1, and assume consistency on treated and untreated cells, no anticipation, and pairwise untreated parallel trends across the three comparison types. For an early cohort e whose adoption date strictly precedes that of a late cohort ℓ, with ℓ's adoption date finite, the late-versus-early contrast Δ_LE equals ℓ's window-specific average treatment effect on the treated over its post-adoption window, minus the "bad-comparison" gap between e's own treatment effects on the two comparison windows:

Formal statement
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
Y0 Y1 :
𝒢 → Fin T → ℝ
hA :
e ℓ :
𝒢
h_lt :
P.A e < P.A ℓ
h_ℓ_fin :
AdoptionPath.isFinite (P.A ℓ)
Δ_LE P e ℓ
= ATT_window Y0 Y1 ℓ (S1_LE P ℓ)
- (ATT_window Y0 Y1 e (S1_LE P ℓ) - ATT_window Y0 Y1 e (S0_LE P e ℓ))
Proof (Lean source)
theorem Δ_LE_eq_bad_comparison (P : CohortPanel 𝒢 T) (Y0 Y1 : 𝒢 → Fin T → ℝ) (hA : CausalAssumptions P Y0 Y1) (e ℓ : 𝒢) (h_lt : P.A e < P.A ℓ) (h_ℓ_fin : AdoptionPath.isFinite (P.A ℓ)) : Δ_LE P e ℓ = ATT_window Y0 Y1 ℓ (S1_LE P ℓ) - (ATT_window Y0 Y1 e (S1_LE P ℓ) - ATT_window Y0 Y1 e (S0_LE P e ℓ)) := by classical have h_l1 : Ybar P ℓ (S1_LE P ℓ) = Ybar0 Y0 ℓ (S1_LE P ℓ) + ATT_window Y0 Y1 ℓ (S1_LE P ℓ) := by exact CausalAssumptions.Ybar_eq_Ybar0_add_ATT_of_treated hA.consistencyTreated ℓ (S1_LE P ℓ) (by intro t ht simpa only [S1_LE, mem_filter, Finset.mem_univ, true_and, Set.mem_ofPred_eq] using ht) have h_l0 := CausalAssumptions.Ybar_eq_Ybar0_late_on_S0_LE hA.consistencyUntreated e ℓ have h_e0 : Ybar P e (S0_LE P e ℓ) = Ybar0 Y0 e (S0_LE P e ℓ) + ATT_window Y0 Y1 e (S0_LE P e ℓ) := by exact CausalAssumptions.Ybar_eq_Ybar0_add_ATT_of_treated hA.consistencyTreated e (S0_LE P e ℓ) (by intro t ht have htmem : AdoptionPath.le (P.A e) t ∧ AdoptionPath.lt (P.A ℓ) t := by simpa only [S0_LE, S1_EL, mem_filter, Finset.mem_univ, true_and, Set.mem_ofPred_eq] using ht exact htmem.1) have h_e1 : Ybar P e (S1_LE P ℓ) = Ybar0 Y0 e (S1_LE P ℓ) + ATT_window Y0 Y1 e (S1_LE P ℓ) := by exact CausalAssumptions.Ybar_eq_Ybar0_add_ATT_of_treated hA.consistencyTreated e (S1_LE P ℓ) (by intro t ht have hle : AdoptionPath.le (P.A ℓ) t := by simpa only [S1_LE, mem_filter, Finset.mem_univ, true_and, Set.mem_ofPred_eq] using ht exact le_of_lt (lt_of_lt_of_le h_lt hle)) have hPT := hA.parallelTrends_LE e ℓ h_lt h_ℓ_fin unfold Δ_LE rw [h_l1, h_l0, h_e1, h_e0] linarith
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.Δ_LE_eq_bad_comparison · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Causal.lean:426 · uses isFinite , ATT_window , CausalAssumptions , CohortPanel , S0_LE , S1_LE , Δ_LE
9 supporting declarations (lemmas, instances)
  • Ybar_eq_Ybar0_on_S0_TN theorem — On the untreated window S0_TN P g = {t : t < A_g}, the factual Ybar of cohort g equals the never-treated Ybar0: by consistencyUntreated on each cell.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    𝒢 → Fin T → ℝ
    shared
    hConsistency :
    ∀ g t
    if
    AdoptionPath.lt (P.A g) t
    then
    P.Y g t = Y0 g t
    g :
    𝒢
    Ybar P g (S0_TN P g) = Ybar0 Y0 g (S0_TN P g)
    Proof (Lean source)
    theorem Ybar_eq_Ybar0_on_S0_TN (hConsistency : ∀ g t, AdoptionPath.lt (P.A g) t → P.Y g t = Y0 g t) (g : 𝒢) : Ybar P g (S0_TN P g) = Ybar0 Y0 g (S0_TN P g) := by classical unfold Ybar Ybar0 congr 1 refine Finset.sum_congr rfl ?_ intro t ht have htlt : AdoptionPath.lt (P.A g) t := by simpa only [S0_TN, mem_filter, Finset.mem_univ, true_and, Set.mem_ofPred_eq] using ht exact hConsistency g t htlt
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.CausalAssumptions.Ybar_eq_Ybar0_on_S0_TN · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Causal.lean:173
  • Ybar_eq_Ybar0_of_inf theorem — On any window S where every period is untreated for cohort u, the factual Ybar equals the never-treated Ybar0.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    𝒢 → Fin T → ℝ
    shared
    hConsistency :
    ∀ g t
    if
    AdoptionPath.lt (P.A g) t
    then
    P.Y g t = Y0 g t
    u :
    𝒢
    S :
    hS :
    ∀ t ∈ S, AdoptionPath.lt (P.A u) t
    Ybar P u S = Ybar0 Y0 u S
    Proof (Lean source)
    theorem Ybar_eq_Ybar0_of_inf (hConsistency : ∀ g t, AdoptionPath.lt (P.A g) t → P.Y g t = Y0 g t) {u : 𝒢} (S : Finset (Fin T)) (hS : ∀ t ∈ S, AdoptionPath.lt (P.A u) t) : Ybar P u S = Ybar0 Y0 u S := by classical unfold Ybar Ybar0 congr 1 refine Finset.sum_congr rfl ?_ intro t ht exact hConsistency u t (hS t ht)
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.CausalAssumptions.Ybar_eq_Ybar0_of_inf · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Causal.lean:190
  • Ybar_eq_Ybar0_add_ATT_of_treated theorem — On a window where every cell is treated for cohort g, the factual Ybar decomposes as the never-treated mean plus the window ATT.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    𝒢 → Fin T → ℝ
    𝒢 → Fin T → ℝ
    shared
    hConsistency :
    ∀ g t
    if
    AdoptionPath.le (P.A g) t
    then
    P.Y g t = Y1 g t
    g :
    𝒢
    S :
    hS :
    ∀ t ∈ S, AdoptionPath.le (P.A g) t
    Ybar P g S = Ybar0 Y0 g S + ATT_window Y0 Y1 g S
    Proof (Lean source)
    theorem Ybar_eq_Ybar0_add_ATT_of_treated (hConsistency : ∀ g t, AdoptionPath.le (P.A g) t → P.Y g t = Y1 g t) (g : 𝒢) (S : Finset (Fin T)) (hS : ∀ t ∈ S, AdoptionPath.le (P.A g) t) : Ybar P g S = Ybar0 Y0 g S + ATT_window Y0 Y1 g S := by classical unfold Ybar Ybar0 ATT_window rw [← mul_add] congr 1 calc ∑ t ∈ S, P.Y g t = ∑ t ∈ S, Y1 g t := by refine Finset.sum_congr rfl ?_ intro t ht exact hConsistency g t (hS t ht) _ = ∑ t ∈ S, (Y0 g t + (Y1 g t - Y0 g t)) := by refine Finset.sum_congr rfl ?_ intro t _ ring _ = ∑ t ∈ S, Y0 g t + ∑ t ∈ S, (Y1 g t - Y0 g t) := by exact Finset.sum_add_distrib
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.CausalAssumptions.Ybar_eq_Ybar0_add_ATT_of_treated · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Causal.lean:205
  • Ybar_eq_Ybar0_on_S0_EL theorem — On the early-cohort untreated window S0_EL P e = {t : t < A_e}, the factual Ybar of cohort e equals the never-treated Ybar0.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    𝒢 → Fin T → ℝ
    shared
    hConsistency :
    ∀ g t
    if
    AdoptionPath.lt (P.A g) t
    then
    P.Y g t = Y0 g t
    e :
    𝒢
    Ybar P e (S0_EL P e) = Ybar0 Y0 e (S0_EL P e)
    Proof (Lean source)
    theorem Ybar_eq_Ybar0_on_S0_EL (hConsistency : ∀ g t, AdoptionPath.lt (P.A g) t → P.Y g t = Y0 g t) (e : 𝒢) : Ybar P e (S0_EL P e) = Ybar0 Y0 e (S0_EL P e) := by classical unfold Ybar Ybar0 congr 1 refine Finset.sum_congr rfl ?_ intro t ht have htlt : AdoptionPath.lt (P.A e) t := by simpa only [S0_EL, mem_filter, Finset.mem_univ, true_and, Set.mem_ofPred_eq] using ht exact hConsistency e t htlt
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.CausalAssumptions.Ybar_eq_Ybar0_on_S0_EL · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Causal.lean:229
  • Ybar_eq_Ybar0_late_on_S1_EL theorem — The late-cohort factual Ybar on S1_EL P e ℓ = {A_e ≤ t < A_ℓ} equals the never-treated Ybar0: each cell satisfies t < A_ℓ.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    𝒢 → Fin T → ℝ
    shared
    hConsistency :
    ∀ g t
    if
    AdoptionPath.lt (P.A g) t
    then
    P.Y g t = Y0 g t
    e ℓ :
    𝒢
    Ybar P ℓ (S1_EL P e ℓ) = Ybar0 Y0 ℓ (S1_EL P e ℓ)
    Proof (Lean source)
    theorem Ybar_eq_Ybar0_late_on_S1_EL (hConsistency : ∀ g t, AdoptionPath.lt (P.A g) t → P.Y g t = Y0 g t) (e ℓ : 𝒢) : Ybar P ℓ (S1_EL P e ℓ) = Ybar0 Y0 ℓ (S1_EL P e ℓ) := by classical unfold Ybar Ybar0 congr 1 refine Finset.sum_congr rfl ?_ intro t ht have htmem : AdoptionPath.le (P.A e) t ∧ AdoptionPath.lt (P.A ℓ) t := by simpa only [S1_EL, mem_filter, Finset.mem_univ, true_and, Set.mem_ofPred_eq] using ht exact hConsistency ℓ t htmem.2
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.CausalAssumptions.Ybar_eq_Ybar0_late_on_S1_EL · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Causal.lean:245
  • Ybar_eq_Ybar0_late_on_S0_EL theorem — The late-cohort factual Ybar on S0_EL P e = {t : t < A_e} equals the never-treated Ybar0 when A_e < A_ℓ.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    𝒢 → Fin T → ℝ
    shared
    hConsistency :
    ∀ g t
    if
    AdoptionPath.lt (P.A g) t
    then
    P.Y g t = Y0 g t
    e ℓ :
    𝒢
    h_lt :
    P.A e < P.A ℓ
    Ybar P ℓ (S0_EL P e) = Ybar0 Y0 ℓ (S0_EL P e)
    Proof (Lean source)
    theorem Ybar_eq_Ybar0_late_on_S0_EL (hConsistency : ∀ g t, AdoptionPath.lt (P.A g) t → P.Y g t = Y0 g t) (e ℓ : 𝒢) (h_lt : P.A e < P.A ℓ) : Ybar P ℓ (S0_EL P e) = Ybar0 Y0 ℓ (S0_EL P e) := by classical unfold Ybar Ybar0 congr 1 refine Finset.sum_congr rfl ?_ intro t ht have htlt : (t : WithTop (Fin T)) < P.A e := by have h0 : AdoptionPath.lt (P.A e) t := by simpa only [S0_EL, mem_filter, Finset.mem_univ, true_and, Set.mem_ofPred_eq] using ht exact h0 exact hConsistency ℓ t (by simpa [AdoptionPath.lt] using lt_trans htlt h_lt)
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.CausalAssumptions.Ybar_eq_Ybar0_late_on_S0_EL · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Causal.lean:261
  • Ybar_eq_Ybar0_late_on_S0_LE theorem — The late-cohort factual Ybar on S0_LE P e ℓ = {A_e ≤ t < A_ℓ} equals the never-treated Ybar0.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    𝒢 → Fin T → ℝ
    shared
    hConsistency :
    ∀ g t
    if
    AdoptionPath.lt (P.A g) t
    then
    P.Y g t = Y0 g t
    e ℓ :
    𝒢
    Ybar P ℓ (S0_LE P e ℓ) = Ybar0 Y0 ℓ (S0_LE P e ℓ)
    Proof (Lean source)
    theorem Ybar_eq_Ybar0_late_on_S0_LE (hConsistency : ∀ g t, AdoptionPath.lt (P.A g) t → P.Y g t = Y0 g t) (e ℓ : 𝒢) : Ybar P ℓ (S0_LE P e ℓ) = Ybar0 Y0 ℓ (S0_LE P e ℓ) := by classical unfold Ybar Ybar0 congr 1 refine Finset.sum_congr rfl ?_ intro t ht have htmem : AdoptionPath.le (P.A e) t ∧ AdoptionPath.lt (P.A ℓ) t := by simpa only [S0_LE, S1_EL, mem_filter, Finset.mem_univ, true_and, Set.mem_ofPred_eq] using ht exact hConsistency ℓ t htmem.2
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.CausalAssumptions.Ybar_eq_Ybar0_late_on_S0_LE · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Causal.lean:281
  • Δ_TN_eq_ATT_totalized theorem — Under the packaged causal assumptions linking a cohort panel to never-treated and own-adoption potential-outcome paths, the totalized comparison of a treated and a never-treated cohort equals the treated cohort's totalized post-adoption window effect when their adoption dates are respectively finite and infinite.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    shared
    P :
    Y0 Y1 :
    𝒢 → Fin T → ℝ
    hA :
    g u :
    𝒢
    h_g_fin :
    AdoptionPath.isFinite (P.A g)
    h_u_inf :
    AdoptionPath.isInfinite (P.A u)
    Δ_TN P g u = ATT_window Y0 Y1 g (S1_TN P g)
    Proof (Lean source)
    theorem Δ_TN_eq_ATT_totalized (P : CohortPanel 𝒢 T) (Y0 Y1 : 𝒢 → Fin T → ℝ) (hA : CausalAssumptions P Y0 Y1) (g u : 𝒢) (h_g_fin : AdoptionPath.isFinite (P.A g)) (h_u_inf : AdoptionPath.isInfinite (P.A u)) : Δ_TN P g u = ATT_window Y0 Y1 g (S1_TN P g) := by classical have h_treated : Ybar P g (S1_TN P g) = Ybar0 Y0 g (S1_TN P g) + ATT_window Y0 Y1 g (S1_TN P g) := by exact CausalAssumptions.Ybar_eq_Ybar0_add_ATT_of_treated hA.consistencyTreated g (S1_TN P g) (by intro t ht simpa only [S1_TN, mem_filter, Finset.mem_univ, true_and, Set.mem_ofPred_eq] using ht) have h_g0 := CausalAssumptions.Ybar_eq_Ybar0_on_S0_TN hA.consistencyUntreated g have h_u1 := CausalAssumptions.Ybar_eq_Ybar0_of_inf hA.consistencyUntreated (S1_TN P g) (fun _ _ => AdoptionPath.lt_of_isInfinite h_u_inf) have h_u0 := CausalAssumptions.Ybar_eq_Ybar0_of_inf hA.consistencyUntreated (S0_TN P g) (fun _ _ => AdoptionPath.lt_of_isInfinite h_u_inf) have hPT := hA.parallelTrends_TN g u h_g_fin h_u_inf unfold Δ_TN rw [h_treated, h_g0, h_u1, h_u0] linarith
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.Δ_TN_eq_ATT_totalized · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Causal.lean:299
  • Δ_EL_eq_ATT_totalized theorem — Under the packaged causal assumptions linking a cohort panel to never-treated and own-adoption potential-outcome paths, the totalized comparison of an early and a late cohort equals the early cohort's totalized effect over the between-adoption window when the early cohort adopts first and the late cohort eventually adopts.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    shared
    P :
    Y0 Y1 :
    𝒢 → Fin T → ℝ
    hA :
    e ℓ :
    𝒢
    h_lt :
    P.A e < P.A ℓ
    h_ℓ_fin :
    AdoptionPath.isFinite (P.A ℓ)
    Δ_EL P e ℓ = ATT_window Y0 Y1 e (S1_EL P e ℓ)
    Proof (Lean source)
    theorem Δ_EL_eq_ATT_totalized (P : CohortPanel 𝒢 T) (Y0 Y1 : 𝒢 → Fin T → ℝ) (hA : CausalAssumptions P Y0 Y1) (e ℓ : 𝒢) (h_lt : P.A e < P.A ℓ) (h_ℓ_fin : AdoptionPath.isFinite (P.A ℓ)) : Δ_EL P e ℓ = ATT_window Y0 Y1 e (S1_EL P e ℓ) := by classical have h_e1 : Ybar P e (S1_EL P e ℓ) = Ybar0 Y0 e (S1_EL P e ℓ) + ATT_window Y0 Y1 e (S1_EL P e ℓ) := by exact CausalAssumptions.Ybar_eq_Ybar0_add_ATT_of_treated hA.consistencyTreated e (S1_EL P e ℓ) (by intro t ht have htmem : AdoptionPath.le (P.A e) t ∧ AdoptionPath.lt (P.A ℓ) t := by simpa only [S1_EL, mem_filter, Finset.mem_univ, true_and, Set.mem_ofPred_eq] using ht exact htmem.1) have h_e0 := CausalAssumptions.Ybar_eq_Ybar0_on_S0_EL hA.consistencyUntreated e have h_l1 := CausalAssumptions.Ybar_eq_Ybar0_late_on_S1_EL hA.consistencyUntreated e ℓ have h_l0 := CausalAssumptions.Ybar_eq_Ybar0_late_on_S0_EL hA.consistencyUntreated e ℓ h_lt have hPT := hA.parallelTrends_EL e ℓ h_lt h_ℓ_fin unfold Δ_EL rw [h_e1, h_e0, h_l1, h_l0] linarith
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.Δ_EL_eq_ATT_totalized · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Causal.lean:363
Algebraic­Decomposition 3 core · 11 supporting This file establishes the finite staggered-adoption Goodman-Bacon algebraic decomposition of a two-way fixed effects coefficient into admissible two-group comparisons. ★ weights_nonneg★ weights_sum_one★ twfe_eq_weighted_avg

Goodman-Bacon Decomposition

This file establishes the finite staggered-adoption Goodman-Bacon algebraic decomposition of a two-way fixed effects coefficient into admissible two-group comparisons. It proves nonnegativity of the raw comparison weights, the denominator and numerator identities, normalization of the weights under positive residualized-treatment variance, and the corresponding weighted-average identity.

theorem weights_nonneg reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

Prop A5.1 (weights_nonneg). For a cohort panel and any comparison-type index, the raw Goodman-Bacon comparison weight is nonnegative.

Formal statement
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
k :
CompTag × 𝒢 × 𝒢
0 ≤ lambdaWeight P k
Proof (Lean source)
theorem weights_nonneg (P : CohortPanel 𝒢 T) (k : CompTag × 𝒢 × 𝒢) : 0 ≤ lambdaWeight P k := by classical unfold lambdaWeight have hTpos : 0 < (T : ℝ) := by exact_mod_cast P.T_pos have hTnonneg : 0 ≤ (T : ℝ) := le_of_lt hTpos have hTne : (T : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt P.T_pos) have hbar_nonneg : ∀ g : 𝒢, 0 ≤ barD P g := by intro g unfold barD have hsum_nonneg : 0 ≤ ∑ t : Fin T, D P g t := by refine Finset.sum_nonneg' ?_ intro t by_cases hD : P.A g ≤ (t : WithTop (Fin T)) · simp [D, hD] · simp [D, hD] simpa using (mul_nonneg (inv_nonneg.mpr hTnonneg) hsum_nonneg) have hbar_le_one : ∀ g : 𝒢, barD P g ≤ 1 := by intro g unfold barD have hsum_le : ∑ t : Fin T, D P g t ≤ (T : ℝ) := by have hsum_le' : (∑ t : Fin T, D P g t) ≤ (∑ t : Fin T, (1 : ℝ)) := by refine Finset.sum_le_sum ?_ intro t ht by_cases hD : P.A g ≤ (t : WithTop (Fin T)) · simp [D, hD] · simp [D, hD] simpa using hsum_le' have hsum_le'' : (∑ t, D P g t) ≤ (T : ℝ) := by simpa using hsum_le have htmp : (T : ℝ)⁻¹ * (∑ t, D P g t) ≤ (T : ℝ)⁻¹ * (T : ℝ) := mul_le_mul_of_nonneg_left hsum_le'' (inv_nonneg.mpr hTnonneg) simpa [barD, inv_mul_cancel₀ hTne] using htmp by_cases h : admissible P k · simp only [h, if_true] rcases k with ⟨tag, g, u⟩ cases tag with | TN => rcases h with ⟨_, _, hpg, hpu⟩ have hmul : 0 ≤ (P.p g * P.p u) * (barD P g * (1 - barD P g)) := by exact mul_nonneg (mul_nonneg (le_of_lt hpg) (le_of_lt hpu)) (mul_nonneg (hbar_nonneg g) (sub_nonneg.mpr (hbar_le_one g))) simpa [lambdaTN, mul_assoc, mul_left_comm, mul_comm] using hmul | EL => rcases h with ⟨hlt, _, hpg, hpu⟩ have hbar_mono : barD P u ≤ barD P g := by unfold barD have hsum_le : (∑ t : Fin T, D P u t) ≤ (∑ t : Fin T, D P g t) := by refine Finset.sum_le_sum ?_ intro t ht by_cases htu : P.A u ≤ (t : WithTop (Fin T)) · have htg : P.A g ≤ (t : WithTop (Fin T)) := le_of_lt (lt_of_lt_of_le hlt htu) simp [D, htu, htg] · by_cases htg : P.A g ≤ (t : WithTop (Fin T)) · simp [D, htu, htg] · simp [D, htu, htg] have hsum_le' : (∑ t : Fin T, D P u t) ≤ (∑ t : Fin T, D P g t) := by simpa using hsum_le exact mul_le_mul_of_nonneg_left hsum_le' (inv_nonneg.mpr hTnonneg) have hq_nonneg : 0 ≤ q P g u := by unfold q exact sub_nonneg.mpr hbar_mono have hq_le_barD : q P g u ≤ barD P g := by unfold q nlinarith [hbar_mono, hbar_nonneg u] have hq_le_one : q P g u ≤ 1 := le_trans hq_le_barD (hbar_le_one g) have h1mq_nonneg : 0 ≤ 1 - q P g u := sub_nonneg.mpr hq_le_one have hmu_nonneg : 0 ≤ mu P g u := by unfold mu exact div_nonneg (sub_nonneg.mpr (hbar_le_one g)) h1mq_nonneg have hnum_le_den : 1 - barD P g ≤ 1 - q P g u := by have hlu_nonneg : 0 ≤ barD P u := hbar_nonneg u unfold q linarith have hmu_le_one : mu P g u ≤ 1 := by by_cases hden : 1 - q P g u = 0 · have hqeq : q P g u = 1 := by linarith simp [mu, hqeq] · have hden_pos : 0 < 1 - q P g u := lt_of_le_of_ne h1mq_nonneg (Ne.symm hden) have hdiv : (1 - barD P g) / (1 - q P g u) ≤ 1 := (div_le_one₀ hden_pos).2 hnum_le_den simpa [mu] using hdiv have h1m_nonneg : 0 ≤ 1 - mu P g u := sub_nonneg.mpr hmu_le_one have hmul : 0 ≤ P.p g * P.p u * (q P g u * (1 - q P g u) * mu P g u) := by have hmul1 : 0 ≤ P.p g * P.p u := mul_nonneg (le_of_lt hpg) (le_of_lt hpu) have hmul2 : 0 ≤ q P g u * (1 - q P g u) := mul_nonneg hq_nonneg h1mq_nonneg have hmul3 : 0 ≤ q P g u * (1 - q P g u) * mu P g u := mul_nonneg hmul2 hmu_nonneg exact mul_nonneg hmul1 hmul3 simpa [lambdaEL, mul_assoc, mul_left_comm, mul_comm] using hmul | LE => rcases h with ⟨hlt, _, hpg, hpu⟩ have hbar_mono : barD P u ≤ barD P g := by unfold barD have hsum_le : (∑ t : Fin T, D P u t) ≤ (∑ t : Fin T, D P g t) := by refine Finset.sum_le_sum ?_ intro t ht by_cases htu : P.A u ≤ (t : WithTop (Fin T)) · have htg : P.A g ≤ (t : WithTop (Fin T)) := le_of_lt (lt_of_lt_of_le hlt htu) simp [D, htu, htg] · by_cases htg : P.A g ≤ (t : WithTop (Fin T)) · simp [D, htu, htg] · simp [D, htu, htg] have hsum_le' : (∑ t : Fin T, D P u t) ≤ (∑ t : Fin T, D P g t) := by simpa using hsum_le exact mul_le_mul_of_nonneg_left hsum_le' (inv_nonneg.mpr hTnonneg) have hq_nonneg : 0 ≤ q P g u := by unfold q exact sub_nonneg.mpr hbar_mono have hq_le_barD : q P g u ≤ barD P g := by unfold q nlinarith [hbar_mono, hbar_nonneg u] have hq_le_one : q P g u ≤ 1 := le_trans hq_le_barD (hbar_le_one g) have h1mq_nonneg : 0 ≤ 1 - q P g u := sub_nonneg.mpr hq_le_one have hmu_nonneg : 0 ≤ mu P g u := by unfold mu exact div_nonneg (sub_nonneg.mpr (hbar_le_one g)) h1mq_nonneg have hnum_le_den : 1 - barD P g ≤ 1 - q P g u := by have hlu_nonneg : 0 ≤ barD P u := hbar_nonneg u unfold q linarith have hmu_le_one : mu P g u ≤ 1 := by by_cases hden : 1 - q P g u = 0 · have hqeq : q P g u = 1 := by linarith simp [mu, hqeq] · have hden_pos : 0 < 1 - q P g u := lt_of_le_of_ne h1mq_nonneg (Ne.symm hden) have hdiv : (1 - barD P g) / (1 - q P g u) ≤ 1 := by exact (div_le_one₀ hden_pos).2 hnum_le_den simpa [mu] using hdiv have h1m_nonneg : 0 ≤ 1 - mu P g u := sub_nonneg.mpr hmu_le_one have hmul : 0 ≤ P.p g * P.p u * (q P g u * (1 - q P g u) * (1 - mu P g u)) := by have hmul1 : 0 ≤ P.p g * P.p u := mul_nonneg (le_of_lt hpg) (le_of_lt hpu) have hmul2 : 0 ≤ q P g u * (1 - q P g u) := mul_nonneg hq_nonneg h1mq_nonneg have hmul3 : 0 ≤ q P g u * (1 - q P g u) * (1 - mu P g u) := mul_nonneg hmul2 h1m_nonneg exact mul_nonneg hmul1 hmul3 simpa [lambdaLE, mul_assoc, mul_left_comm, mul_comm] using hmul · simp [h]
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.weights_nonneg · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/AlgebraicDecomposition.lean:61 · uses CohortPanel , CompTag , lambdaWeight
theorem weights_sum_one reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

Prop A5.4 (weights_sum_one). For a finite Goodman–Bacon cohort panel P, if the residualized-treatment variance VD P is strictly positive, then the normalized comparison weights sum to one over all admissible 2×2 comparisons: Σ_{k ∈ 𝒦 P} weight P k = 1.

Formal statement
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
hVD_pos :
0 < VD P
∑ k ∈ 𝒦 P, weight P k = 1
Proof (Lean source)
theorem weights_sum_one (P : CohortPanel 𝒢 T) (hVD_pos : 0 < VD P) : ∑ k ∈ 𝒦 P, weight P k = 1 := by classical have hL_ne : Lambda P ≠ 0 := by rw [raw_weight_sum_eq_VD P] exact ne_of_gt hVD_pos have hsum_lambda : ∑ k ∈ 𝒦 P, lambdaWeight P k = Lambda P := by exact sum_lambdaWeight_eq_Lambda P calc ∑ k ∈ 𝒦 P, weight P k = ∑ k ∈ 𝒦 P, lambdaWeight P k / Lambda P := by refine Finset.sum_congr rfl ?_ intro k hk have hk' : admissible P k := by simpa [𝒦] using hk rcases k with ⟨tag, pair⟩ rcases pair with ⟨g, u⟩ cases tag <;> simp [weight, lambdaWeight, w_TN, w_EL, w_LE, hk'] _ = (∑ k ∈ 𝒦 P, lambdaWeight P k) / Lambda P := by simp [div_eq_mul_inv, Finset.mul_sum, mul_comm] _ = Lambda P / Lambda P := by rw [hsum_lambda] _ = 1 := by exact div_self hL_ne
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.weights_sum_one · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/AlgebraicDecomposition.lean:661 · uses CohortPanel , CompTag , VD , weight , 𝒦
theorem twfe_eq_weighted_avg reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

Theorem A5.5 (twfe_eq_weighted_avg, thm:po-estimand-goodman-bacon-decomposition). For a cohort panel whose residualized-treatment variance is strictly positive, the two-way fixed-effects (TWFE) coefficient equals a weighted average of admissible two-by-two DID contrasts across comparison groups. The positivity condition makes the normalized weights sum to one by weights_sum_one.

Formal statement
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
hVD_pos :
0 < VD P
betaTWFE P = ∑ k ∈ 𝒦 P, weight P k * contrast P k
Proof (Lean source)
theorem twfe_eq_weighted_avg (P : CohortPanel 𝒢 T) (hVD_pos : 0 < VD P) : betaTWFE P = ∑ k ∈ 𝒦 P, weight P k * contrast P k := twfe_eq_normalized_comparison_sum P
11 supporting declarations (lemmas, instances)
  • barD_eq_zero_of_isInf lemma — A never-treated cohort has zero average treatment over the panel.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    shared
    P :
    g :
    𝒢
    hg :
    AdoptionPath.isInfinite (P.A g)
    barD P g = 0
    Proof (Lean source)
    lemma barD_eq_zero_of_isInf (P : CohortPanel 𝒢 T) {g : 𝒢} (hg : AdoptionPath.isInfinite (P.A g)) : barD P g = 0 := by unfold barD simp [D_eq_zero_of_isInf P hg]
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.barD_eq_zero_of_isInf · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/AlgebraicDecomposition.lean:206
  • lambdaTN_eq_gap_of_isInf lemma — When one cohort is never treated, its raw comparison weight with another cohort equals the product of their cohort shares, the gap in their average treatment rates, and one minus that gap.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    shared
    P :
    g u :
    𝒢
    hu :
    AdoptionPath.isInfinite (P.A u)
    lambdaTN P g u = P.p g * P.p u * q P g u * (1 - q P g u)
    Proof (Lean source)
    lemma lambdaTN_eq_gap_of_isInf (P : CohortPanel 𝒢 T) {g u : 𝒢} (hu : AdoptionPath.isInfinite (P.A u)) : lambdaTN P g u = P.p g * P.p u * q P g u * (1 - q P g u) := by unfold lambdaTN q rw [barD_eq_zero_of_isInf P hu] ring
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.lambdaTN_eq_gap_of_isInf · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/AlgebraicDecomposition.lean:213
  • lambdaEL_add_lambdaLE_eq_gap lemma — The two ordered raw comparison weights between two cohorts sum to the product of their cohort shares, the gap in their average treatment rates, and one minus that gap.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    shared
    P :
    e ℓ :
    𝒢
    lambdaEL P e ℓ + lambdaLE P e ℓ = P.p e * P.p ℓ * q P e ℓ * (1 - q P e ℓ)
    Proof (Lean source)
    lemma lambdaEL_add_lambdaLE_eq_gap (P : CohortPanel 𝒢 T) (e ℓ : 𝒢) : lambdaEL P e ℓ + lambdaLE P e ℓ = P.p e * P.p ℓ * q P e ℓ * (1 - q P e ℓ) := by unfold lambdaEL lambdaLE ring
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.lambdaEL_add_lambdaLE_eq_gap · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/AlgebraicDecomposition.lean:223
  • Lambda_eq_gap_sums lemma — The raw denominator of the staggered-adoption two-way fixed-effects decomposition equals the sum of treated-versus-never comparison terms and ordered early-versus-late comparison terms.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    shared
    P :
    = (∑ g, ∑ u, if AdoptionPath.isFinite (P.A g) ∧ AdoptionPath.isInfinite (P.A u) then P.p g * P.p u * q P g u * (1 - q P g u) else 0)
    + (∑ e, ∑ ℓ, if P.A e < P.A ℓ ∧ AdoptionPath.isFinite (P.A ℓ) then P.p e * P.p ℓ * q P e ℓ * (1 - q P e ℓ) else 0)
    Proof (Lean source)
    lemma Lambda_eq_gap_sums (P : CohortPanel 𝒢 T) : Lambda P = (∑ g, ∑ u, if AdoptionPath.isFinite (P.A g) ∧ AdoptionPath.isInfinite (P.A u) then P.p g * P.p u * q P g u * (1 - q P g u) else 0) + (∑ e, ∑ ℓ, if P.A e < P.A ℓ ∧ AdoptionPath.isFinite (P.A ℓ) then P.p e * P.p ℓ * q P e ℓ * (1 - q P e ℓ) else 0) := by unfold Lambda congr 1 · refine Finset.sum_congr rfl ?_ intro g _hg refine Finset.sum_congr rfl ?_ intro u _hu by_cases h : P.A g ≠ ⊤ ∧ P.A u = ⊤ · simp [AdoptionPath.isFinite, AdoptionPath.isInfinite, h, lambdaTN_eq_gap_of_isInf P h.2] · simp [AdoptionPath.isFinite, AdoptionPath.isInfinite, h] · refine Finset.sum_congr rfl ?_ intro e _he refine Finset.sum_congr rfl ?_ intro ℓ _hℓ by_cases h : P.A e < P.A ℓ ∧ P.A ℓ ≠ ⊤ · simp [AdoptionPath.isFinite, h, lambdaEL_add_lambdaLE_eq_gap P e ℓ] · simp [AdoptionPath.isFinite, h]
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.Lambda_eq_gap_sums · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/AlgebraicDecomposition.lean:233
  • D_eq_of_A_eq lemma — Cohorts that share the same adoption date have identical treatment status in every time period.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    shared
    P :
    g u :
    𝒢
    hA :
    P.A g = P.A u
    t :
    Fin T
    D P g t = D P u t
    Proof (Lean source)
    lemma D_eq_of_A_eq (P : CohortPanel 𝒢 T) {g u : 𝒢} (hA : P.A g = P.A u) (t : Fin T) : D P g t = D P u t := by unfold D rw [hA]
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.D_eq_of_A_eq · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/AlgebraicDecomposition.lean:261
  • adoption_pair_sum_decomp lemma — When a pairwise cohort contribution is zero for cohorts sharing an adoption date, its total over all cohort pairs decomposes into the four possible ordered timing comparisons.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    shared
    P :
    f :
    𝒢 → 𝒢 → ℝ
    hzero :
    ∀ g u
    if
    P.A g = P.A u
    then
    f g u = 0
    (∑ g, ∑ u, f g u)
    = (∑ g, ∑ u, if AdoptionPath.isFinite (P.A g) ∧ AdoptionPath.isInfinite (P.A u) then f g u else 0)
    + (∑ g, ∑ u, if AdoptionPath.isFinite (P.A u) ∧ AdoptionPath.isInfinite (P.A g) then f g u else 0)
    + (∑ g, ∑ u, if P.A g < P.A u ∧ AdoptionPath.isFinite (P.A u) then f g u else 0)
    + (∑ g, ∑ u, if P.A u < P.A g ∧ AdoptionPath.isFinite (P.A g) then f g u else 0)
    Proof (Lean source)
    lemma adoption_pair_sum_decomp (P : CohortPanel 𝒢 T) (f : 𝒢 → 𝒢 → ℝ) (hzero : ∀ g u, P.A g = P.A u → f g u = 0) : (∑ g, ∑ u, f g u) = (∑ g, ∑ u, if AdoptionPath.isFinite (P.A g) ∧ AdoptionPath.isInfinite (P.A u) then f g u else 0) + (∑ g, ∑ u, if AdoptionPath.isFinite (P.A u) ∧ AdoptionPath.isInfinite (P.A g) then f g u else 0) + (∑ g, ∑ u, if P.A g < P.A u ∧ AdoptionPath.isFinite (P.A u) then f g u else 0) + (∑ g, ∑ u, if P.A u < P.A g ∧ AdoptionPath.isFinite (P.A g) then f g u else 0) := by calc (∑ g, ∑ u, f g u) = ∑ g, ∑ u, ((if AdoptionPath.isFinite (P.A g) ∧ AdoptionPath.isInfinite (P.A u) then f g u else 0) + (if AdoptionPath.isFinite (P.A u) ∧ AdoptionPath.isInfinite (P.A g) then f g u else 0) + (if P.A g < P.A u ∧ AdoptionPath.isFinite (P.A u) then f g u else 0) + (if P.A u < P.A g ∧ AdoptionPath.isFinite (P.A g) then f g u else 0)) := by refine Finset.sum_congr rfl ?_ intro g _hg refine Finset.sum_congr rfl ?_ intro u _hu exact adoption_pair_pointwise P f hzero g u _ = _ := by simp [Finset.sum_add_distrib, add_assoc]
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.adoption_pair_sum_decomp · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/AlgebraicDecomposition.lean:378
  • gap_sums_eq_VD lemma — The total of cohort-share products times each pair's treatment-rate gap and one minus that gap, over treated-versus-never and ordered early-versus-later pairs, equals the residualized treatment variance.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    shared
    P :
    (∑ g, ∑ u, if AdoptionPath.isFinite (P.A g) ∧ AdoptionPath.isInfinite (P.A u) then P.p g * P.p u * q P g u * (1 - q P g u) else 0)
    + (∑ e, ∑ ℓ, if P.A e < P.A ℓ ∧ AdoptionPath.isFinite (P.A ℓ) then P.p e * P.p ℓ * q P e ℓ * (1 - q P e ℓ) else 0)
    = VD P
    Proof (Lean source)
    lemma gap_sums_eq_VD (P : CohortPanel 𝒢 T) : (∑ g, ∑ u, if AdoptionPath.isFinite (P.A g) ∧ AdoptionPath.isInfinite (P.A u) then P.p g * P.p u * q P g u * (1 - q P g u) else 0) + (∑ e, ∑ ℓ, if P.A e < P.A ℓ ∧ AdoptionPath.isFinite (P.A ℓ) then P.p e * P.p ℓ * q P e ℓ * (1 - q P e ℓ) else 0) = VD P := by -- Remaining denominator algebra: expand `VD`, use `P.p_sum_one`, and group -- the pairwise variance of monotone adoption indicators by adoption-date -- order. This is the finite-sum manipulation described in the NL A5.2 doc. rw [VD_eq_pairwise_centeredD P] rw [adoption_pair_sum_grouped P (vdPairContribution P) (fun g u hA => vdPairContribution_eq_zero_of_A_eq P hA)] congr 1 · refine Finset.sum_congr rfl ?_ intro g _hg refine Finset.sum_congr rfl ?_ intro u _hu by_cases h : P.A g ≠ ⊤ ∧ P.A u = ⊤ · simp [AdoptionPath.isFinite, AdoptionPath.isInfinite, h, TN_pair_vd_contribution_eq_gap P h.2] · simp [AdoptionPath.isFinite, AdoptionPath.isInfinite, h] · refine Finset.sum_congr rfl ?_ intro e _he refine Finset.sum_congr rfl ?_ intro ℓ _hℓ by_cases h : P.A e < P.A ℓ ∧ P.A ℓ ≠ ⊤ · simp [AdoptionPath.isFinite, h, TT_pair_vd_contribution_eq_gap P h.1] · simp [AdoptionPath.isFinite, h]
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.gap_sums_eq_VD · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/AlgebraicDecomposition.lean:500
  • raw_weight_sum_eq_VD theorem — Prop A5.2 (raw_weight_sum_eq_VD). The aggregate raw-weight denominator equals the residualized treatment variance: Λ P = V_D P. Key denominator identity in thm:po-estimand-goodman-bacon-decomposition.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    shared
    P :
    Lambda P = VD P
    Proof (Lean source)
    theorem raw_weight_sum_eq_VD (P : CohortPanel 𝒢 T) : Lambda P = VD P := by rw [Lambda_eq_gap_sums] exact gap_sums_eq_VD P
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.raw_weight_sum_eq_VD · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/AlgebraicDecomposition.lean:533
  • twfe_numerator_eq_lambda_delta_sum theorem — Prop A5.3 (twfe_numerator_eq_lambda_delta_sum). The TWFE numerator decomposes by unordered cohort pairs into raw-weight times 2x2 DID contrast contributions.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    shared
    P :
    (∑ g, ∑ t, (P.p g / (T : ℝ)) * Dtilde P g t * P.Y g t)
    = (∑ g, ∑ u, if AdoptionPath.isFinite (P.A g) ∧ AdoptionPath.isInfinite (P.A u) then lambdaTN P g u * Δ_TN P g u else 0)
    + (∑ e, ∑ ℓ, if P.A e < P.A ℓ ∧ AdoptionPath.isFinite (P.A ℓ) then lambdaEL P e ℓ * Δ_EL P e ℓ + lambdaLE P e ℓ * Δ_LE P e ℓ else 0)
    Proof (Lean source)
    theorem twfe_numerator_eq_lambda_delta_sum (P : CohortPanel 𝒢 T) : (∑ g, ∑ t, (P.p g / (T : ℝ)) * Dtilde P g t * P.Y g t) = (∑ g, ∑ u, if AdoptionPath.isFinite (P.A g) ∧ AdoptionPath.isInfinite (P.A u) then lambdaTN P g u * Δ_TN P g u else 0) + (∑ e, ∑ ℓ, if P.A e < P.A ℓ ∧ AdoptionPath.isFinite (P.A ℓ) then lambdaEL P e ℓ * Δ_EL P e ℓ + lambdaLE P e ℓ * Δ_LE P e ℓ else 0) := by rw [twfe_numerator_eq_pairwise_centeredD_Y P] rw [adoption_pair_sum_grouped P (numPairContribution P) (fun g u hA => numPairContribution_eq_zero_of_A_eq P hA)] congr 1 · refine Finset.sum_congr rfl ?_ intro g _hg refine Finset.sum_congr rfl ?_ intro u _hu by_cases h : P.A g ≠ ⊤ ∧ P.A u = ⊤ · simp [AdoptionPath.isFinite, AdoptionPath.isInfinite, h, TN_pair_contribution_eq_lambda_delta P h.1 h.2] · simp [AdoptionPath.isFinite, AdoptionPath.isInfinite, h] · refine Finset.sum_congr rfl ?_ intro e _he refine Finset.sum_congr rfl ?_ intro ℓ _hℓ by_cases h : P.A e < P.A ℓ ∧ P.A ℓ ≠ ⊤ · simp [AdoptionPath.isFinite, h, TT_pair_contribution_eq_lambda_delta_sum P h.1 h.2] · simp [AdoptionPath.isFinite, h]
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.twfe_numerator_eq_lambda_delta_sum · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/AlgebraicDecomposition.lean:543
  • sum_lambdaWeight_eq_Lambda lemma — Across all admissible comparison types and cohort pairs, the raw comparison weights sum to the aggregate normalizing denominator.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    shared
    P :
    ∑ k ∈ 𝒦 P, lambdaWeight P k = Lambda P
    Proof (Lean source)
    lemma sum_lambdaWeight_eq_Lambda (P : CohortPanel 𝒢 T) : ∑ k ∈ 𝒦 P, lambdaWeight P k = Lambda P := by classical rw [show (∑ k ∈ 𝒦 P, lambdaWeight P k) = ∑ k, if admissible P k then lambdaWeight P k else 0 by simp [𝒦, Finset.sum_filter]] rw [Fintype.sum_prod_type] rw [sum_compTag] simp only [lambdaWeight, admissible, P.p_pos, true_and] simp_rw [if_dup] simp_rw [Fintype.sum_prod_type] simp only [and_true] have hELLE : (∑ e, ∑ ℓ, if P.A e < P.A ℓ ∧ AdoptionPath.isFinite (P.A ℓ) then lambdaEL P e ℓ else 0) + (∑ e, ∑ ℓ, if P.A e < P.A ℓ ∧ AdoptionPath.isFinite (P.A ℓ) then lambdaLE P e ℓ else 0) = ∑ e, ∑ ℓ, if P.A e < P.A ℓ ∧ AdoptionPath.isFinite (P.A ℓ) then lambdaEL P e ℓ + lambdaLE P e ℓ else 0 := by rw [← Finset.sum_add_distrib] refine Finset.sum_congr rfl ?_ intro e he rw [← Finset.sum_add_distrib] refine Finset.sum_congr rfl ?_ intro ℓ hℓ by_cases h : P.A e < P.A ℓ ∧ P.A ℓ ≠ ⊤ <;> simp [AdoptionPath.isFinite, h] unfold Lambda rw [← hELLE] rw [add_assoc]
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.sum_lambdaWeight_eq_Lambda · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/AlgebraicDecomposition.lean:591
  • twfe_eq_normalized_comparison_sum theorem — For a cohort panel, the totalized TWFE ratio equals the totalized normalized sum of admissible two-by-two DID contrasts, including in zero-variance cases.
    𝒢 :
    Type u_1
    shared
    T :
    ℕ
    shared
    P :
    betaTWFE P = ∑ k ∈ 𝒦 P, weight P k * contrast P k
    Proof (Lean source)
    theorem twfe_eq_normalized_comparison_sum (P : CohortPanel 𝒢 T) : betaTWFE P = ∑ k ∈ 𝒦 P, weight P k * contrast P k := by classical have hnum := twfe_numerator_eq_lambda_delta_sum P have hsum : ∑ k ∈ 𝒦 P, lambdaWeight P k * contrast P k = (∑ g, ∑ u, if AdoptionPath.isFinite (P.A g) ∧ AdoptionPath.isInfinite (P.A u) then lambdaTN P g u * Δ_TN P g u else 0) + (∑ e, ∑ ℓ, if P.A e < P.A ℓ ∧ AdoptionPath.isFinite (P.A ℓ) then lambdaEL P e ℓ * Δ_EL P e ℓ + lambdaLE P e ℓ * Δ_LE P e ℓ else 0) := sum_lambdaWeight_mul_contrast_eq P have hweighted : ∑ k ∈ 𝒦 P, weight P k * contrast P k = (∑ k ∈ 𝒦 P, lambdaWeight P k * contrast P k) / Lambda P := by rw [Finset.sum_div] refine Finset.sum_congr rfl ?_ intro k hk have hk' : admissible P k := by simpa [𝒦] using hk rcases k with ⟨tag, pair⟩ rcases pair with ⟨g, u⟩ cases tag <;> simp [weight, lambdaWeight, w_TN, w_EL, w_LE, hk', div_eq_mul_inv, mul_left_comm, mul_comm] calc betaTWFE P = ((∑ k ∈ 𝒦 P, lambdaWeight P k * contrast P k) / Lambda P) := by unfold betaTWFE rw [hnum] rw [← hsum] rw [← raw_weight_sum_eq_VD P] _ = ∑ k ∈ 𝒦 P, weight P k * contrast P k := by rw [hweighted]
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.twfe_eq_normalized_comparison_sum · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/AlgebraicDecomposition.lean:687
Causal­Decomposition 2 core · 1 supporting This file composes the algebraic TWFE totalized weighted-sum identity with the causal window-effect equalities, expressing the two-way fixed-effect coefficient as a sum of normalized comparison weights times potential-ou ★ twfe_po_decomposition

Goodman-Bacon fused causal decomposition

This file composes the algebraic TWFE totalized weighted-sum identity with the causal window-effect equalities, expressing the two-way fixed-effect coefficient as a sum of normalized comparison weights times potential-outcome window contrasts, with the late-versus-early bad-comparison term made explicit. TN and EL entries with empty pre-treatment windows are zero-weight bookkeeping terms, not standalone DID identification results. A weighted-average interpretation requires the separate positive-variance condition used by weights_sum_one.

def contrastCausal reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a finite collection of cohorts whose members can be compared for equality, a natural-number panel length, a cohort panel, two potential-outcome paths, respectively under no treatment and under treatment at the cohort's own adoption date, and a labelled ordered pair of cohorts, the causal two-by-two contrast is zero when that comparison is inadmissible; otherwise, it is the relevant window average treatment effect for a treated-versus-never-treated or early-versus-late comparison, and for a late-versus-early comparison it is the late cohort's window average treatment effect minus the early cohort's corresponding treated-period effect net of its pre-period effect.

Definition (Lean source)
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
Y0 Y1 :
𝒢 → Fin T → ℝ
k :
CompTag × 𝒢 × 𝒢
contrastCausal P Y0 Y1 k :
ℝ
if admissible P k then match k.1 with | CompTag.TN
=> ATT_window Y0 Y1 k.2.1 (S1_TN P k.2.1) | CompTag.EL => ATT_window Y0 Y1 k.2.1 (S1_EL P k.2.1 k.2.2) | CompTag.LE => ATT_window Y0 Y1 k.2.2 (S1_LE P k.2.2)
- (ATT_window Y0 Y1 k.2.1 (S1_LE P k.2.2) - ATT_window Y0 Y1 k.2.1 (S0_LE P k.2.1 k.2.2)) else 0
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.contrastCausal · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/CausalDecomposition.lean:52 · uses CohortPanel , CompTag
theorem twfe_po_decomposition reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

Fused causal Goodman-Bacon decomposition. Fix a cohort panel P and potential-outcome maps Y0 (never-treated path) and Y1 (own-adoption-date path). Assume consistency on treated and untreated cells, no anticipation, and pairwise untreated parallel trends across the treated-versus-never, early-versus-late, and late-versus-early comparison types; then the two-way fixed-effects coefficient betaTWFE P equals the sum, over admissible pairwise comparisons, of each comparison's Goodman-Bacon weight times its potential-outcome window contrast — the treated-versus-never and early-versus-late window-specific ATTs, or the late-versus-early bad-comparison adjustment.

Formal statement
𝒢 :
Type u_1
shared
T :
ℕ
shared
P :
Y0 Y1 :
𝒢 → Fin T → ℝ
hA :
betaTWFE P = ∑ k ∈ 𝒦 P, weight P k * contrastCausal P Y0 Y1 k
Proof (Lean source)
theorem twfe_po_decomposition (P : CohortPanel 𝒢 T) (Y0 Y1 : 𝒢 → Fin T → ℝ) (hA : CausalAssumptions P Y0 Y1) : betaTWFE P = ∑ k ∈ 𝒦 P, weight P k * contrastCausal P Y0 Y1 k := by rw [twfe_eq_normalized_comparison_sum P] refine Finset.sum_congr rfl ?_ intro k hk have hk' : admissible P k := by simpa [𝒦] using hk rw [contrast_eq_contrastCausal P Y0 Y1 hA hk']
1 supporting declaration (lemmas, instances)
Population­Bridge 3 core · 0 supporting This file states a conditional transport bridge from a probability-space panel model to the finite Goodman-Bacon cohort-period algebra. ★ bridge_Dtilde_sq_eq_VD_of_residual_compatibility★ bridge_VD_pos_iff_Dtilde_sq_pos_of_residual_compatibility★ bridge_finite_residualized_eq_twfe_of_residual_compatibility

Goodman-Bacon Measure-Theoretic Bridge

This file states a conditional transport bridge from a probability-space panel model to the finite Goodman-Bacon cohort-period algebra. It assumes explicit compatibility between the population and finite residualized treatments; it does not derive that compatibility from an observed staggered-adoption path. Under that premise and the balanced cohort-period law, it identifies the population residualized coefficient with the finite-cell TWFE coefficient.

theorem bridge_Dtilde_sq_eq_VD_of_residual_compatibility reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

The population second moment of residualized treatment equals the corresponding finite cohort-period denominator for a probability law with treatment and outcome variables, cohort and period labels, and an adoption schedule, provided the labels and treatment are measurable, treatment is binary almost everywhere, the cohort-period law is balanced, there is at least one period, cohort masses are positive and sum to one, each cohort's mass is uniform across periods, treatment is constant at its mean within every cell, and population and finite residualized treatments agree in every cell.

Formal statement
Ω :
Type u_1
shared
𝒢 :
Type u_2
shared
T :
ℕ
shared
D Y :
Ω → ℝ
G :
Ω → 𝒢
T_rv :
Ω → Fin T
A :
𝒢 → WithTop (Fin T)
G_meas :
T_meas :
D_meas :
D_binary :
∀ᵐ ω ∂μ, D ω = 0 ∨ D ω = 1
B_balanced :
hT_pos :
0 < T
hp_pos :
∀ g, 0 < cohortMass μ G g
hp_sum :
∑ g, cohortMass μ G g = 1
hLaw :
∀ g t, cellMass μ G T_rv g t = cohortMass μ G g / (T : ℝ)
hD_cell :
∀ g t,
∀ᵐ ω ∂μ.restrict {ω' | G ω' = g ∧ T_rv ω' = t}, D ω
= (∫ ω', D ω' * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω' ∂μ) / cellMass μ G T_rv g t
hDtilde_eq :
∀ g t, panelDtilde μ D G T_rv g t = Dtilde (panelOf μ Y G T_rv A hT_pos hp_pos hp_sum) g t
(∫ ω, (residWitnessD_panel μ D G T_rv G_meas T_meas D_meas D_binary B_balanced).Vtilde ω * (residWitnessD_panel μ D G T_rv G_meas T_meas D_meas D_binary B_balanced).Vtilde ω ∂μ)
= VD (panelOf μ Y G T_rv A hT_pos hp_pos hp_sum)
Proof (Lean source)
theorem bridge_Dtilde_sq_eq_VD_of_residual_compatibility (μ : Measure Ω) [IsProbabilityMeasure μ] (D Y : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (A : 𝒢 → WithTop (Fin T)) (G_meas : Measurable G) (T_meas : Measurable T_rv) (D_meas : Measurable D) (D_binary : ∀ᵐ ω ∂μ, D ω = 0 ∨ D ω = 1) (B_balanced : IsBalancedPanelLaw μ G T_rv) (hT_pos : 0 < T) (hp_pos : ∀ g, 0 < cohortMass μ G g) (hp_sum : ∑ g, cohortMass μ G g = 1) (hLaw : ∀ g t, cellMass μ G T_rv g t = cohortMass μ G g / (T : ℝ)) (hD_cell : ∀ g t, ∀ᵐ ω ∂μ.restrict {ω' | G ω' = g ∧ T_rv ω' = t}, D ω = (∫ ω', D ω' * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω' ∂μ) / cellMass μ G T_rv g t) (hDtilde_eq : ∀ g t, panelDtilde μ D G T_rv g t = Dtilde (panelOf μ Y G T_rv A hT_pos hp_pos hp_sum) g t) : (∫ ω, (residWitnessD_panel μ D G T_rv G_meas T_meas D_meas D_binary B_balanced).Vtilde ω * (residWitnessD_panel μ D G T_rv G_meas T_meas D_meas D_binary B_balanced).Vtilde ω ∂μ) = VD (panelOf μ Y G T_rv A hT_pos hp_pos hp_sum) := by let wD := residWitnessD_panel μ D G T_rv G_meas T_meas D_meas D_binary B_balanced let P := panelOf μ Y G T_rv A hT_pos hp_pos hp_sum have hDen_sum : ∫ ω, wD.Vtilde ω * wD.Vtilde ω ∂μ = ∑ g, ∑ t, cellMass μ G T_rv g t * (panelDtilde μ D G T_rv g t)^2 := by have hF_int : Integrable (fun ω => wD.Vtilde ω * wD.Vtilde ω) μ := wD.Vtilde_memLp.integrable_mul wD.Vtilde_memLp calc ∫ ω, wD.Vtilde ω * wD.Vtilde ω ∂μ = ∑ g, ∑ t, ∫ ω, (wD.Vtilde ω * wD.Vtilde ω) * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ := integral_eq_sum_panel_cell μ (fun ω => wD.Vtilde ω * wD.Vtilde ω) G T_rv G_meas T_meas hF_int _ = ∑ g, ∑ t, cellMass μ G T_rv g t * (panelDtilde μ D G T_rv g t)^2 := by refine Finset.sum_congr rfl (fun g _ => ?_) refine Finset.sum_congr rfl (fun t _ => ?_) simpa [wD, residWitnessD_panel, mul_assoc] using denom_per_cell_panel μ D G T_rv G_meas T_meas g t (hD_cell g t) calc ∫ ω, (residWitnessD_panel μ D G T_rv G_meas T_meas D_meas D_binary B_balanced).Vtilde ω * (residWitnessD_panel μ D G T_rv G_meas T_meas D_meas D_binary B_balanced).Vtilde ω ∂μ = ∫ ω, wD.Vtilde ω * wD.Vtilde ω ∂μ := by rfl _ = ∑ g, ∑ t, cellMass μ G T_rv g t * (panelDtilde μ D G T_rv g t)^2 := hDen_sum _ = VD P := by simp [P, panelOf, VD, hLaw, hDtilde_eq]
theorem bridge_VD_pos_iff_Dtilde_sq_pos_of_residual_compatibility reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

Positivity of the finite-panel treatment denominator is equivalent to positivity of the population residualized-treatment second moment for a probability law with treatment and outcome variables, cohort and period labels, and an adoption schedule, provided the labels and treatment are measurable, treatment is binary almost everywhere, the cohort-period law is balanced, there is at least one period, cohort masses are positive and sum to one, each cohort's mass is uniform across periods, treatment is constant at its mean within every cell, and population and finite residualized treatments agree in every cell.

Formal statement
Ω :
Type u_1
shared
𝒢 :
Type u_2
shared
T :
ℕ
shared
D Y :
Ω → ℝ
G :
Ω → 𝒢
T_rv :
Ω → Fin T
A :
𝒢 → WithTop (Fin T)
G_meas :
T_meas :
D_meas :
D_binary :
∀ᵐ ω ∂μ, D ω = 0 ∨ D ω = 1
B_balanced :
hT_pos :
0 < T
hp_pos :
∀ g, 0 < cohortMass μ G g
hp_sum :
∑ g, cohortMass μ G g = 1
hLaw :
∀ g t, cellMass μ G T_rv g t = cohortMass μ G g / (T : ℝ)
hD_cell :
∀ g t,
∀ᵐ ω ∂μ.restrict {ω' | G ω' = g ∧ T_rv ω' = t}, D ω
= (∫ ω', D ω' * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω' ∂μ) / cellMass μ G T_rv g t
hDtilde_eq :
∀ g t, panelDtilde μ D G T_rv g t = Dtilde (panelOf μ Y G T_rv A hT_pos hp_pos hp_sum) g t
0 < VD (panelOf μ Y G T_rv A hT_pos hp_pos hp_sum)
↔ 0 < ∫ ω, (residWitnessD_panel μ D G T_rv G_meas T_meas D_meas D_binary B_balanced).Vtilde ω * (residWitnessD_panel μ D G T_rv G_meas T_meas D_meas D_binary B_balanced).Vtilde ω ∂μ
Proof (Lean source)
theorem bridge_VD_pos_iff_Dtilde_sq_pos_of_residual_compatibility (μ : Measure Ω) [IsProbabilityMeasure μ] (D Y : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (A : 𝒢 → WithTop (Fin T)) (G_meas : Measurable G) (T_meas : Measurable T_rv) (D_meas : Measurable D) (D_binary : ∀ᵐ ω ∂μ, D ω = 0 ∨ D ω = 1) (B_balanced : IsBalancedPanelLaw μ G T_rv) (hT_pos : 0 < T) (hp_pos : ∀ g, 0 < cohortMass μ G g) (hp_sum : ∑ g, cohortMass μ G g = 1) (hLaw : ∀ g t, cellMass μ G T_rv g t = cohortMass μ G g / (T : ℝ)) (hD_cell : ∀ g t, ∀ᵐ ω ∂μ.restrict {ω' | G ω' = g ∧ T_rv ω' = t}, D ω = (∫ ω', D ω' * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω' ∂μ) / cellMass μ G T_rv g t) (hDtilde_eq : ∀ g t, panelDtilde μ D G T_rv g t = Dtilde (panelOf μ Y G T_rv A hT_pos hp_pos hp_sum) g t) : 0 < VD (panelOf μ Y G T_rv A hT_pos hp_pos hp_sum) ↔ 0 < ∫ ω, (residWitnessD_panel μ D G T_rv G_meas T_meas D_meas D_binary B_balanced).Vtilde ω * (residWitnessD_panel μ D G T_rv G_meas T_meas D_meas D_binary B_balanced).Vtilde ω ∂μ := by rw [bridge_Dtilde_sq_eq_VD_of_residual_compatibility μ D Y G T_rv A G_meas T_meas D_meas D_binary B_balanced hT_pos hp_pos hp_sum hLaw hD_cell hDtilde_eq]
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.bridge_VD_pos_iff_Dtilde_sq_pos_of_residual_compatibility · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/PopulationBridge.lean:132 · uses Dtilde , IsBalancedPanelLaw , VD , cellMass , cohortMass , panelClass , panelDtilde , panelOf , residWitnessD_panel
theorem bridge_finite_residualized_eq_twfe_of_residual_compatibility reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

The population coefficient from residualizing treatment and outcome on cohort and period effects equals the induced finite-panel TWFE coefficient for a probability law with treatment and outcome variables, cohort and period labels, and an adoption schedule, provided the labels and treatment are measurable, treatment is binary almost everywhere, the outcome is square-integrable, the cohort-period law is balanced, there is at least one period, cohort masses are positive and sum to one, each cohort's mass is uniform across periods, treatment is constant at its mean within every cell, and population and finite residualized treatments agree in every cell.

Formal statement
Ω :
Type u_1
shared
𝒢 :
Type u_2
shared
T :
ℕ
shared
D Y :
Ω → ℝ
G :
Ω → 𝒢
T_rv :
Ω → Fin T
A :
𝒢 → WithTop (Fin T)
G_meas :
T_meas :
D_meas :
D_binary :
∀ᵐ ω ∂μ, D ω = 0 ∨ D ω = 1
Y_memLp :
MemLp Y 2 μ
B_balanced :
hT_pos :
0 < T
hp_pos :
∀ g, 0 < cohortMass μ G g
hp_sum :
∑ g, cohortMass μ G g = 1
hLaw :
∀ g t, cellMass μ G T_rv g t = cohortMass μ G g / (T : ℝ)
hD_cell :
∀ g t,
∀ᵐ ω ∂μ.restrict {ω' | G ω' = g ∧ T_rv ω' = t}, D ω
= (∫ ω', D ω' * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω' ∂μ) / cellMass μ G T_rv g t
hDtilde_eq :
∀ g t, panelDtilde μ D G T_rv g t = Dtilde (panelOf μ Y G T_rv A hT_pos hp_pos hp_sum) g t
residualizedCoefficient μ (panelClass μ G T_rv G_meas T_meas) (residWitnessY_panel μ Y G T_rv G_meas T_meas Y_memLp B_balanced) (residWitnessD_panel μ D G T_rv G_meas T_meas D_meas D_binary B_balanced)
= betaTWFE (panelOf μ Y G T_rv A hT_pos hp_pos hp_sum)
Proof (Lean source)
theorem bridge_finite_residualized_eq_twfe_of_residual_compatibility (μ : Measure Ω) [IsProbabilityMeasure μ] (D Y : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (A : 𝒢 → WithTop (Fin T)) (G_meas : Measurable G) (T_meas : Measurable T_rv) (D_meas : Measurable D) (D_binary : ∀ᵐ ω ∂μ, D ω = 0 ∨ D ω = 1) (Y_memLp : MemLp Y 2 μ) (B_balanced : IsBalancedPanelLaw μ G T_rv) (hT_pos : 0 < T) (hp_pos : ∀ g, 0 < cohortMass μ G g) (hp_sum : ∑ g, cohortMass μ G g = 1) (hLaw : ∀ g t, cellMass μ G T_rv g t = cohortMass μ G g / (T : ℝ)) (hD_cell : ∀ g t, ∀ᵐ ω ∂μ.restrict {ω' | G ω' = g ∧ T_rv ω' = t}, D ω = (∫ ω', D ω' * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω' ∂μ) / cellMass μ G T_rv g t) (hDtilde_eq : ∀ g t, panelDtilde μ D G T_rv g t = Dtilde (panelOf μ Y G T_rv A hT_pos hp_pos hp_sum) g t) : residualizedCoefficient μ (panelClass μ G T_rv G_meas T_meas) (residWitnessY_panel μ Y G T_rv G_meas T_meas Y_memLp B_balanced) (residWitnessD_panel μ D G T_rv G_meas T_meas D_meas D_binary B_balanced) = betaTWFE (panelOf μ Y G T_rv A hT_pos hp_pos hp_sum) := by let H := panelClass μ G T_rv G_meas T_meas let wY := residWitnessY_panel μ Y G T_rv G_meas T_meas Y_memLp B_balanced let wD := residWitnessD_panel μ D G T_rv G_meas T_meas D_meas D_binary B_balanced let P := panelOf μ Y G T_rv A hT_pos hp_pos hp_sum have hMeanReg_mem : H.mem (panelMeanReg μ Y G T_rv) := panelMeanReg_mem_panelClass μ Y G T_rv G_meas T_meas have hNum_tilde : ∫ ω, wD.Vtilde ω * wY.Vtilde ω ∂μ = ∫ ω, wD.Vtilde ω * Y ω ∂μ := by have hDY_int : Integrable (fun ω => wD.Vtilde ω * Y ω) μ := wD.Vtilde_memLp.integrable_mul Y_memLp have hDM_int : Integrable (fun ω => wD.Vtilde ω * panelMeanReg μ Y G T_rv ω) μ := wD.Vtilde_memLp.integrable_mul (H.memLp hMeanReg_mem) calc ∫ ω, wD.Vtilde ω * wY.Vtilde ω ∂μ = ∫ ω, wD.Vtilde ω * Y ω - wD.Vtilde ω * panelMeanReg μ Y G T_rv ω ∂μ := by refine integral_congr_ae ?_ filter_upwards [] with ω simp [wY, residWitnessY_panel] ring _ = ∫ ω, wD.Vtilde ω * Y ω ∂μ - ∫ ω, wD.Vtilde ω * panelMeanReg μ Y G T_rv ω ∂μ := integral_sub hDY_int hDM_int _ = ∫ ω, wD.Vtilde ω * Y ω ∂μ := by rw [wD.orthogonal hMeanReg_mem] ring have hDen_sum : ∫ ω, wD.Vtilde ω * wD.Vtilde ω ∂μ = ∑ g, ∑ t, cellMass μ G T_rv g t * (panelDtilde μ D G T_rv g t)^2 := by have hF_int : Integrable (fun ω => wD.Vtilde ω * wD.Vtilde ω) μ := wD.Vtilde_memLp.integrable_mul wD.Vtilde_memLp calc ∫ ω, wD.Vtilde ω * wD.Vtilde ω ∂μ = ∑ g, ∑ t, ∫ ω, (wD.Vtilde ω * wD.Vtilde ω) * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ := integral_eq_sum_panel_cell μ (fun ω => wD.Vtilde ω * wD.Vtilde ω) G T_rv G_meas T_meas hF_int _ = ∑ g, ∑ t, cellMass μ G T_rv g t * (panelDtilde μ D G T_rv g t)^2 := by refine Finset.sum_congr rfl (fun g _ => ?_) refine Finset.sum_congr rfl (fun t _ => ?_) simpa [wD, residWitnessD_panel, mul_assoc] using denom_per_cell_panel μ D G T_rv G_meas T_meas g t (hD_cell g t) have hNum_sum : ∫ ω, wD.Vtilde ω * Y ω ∂μ = ∑ g, ∑ t, cellMass μ G T_rv g t * panelDtilde μ D G T_rv g t * cellMean μ Y G T_rv g t := by have hF_int : Integrable (fun ω => wD.Vtilde ω * Y ω) μ := wD.Vtilde_memLp.integrable_mul Y_memLp calc ∫ ω, wD.Vtilde ω * Y ω ∂μ = ∑ g, ∑ t, ∫ ω, (wD.Vtilde ω * Y ω) * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ := integral_eq_sum_panel_cell μ (fun ω => wD.Vtilde ω * Y ω) G T_rv G_meas T_meas hF_int _ = ∑ g, ∑ t, cellMass μ G T_rv g t * panelDtilde μ D G T_rv g t * cellMean μ Y G T_rv g t := by refine Finset.sum_congr rfl (fun g _ => ?_) refine Finset.sum_congr rfl (fun t _ => ?_) simpa [wD, residWitnessD_panel, mul_assoc] using num_per_cell_panel μ D Y G T_rv G_meas T_meas g t (hD_cell g t) calc residualizedCoefficient μ (panelClass μ G T_rv G_meas T_meas) (residWitnessY_panel μ Y G T_rv G_meas T_meas Y_memLp B_balanced) (residWitnessD_panel μ D G T_rv G_meas T_meas D_meas D_binary B_balanced) = (∫ ω, wD.Vtilde ω * wY.Vtilde ω ∂μ) / (∫ ω, wD.Vtilde ω * wD.Vtilde ω ∂μ) := by rfl _ = (∫ ω, wD.Vtilde ω * Y ω ∂μ) / (∫ ω, wD.Vtilde ω * wD.Vtilde ω ∂μ) := by rw [hNum_tilde] _ = (∑ g, ∑ t, cellMass μ G T_rv g t * panelDtilde μ D G T_rv g t * cellMean μ Y G T_rv g t) / (∑ g, ∑ t, cellMass μ G T_rv g t * (panelDtilde μ D G T_rv g t)^2) := by rw [hNum_sum, hDen_sum] _ = betaTWFE P := by simp [P, panelOf, betaTWFE, VD, hLaw, hDtilde_eq, mul_assoc]