Panel.Estimand­Characterization.Staggered­TWFEDecomposition.Support

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.

Basic 11 core · 4 supporting Defines basic bridge objects for the staggered-TWFE decomposition. ★ panelPropensity_mem_panelClass★ panelMeanReg_mem_panelClass

Defines basic bridge objects for the staggered-TWFE decomposition. The module packages saturated cohort-period classes and finite panel support used to connect algebraic weighted panels to population integrals.

def panelClass reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

B1. Saturated cohort + period class. Linear class spanned (a.e.) by the family of cohort indicators 𝟙{G = g} (for g : 𝒢) and period indicators 𝟙{T_rv = t} (for t : Fin T).

Definition (Lean source)
noncomputable def panelClass (μ : Measure Ω) [IsFiniteMeasure μ] (G : Ω → 𝒢) (T_rv : Ω → Fin T) (G_meas : Measurable G) (T_meas : Measurable T_rv) : LinearL2Class μ := CellBridge.twoAxisIndicatorSpan μ G T_rv G_meas T_meas
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.panelClass · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Basic.lean:48 · uses LinearL2Class
def cellMass reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

B2. Cell mass. cellMass μ G T_rv g t = (μ {G = g ∧ T_rv = t}).toReal. Plays the role of ℙ(G = g, T = t) = p_g / |𝒯| in def:po-estimand-goodman-bacon-panel.

Definition (Lean source)
def cellMass (μ : Measure Ω) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (g : 𝒢) (t : Fin T) : ℝ := CellBridge.jointCellMass μ G T_rv g t
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.cellMass · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Basic.lean:65
def cohortMass reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

B2. Cohort mass. cohortMass μ G g = (μ {G = g}).toReal. Plays the role of p_g. Equals ∑ t, cellMass μ G T_rv g t under the balanced-law hypothesis.

Definition (Lean source)
def cohortMass (μ : Measure Ω) (G : Ω → 𝒢) (g : 𝒢) : ℝ := CellBridge.cellMass μ G g
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.cohortMass · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Basic.lean:72
def periodMass reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

B2. Period mass. periodMass μ T_rv t = (μ {T_rv = t}).toReal. Plays the role of 1/|𝒯| under the balanced-law hypothesis.

Definition (Lean source)
def periodMass (μ : Measure Ω) (T_rv : Ω → Fin T) (t : Fin T) : ℝ := CellBridge.cellMass μ T_rv t
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.periodMass · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Basic.lean:78
def cellMean reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

B2. Cell mean. cellMean μ Y G T_rv g t plays the role of Y_{gt} = E[Y | G = g, T = t] from the LaTeX panel definition. On zero-mass cells the value is 0 by Mathlib's 0/0 = 0 convention.

Definition (Lean source)
noncomputable def cellMean (μ : Measure Ω) (Y : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (g : 𝒢) (t : Fin T) : ℝ := (∫ ω, Y ω * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ) / cellMass μ G T_rv g t
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.cellMean · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Basic.lean:83
def cohortBarD reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

B2. Cohort mean treatment share. cohortBarD μ D G g plays the role of \overline{D}_g = E[D | G = g].

Definition (Lean source)
noncomputable def cohortBarD (μ : Measure Ω) (D : Ω → ℝ) (G : Ω → 𝒢) (g : 𝒢) : ℝ := (∫ ω, D ω * indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω ∂μ) / cohortMass μ G g
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.cohortBarD · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Basic.lean:108
def panelOf reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

B2. Bridge to Layer A. Constructs a CohortPanel 𝒢 T from a measure carrying the cell-level data plus an explicit adoption date A : 𝒢 → WithTop (Fin T).

Definition (Lean source)
noncomputable def panelOf (μ : Measure Ω) (Y : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (A : 𝒢 → WithTop (Fin T)) (hT_pos : 0 < T) (hp_pos : ∀ g, 0 < cohortMass μ G g) (hp_sum : ∑ g, cohortMass μ G g = 1) : CohortPanel 𝒢 T := { p := cohortMass μ G , A := A , Y := cellMean μ Y G T_rv , T_pos := hT_pos , p_pos := hp_pos , p_sum_one := hp_sum }
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.panelOf · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Basic.lean:117 · uses CohortPanel , cohortMass
def panelPropensity reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

B3. Saturated cohort+period propensity for D. The pointwise representative

Definition (Lean source)
noncomputable def panelPropensity (μ : Measure Ω) (D : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) : Ω → ℝ := fun ω => (∑ g, cohortBarD μ D G g * indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω) + (∑ t, ((∫ ω', D ω' * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω' ∂μ) / periodMass μ T_rv t - ∫ ω', D ω' ∂μ) * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω)
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.panelPropensity · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Basic.lean:137
def panelMeanReg reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

B3. Saturated cohort+period mean regression for Y. Analogous to panelPropensity, with Y in place of D.

Definition (Lean source)
noncomputable def panelMeanReg (μ : Measure Ω) (Y : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) : Ω → ℝ := fun ω => (∑ g, ((∫ ω', Y ω' * indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω' ∂μ) / cohortMass μ G g) * indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω) + (∑ t, ((∫ ω', Y ω' * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω' ∂μ) / periodMass μ T_rv t - ∫ ω', Y ω' ∂μ) * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω)
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.panelMeanReg · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Basic.lean:157
theorem panelPropensity_mem_panelClass reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a finite measure μ, a treatment variable D, a measurable cohort map G, and a measurable period map T_rv, the pointwise saturated cohort-and-period propensity regression of D belongs to the two-axis additive (cohort-plus-period) function class.

Formal statement
D :
Ω → ℝ
G :
Ω → 𝒢
T_rv :
Ω → Fin T
G_meas :
T_meas :
(panelClass μ G T_rv G_meas T_meas).mem (panelPropensity μ D G T_rv)
Proof (Lean source)
theorem panelPropensity_mem_panelClass (μ : Measure Ω) [IsFiniteMeasure μ] (D : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (G_meas : Measurable G) (T_meas : Measurable T_rv) : (panelClass μ G T_rv G_meas T_meas).mem (panelPropensity μ D G T_rv) := by unfold panelClass CellBridge.twoAxisIndicatorSpan refine ⟨fun g => cohortBarD μ D G g, fun t => (∫ ω', D ω' * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω' ∂μ) / periodMass μ T_rv t - ∫ ω', D ω' ∂μ, ?_⟩ filter_upwards [] with ω rfl
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.panelPropensity_mem_panelClass · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Basic.lean:174 · uses panelClass , panelPropensity
theorem panelMeanReg_mem_panelClass reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a finite measure μ, an outcome variable Y, a measurable cohort map G, and a measurable period map T_rv, the pointwise saturated cohort-and-period mean regression of Y belongs to the two-axis additive (cohort-plus-period) function class.

Formal statement
Y :
Ω → ℝ
G :
Ω → 𝒢
T_rv :
Ω → Fin T
G_meas :
T_meas :
(panelClass μ G T_rv G_meas T_meas).mem (panelMeanReg μ Y G T_rv)
Proof (Lean source)
theorem panelMeanReg_mem_panelClass (μ : Measure Ω) [IsFiniteMeasure μ] (Y : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (G_meas : Measurable G) (T_meas : Measurable T_rv) : (panelClass μ G T_rv G_meas T_meas).mem (panelMeanReg μ Y G T_rv) := by unfold panelClass CellBridge.twoAxisIndicatorSpan refine ⟨fun g => (∫ ω', Y ω' * indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω' ∂μ) / cohortMass μ G g, fun t => (∫ ω', Y ω' * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω' ∂μ) / periodMass μ T_rv t - ∫ ω', Y ω' ∂μ, ?_⟩ filter_upwards [] with ω rfl
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.panelMeanReg_mem_panelClass · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Basic.lean:195 · uses panelClass , panelMeanReg
4 supporting declarations (lemmas, instances)
Orthogonality 2 core · 8 supporting This file proves the cohort-axis and period-axis orthogonality conditions needed for the measure-theoretic Goodman-Bacon bridge. ★ residD_cohort_orthogonal

Goodman-Bacon Bridge Orthogonality

This file proves the cohort-axis and period-axis orthogonality conditions needed for the measure-theoretic Goodman-Bacon bridge. Under the balanced cell-mass product condition, residuals from the panel propensity and mean regressions are orthogonal to the saturated cohort and period indicator class.

def IsBalancedPanelLaw reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

The "balanced cell-mass product" hypothesis. Says the joint law of (G, T_rv) factors as a product on each cohort × period cell:

Definition (Lean source)
def IsBalancedPanelLaw (μ : Measure Ω) (G : Ω → 𝒢) (T_rv : Ω → Fin T) : Prop := ∀ g t, cellMass μ G T_rv g t = cohortMass μ G g * periodMass μ T_rv t
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.IsBalancedPanelLaw · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Orthogonality.lean:38
theorem residD_cohort_orthogonal reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

For a treatment indicator D that is binary almost everywhere, the residual between D and its cohort-period propensity score panelPropensity is orthogonal, in the L²(μ) sense, to every cohort indicator 𝟙{G = g}.

Formal statement
D :
Ω → ℝ
G :
Ω → 𝒢
T_rv :
Ω → Fin T
G_meas :
T_meas :
D_meas :
D_binary :
∀ᵐ ω ∂μ, D ω = 0 ∨ D ω = 1
B_balanced :
g :
𝒢
∫ ω, (D ω - panelPropensity μ D G T_rv ω) * indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω ∂μ
= 0
Proof (Lean source)
theorem residD_cohort_orthogonal (μ : Measure Ω) [IsProbabilityMeasure μ] (D : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → 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) (g : 𝒢) : ∫ ω, (D ω - panelPropensity μ D G T_rv ω) * indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω ∂μ = 0 := by classical have hD_mem : MemLp D 2 μ := memLp_two_of_binary μ D D_meas D_binary have hproj : panelPropensity μ D G T_rv = panelMeanReg μ D G T_rv := by funext ω simp [panelPropensity, panelMeanReg, cohortBarD] simpa [hproj] using panelMeanReg_cohort_axis_orthogonal μ D G T_rv G_meas T_meas hD_mem B_balanced g
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.residD_cohort_orthogonal · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Orthogonality.lean:621 · uses IsBalancedPanelLaw , panelPropensity
8 supporting declarations (lemmas, instances)
  • memLp_two_of_binary theorem — Under a probability measure, a measurable real-valued variable that equals either zero or one almost surely has a finite second moment.
    D :
    Ω → ℝ
    D_meas :
    D_binary :
    ∀ᵐ ω ∂μ, D ω = 0 ∨ D ω = 1
    MemLp D 2 μ
    Proof (Lean source)
    theorem memLp_two_of_binary (μ : Measure Ω) [IsProbabilityMeasure μ] (D : Ω → ℝ) (D_meas : Measurable D) (D_binary : ∀ᵐ ω ∂μ, D ω = 0 ∨ D ω = 1) : MemLp D 2 μ := by have hD_bounded : ∀ᵐ ω ∂μ, D ω ∈ Icc (-1 : ℝ) 1 := by filter_upwards [D_binary] with ω hD rcases hD with hD0 | hD1 · simp [hD0] · simp [hD1] exact memLp_of_bounded (f := D) hD_bounded D_meas.aestronglyMeasurable (2 : ENNReal)
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.memLp_two_of_binary · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Orthogonality.lean:49
  • sum_periodMass_eq_one theorem — Under a probability distribution, the probabilities assigned to every period by a measurable finite-valued period variable sum to one.
    T_rv :
    Ω → Fin T
    T_meas :
    ∑ t, periodMass μ T_rv t = 1
    Proof (Lean source)
    theorem sum_periodMass_eq_one (μ : Measure Ω) [IsProbabilityMeasure μ] (T_rv : Ω → Fin T) (T_meas : Measurable T_rv) : ∑ t, periodMass μ T_rv t = 1 := by have hOneInt : Integrable (fun _ : Ω => (1 : ℝ)) μ := integrable_const (1 : ℝ) calc ∑ t, periodMass μ T_rv t = ∑ t, ∫ ω, (fun _ : Ω => (1 : ℝ)) ω * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ := by refine Finset.sum_congr rfl ?_ intro t _ simpa [periodMass] using (CellBridge.integral_cell_indicator_one_eq_cellMass μ T_rv T_meas t).symm _ = ∫ ω, (1 : ℝ) ∂μ := by rw [CellBridge.integral_eq_sum_cell μ (fun _ : Ω => (1 : ℝ)) T_rv T_meas hOneInt] _ = 1 := by simp
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.sum_periodMass_eq_one · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Orthogonality.lean:318
  • period_centered_sum_eq_zero theorem — Under a probability distribution, period-specific means of an integrable outcome, centered by the overall mean and weighted by their period probabilities, sum to zero.
    F :
    Ω → ℝ
    T_rv :
    Ω → Fin T
    T_meas :
    F_int :
    ∑ t, (((∫ ω, F ω * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ) / periodMass μ T_rv t) - ∫ ω, F ω ∂μ) * periodMass μ T_rv t
    = 0
    Proof (Lean source)
    theorem period_centered_sum_eq_zero (μ : Measure Ω) [IsProbabilityMeasure μ] (F : Ω → ℝ) (T_rv : Ω → Fin T) (T_meas : Measurable T_rv) (F_int : Integrable F μ) : ∑ t, (((∫ ω, F ω * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ) / periodMass μ T_rv t) - ∫ ω, F ω ∂μ) * periodMass μ T_rv t = 0 := by have hdiv : ∀ t, ((∫ ω, F ω * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ) / periodMass μ T_rv t) * periodMass μ T_rv t = ∫ ω, F ω * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ := fun t => period_integral_div_mul_periodMass μ F T_rv t calc ∑ t, (((∫ ω, F ω * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ) / periodMass μ T_rv t) - ∫ ω, F ω ∂μ) * periodMass μ T_rv t = (∑ t, ∫ ω, F ω * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ) - (∫ ω, F ω ∂μ) * ∑ t, periodMass μ T_rv t := by simp only [sub_mul, Finset.sum_sub_distrib, Finset.mul_sum] congr 1 exact Finset.sum_congr rfl (fun t _ => hdiv t) _ = (∫ ω, F ω ∂μ) - (∫ ω, F ω ∂μ) * 1 := by rw [← integral_eq_sum_period μ F T_rv T_meas F_int, sum_periodMass_eq_one μ T_rv T_meas] _ = 0 := by ring
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.period_centered_sum_eq_zero · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Orthogonality.lean:338
  • panelMeanReg_cohort_axis_orthogonal theorem — Under a balanced panel law, the residual from the panel mean regression has zero average product with the indicator of any fixed cohort.
    F :
    Ω → ℝ
    G :
    Ω → 𝒢
    T_rv :
    Ω → Fin T
    G_meas :
    T_meas :
    F_memLp :
    MemLp F 2 μ
    B_balanced :
    g :
    𝒢
    ∫ ω, (F ω - panelMeanReg μ F G T_rv ω) * indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω ∂μ
    = 0
    Proof (Lean source)
    theorem panelMeanReg_cohort_axis_orthogonal (μ : Measure Ω) [IsProbabilityMeasure μ] (F : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (G_meas : Measurable G) (T_meas : Measurable T_rv) (F_memLp : MemLp F 2 μ) (B_balanced : IsBalancedPanelLaw μ G T_rv) (g : 𝒢) : ∫ ω, (F ω - panelMeanReg μ F G T_rv ω) * indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω ∂μ = 0 := by classical let IG : 𝒢 → Ω → ℝ := fun g ω => indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω let IT : Fin T → Ω → ℝ := fun t ω => indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω let a : 𝒢 → ℝ := fun g => (∫ ω, F ω * IG g ω ∂μ) / cohortMass μ G g let b : Fin T → ℝ := fun t => (∫ ω, F ω * IT t ω ∂μ) / periodMass μ T_rv t - ∫ ω, F ω ∂μ have hF_int : Integrable F μ := F_memLp.integrable (by norm_num : (1 : ENNReal) ≤ 2) have hIG : MemLp (IG g) 2 μ := by simpa [IG] using indicator_cohort_memLp μ G G_meas g have hFI_int : Integrable (fun ω => F ω * IG g ω) μ := F_memLp.integrable_mul hIG have hPanel_mem : MemLp (panelMeanReg μ F G T_rv) 2 μ := (panelClass μ G T_rv G_meas T_meas).memLp (panelMeanReg_mem_panelClass μ F G T_rv G_meas T_meas) have hPanelI_int : Integrable (fun ω => panelMeanReg μ F G T_rv ω * IG g ω) μ := hPanel_mem.integrable_mul hIG have hsumG_mem : MemLp (fun ω => ∑ g', a g' * IG g' ω) 2 μ := (panelClass μ G T_rv G_meas T_meas).memLp ⟨a, fun _ => 0, by filter_upwards [] with ω; simp [IG]⟩ have hsumT_mem : MemLp (fun ω => ∑ t, b t * IT t ω) 2 μ := (panelClass μ G T_rv G_meas T_meas).memLp ⟨fun _ => 0, b, by filter_upwards [] with ω; simp [IT]⟩ have hsumGI_int : Integrable (fun ω => (∑ g', a g' * IG g' ω) * IG g ω) μ := hsumG_mem.integrable_mul hIG have hsumTI_int : Integrable (fun ω => (∑ t, b t * IT t ω) * IG g ω) μ := hsumT_mem.integrable_mul hIG have hcohort : ∫ ω, (∑ g', a g' * IG g' ω) * IG g ω ∂μ = ∫ ω, F ω * IG g ω ∂μ := by calc ∫ ω, (∑ g', a g' * IG g' ω) * IG g ω ∂μ = a g * cohortMass μ G g := by simpa [IG, a] using integral_cohort_sum_mul_cohort_indicator μ G G_meas a g _ = ∫ ω, F ω * IG g ω ∂μ := by simpa [a, IG, mul_comm] using (cohort_integral_div_mul_cohortMass μ F G g) have hperiod : ∫ ω, (∑ t, b t * IT t ω) * IG g ω ∂μ = 0 := by calc ∫ ω, (∑ t, b t * IT t ω) * IG g ω ∂μ = ∑ t, b t * cellMass μ G T_rv g t := by simpa [IG, IT, b] using integral_period_sum_mul_cohort_indicator μ G T_rv G_meas T_meas b g _ = cohortMass μ G g * ∑ t, b t * periodMass μ T_rv t := by calc ∑ t, b t * cellMass μ G T_rv g t = ∑ t, b t * (cohortMass μ G g * periodMass μ T_rv t) := by refine Finset.sum_congr rfl ?_ intro t _ rw [B_balanced g t] _ = cohortMass μ G g * ∑ t, b t * periodMass μ T_rv t := by rw [Finset.mul_sum] refine Finset.sum_congr rfl ?_ intro t _ ring _ = 0 := by rw [period_centered_sum_eq_zero μ F T_rv T_meas hF_int] ring have hpanel : ∫ ω, panelMeanReg μ F G T_rv ω * IG g ω ∂μ = ∫ ω, F ω * IG g ω ∂μ := by calc ∫ ω, panelMeanReg μ F G T_rv ω * IG g ω ∂μ = ∫ ω, ((∑ g', a g' * IG g' ω) + (∑ t, b t * IT t ω)) * IG g ω ∂μ := by simp [panelMeanReg, IG, IT, a, b] _ = ∫ ω, (∑ g', a g' * IG g' ω) * IG g ω + (∑ t, b t * IT t ω) * IG g ω ∂μ := by refine integral_congr_ae ?_ filter_upwards [] with ω ring _ = ∫ ω, (∑ g', a g' * IG g' ω) * IG g ω ∂μ + ∫ ω, (∑ t, b t * IT t ω) * IG g ω ∂μ := by exact integral_add hsumGI_int hsumTI_int _ = ∫ ω, F ω * IG g ω ∂μ := by rw [hcohort, hperiod] ring calc ∫ ω, (F ω - panelMeanReg μ F G T_rv ω) * IG g ω ∂μ = ∫ ω, F ω * IG g ω ∂μ - ∫ ω, panelMeanReg μ F G T_rv ω * IG g ω ∂μ := by calc ∫ ω, (F ω - panelMeanReg μ F G T_rv ω) * IG g ω ∂μ = ∫ ω, F ω * IG g ω - panelMeanReg μ F G T_rv ω * IG g ω ∂μ := by refine integral_congr_ae ?_ filter_upwards [] with ω ring _ = ∫ ω, F ω * IG g ω ∂μ - ∫ ω, panelMeanReg μ F G T_rv ω * IG g ω ∂μ := integral_sub hFI_int hPanelI_int _ = 0 := by rw [hpanel]; ring
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.panelMeanReg_cohort_axis_orthogonal · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Orthogonality.lean:372
  • panelMeanReg_period_axis_orthogonal theorem — Under a balanced panel law, the residual from the panel mean regression has zero average product with the indicator of any fixed period.
    F :
    Ω → ℝ
    G :
    Ω → 𝒢
    T_rv :
    Ω → Fin T
    G_meas :
    T_meas :
    F_memLp :
    MemLp F 2 μ
    B_balanced :
    t :
    Fin T
    ∫ ω, (F ω - panelMeanReg μ F G T_rv ω) * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ
    = 0
    Proof (Lean source)
    theorem panelMeanReg_period_axis_orthogonal (μ : Measure Ω) [IsProbabilityMeasure μ] (F : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (G_meas : Measurable G) (T_meas : Measurable T_rv) (F_memLp : MemLp F 2 μ) (B_balanced : IsBalancedPanelLaw μ G T_rv) (t : Fin T) : ∫ ω, (F ω - panelMeanReg μ F G T_rv ω) * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ = 0 := by classical let IG : 𝒢 → Ω → ℝ := fun g ω => indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω let IT : Fin T → Ω → ℝ := fun t ω => indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω let a : 𝒢 → ℝ := fun g => (∫ ω, F ω * IG g ω ∂μ) / cohortMass μ G g let b : Fin T → ℝ := fun t => (∫ ω, F ω * IT t ω ∂μ) / periodMass μ T_rv t - ∫ ω, F ω ∂μ have hF_int : Integrable F μ := F_memLp.integrable (by norm_num : (1 : ENNReal) ≤ 2) have hIT : MemLp (IT t) 2 μ := by simpa [IT] using indicator_period_memLp μ T_rv T_meas t have hFI_int : Integrable (fun ω => F ω * IT t ω) μ := F_memLp.integrable_mul hIT have hPanel_mem : MemLp (panelMeanReg μ F G T_rv) 2 μ := (panelClass μ G T_rv G_meas T_meas).memLp (panelMeanReg_mem_panelClass μ F G T_rv G_meas T_meas) have hPanelI_int : Integrable (fun ω => panelMeanReg μ F G T_rv ω * IT t ω) μ := hPanel_mem.integrable_mul hIT have hsumG_mem : MemLp (fun ω => ∑ g, a g * IG g ω) 2 μ := (panelClass μ G T_rv G_meas T_meas).memLp ⟨a, fun _ => 0, by filter_upwards [] with ω; simp [IG]⟩ have hsumT_mem : MemLp (fun ω => ∑ t', b t' * IT t' ω) 2 μ := (panelClass μ G T_rv G_meas T_meas).memLp ⟨fun _ => 0, b, by filter_upwards [] with ω; simp [IT]⟩ have hsumGI_int : Integrable (fun ω => (∑ g, a g * IG g ω) * IT t ω) μ := hsumG_mem.integrable_mul hIT have hsumTI_int : Integrable (fun ω => (∑ t', b t' * IT t' ω) * IT t ω) μ := hsumT_mem.integrable_mul hIT have hcohort : ∫ ω, (∑ g, a g * IG g ω) * IT t ω ∂μ = (∫ ω, F ω ∂μ) * periodMass μ T_rv t := by calc ∫ ω, (∑ g, a g * IG g ω) * IT t ω ∂μ = ∑ g, a g * cellMass μ G T_rv g t := by simpa [IG, IT, a] using integral_cohort_sum_mul_period_indicator μ G T_rv G_meas T_meas a t _ = (∑ g, a g * cohortMass μ G g) * periodMass μ T_rv t := by calc ∑ g, a g * cellMass μ G T_rv g t = ∑ g, a g * (cohortMass μ G g * periodMass μ T_rv t) := by refine Finset.sum_congr rfl ?_ intro g _ rw [B_balanced g t] _ = (∑ g, a g * cohortMass μ G g) * periodMass μ T_rv t := by rw [Finset.sum_mul] refine Finset.sum_congr rfl ?_ intro g _ ring _ = (∫ ω, F ω ∂μ) * periodMass μ T_rv t := by congr 1 calc ∑ g, a g * cohortMass μ G g = ∑ g, ∫ ω, F ω * IG g ω ∂μ := by refine Finset.sum_congr rfl ?_ intro g _ simpa [a, IG, mul_comm] using (cohort_integral_div_mul_cohortMass μ F G g) _ = ∫ ω, F ω ∂μ := by rw [integral_eq_sum_cohort μ F G G_meas hF_int] have hperiod : ∫ ω, (∑ t', b t' * IT t' ω) * IT t ω ∂μ = ∫ ω, F ω * IT t ω ∂μ - (∫ ω, F ω ∂μ) * periodMass μ T_rv t := by calc ∫ ω, (∑ t', b t' * IT t' ω) * IT t ω ∂μ = b t * periodMass μ T_rv t := by simpa [IT, b] using integral_period_sum_mul_period_indicator μ T_rv T_meas b t _ = ∫ ω, F ω * IT t ω ∂μ - (∫ ω, F ω ∂μ) * periodMass μ T_rv t := by have hdiv : ((∫ ω, F ω * IT t ω ∂μ) / periodMass μ T_rv t) * periodMass μ T_rv t = ∫ ω, F ω * IT t ω ∂μ := by simpa [IT] using period_integral_div_mul_periodMass μ F T_rv t dsimp [b] calc ((∫ ω, F ω * IT t ω ∂μ) / periodMass μ T_rv t - ∫ ω, F ω ∂μ) * periodMass μ T_rv t = ((∫ ω, F ω * IT t ω ∂μ) / periodMass μ T_rv t) * periodMass μ T_rv t - (∫ ω, F ω ∂μ) * periodMass μ T_rv t := by ring _ = ∫ ω, F ω * IT t ω ∂μ - (∫ ω, F ω ∂μ) * periodMass μ T_rv t := by rw [hdiv] have hpanel : ∫ ω, panelMeanReg μ F G T_rv ω * IT t ω ∂μ = ∫ ω, F ω * IT t ω ∂μ := by calc ∫ ω, panelMeanReg μ F G T_rv ω * IT t ω ∂μ = ∫ ω, ((∑ g, a g * IG g ω) + (∑ t', b t' * IT t' ω)) * IT t ω ∂μ := by simp [panelMeanReg, IG, IT, a, b] _ = ∫ ω, (∑ g, a g * IG g ω) * IT t ω + (∑ t', b t' * IT t' ω) * IT t ω ∂μ := by refine integral_congr_ae ?_ filter_upwards [] with ω ring _ = ∫ ω, (∑ g, a g * IG g ω) * IT t ω ∂μ + ∫ ω, (∑ t', b t' * IT t' ω) * IT t ω ∂μ := by exact integral_add hsumGI_int hsumTI_int _ = ∫ ω, F ω * IT t ω ∂μ := by rw [hcohort, hperiod] ring calc ∫ ω, (F ω - panelMeanReg μ F G T_rv ω) * IT t ω ∂μ = ∫ ω, F ω * IT t ω ∂μ - ∫ ω, panelMeanReg μ F G T_rv ω * IT t ω ∂μ := by calc ∫ ω, (F ω - panelMeanReg μ F G T_rv ω) * IT t ω ∂μ = ∫ ω, F ω * IT t ω - panelMeanReg μ F G T_rv ω * IT t ω ∂μ := by refine integral_congr_ae ?_ filter_upwards [] with ω ring _ = ∫ ω, F ω * IT t ω ∂μ - ∫ ω, panelMeanReg μ F G T_rv ω * IT t ω ∂μ := integral_sub hFI_int hPanelI_int _ = 0 := by rw [hpanel]; ring
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.panelMeanReg_period_axis_orthogonal · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Orthogonality.lean:484
  • residY_cohort_orthogonal theorem — The outcome residual is orthogonal to every cohort indicator.
    Y :
    Ω → ℝ
    G :
    Ω → 𝒢
    T_rv :
    Ω → Fin T
    G_meas :
    T_meas :
    Y_memLp :
    MemLp Y 2 μ
    B_balanced :
    g :
    𝒢
    ∫ ω, (Y ω - panelMeanReg μ Y G T_rv ω) * indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω ∂μ
    = 0
    Proof (Lean source)
    theorem residY_cohort_orthogonal (μ : Measure Ω) [IsProbabilityMeasure μ] (Y : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (G_meas : Measurable G) (T_meas : Measurable T_rv) (Y_memLp : MemLp Y 2 μ) (B_balanced : IsBalancedPanelLaw μ G T_rv) (g : 𝒢) : ∫ ω, (Y ω - panelMeanReg μ Y G T_rv ω) * indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω ∂μ = 0 := by classical exact panelMeanReg_cohort_axis_orthogonal μ Y G T_rv G_meas T_meas Y_memLp B_balanced g
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.residY_cohort_orthogonal · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Orthogonality.lean:646
  • residD_period_orthogonal theorem — The treatment residual is orthogonal to every period indicator 𝟙{T_rv = t}. Requires B_balanced to make the cross-cohort sum cancel.
    D :
    Ω → ℝ
    G :
    Ω → 𝒢
    T_rv :
    Ω → Fin T
    G_meas :
    T_meas :
    D_meas :
    D_binary :
    ∀ᵐ ω ∂μ, D ω = 0 ∨ D ω = 1
    B_balanced :
    t :
    Fin T
    ∫ ω, (D ω - panelPropensity μ D G T_rv ω) * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ
    = 0
    Proof (Lean source)
    theorem residD_period_orthogonal (μ : Measure Ω) [IsProbabilityMeasure μ] (D : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → 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) (t : Fin T) : ∫ ω, (D ω - panelPropensity μ D G T_rv ω) * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ = 0 := by classical have hD_mem : MemLp D 2 μ := memLp_two_of_binary μ D D_meas D_binary have hproj : panelPropensity μ D G T_rv = panelMeanReg μ D G T_rv := by funext ω simp [panelPropensity, panelMeanReg, cohortBarD] simpa [hproj] using panelMeanReg_period_axis_orthogonal μ D G T_rv G_meas T_meas hD_mem B_balanced t
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.residD_period_orthogonal · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Orthogonality.lean:662
  • residY_period_orthogonal theorem — The outcome residual is orthogonal to every period indicator.
    Y :
    Ω → ℝ
    G :
    Ω → 𝒢
    T_rv :
    Ω → Fin T
    G_meas :
    T_meas :
    Y_memLp :
    MemLp Y 2 μ
    B_balanced :
    t :
    Fin T
    ∫ ω, (Y ω - panelMeanReg μ Y G T_rv ω) * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ
    = 0
    Proof (Lean source)
    theorem residY_period_orthogonal (μ : Measure Ω) [IsProbabilityMeasure μ] (Y : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (G_meas : Measurable G) (T_meas : Measurable T_rv) (Y_memLp : MemLp Y 2 μ) (B_balanced : IsBalancedPanelLaw μ G T_rv) (t : Fin T) : ∫ ω, (Y ω - panelMeanReg μ Y G T_rv ω) * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ = 0 := by classical exact panelMeanReg_period_axis_orthogonal μ Y G T_rv G_meas T_meas Y_memLp B_balanced t
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.residY_period_orthogonal · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Orthogonality.lean:684
Integrals 3 core · 15 supporting Proves integral identities for the staggered-TWFE bridge. ★ integral_mul_panelClass_eq_zero_of_axes

Proves integral identities for the staggered-TWFE bridge. The module supplies MemLp, indicator, and orthogonality facts used to transport finite weighted decompositions into the population setting.

def panelPropensityHat reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

The "panel-propensity hat" pHat g t = cohortBarD g + cT t where cT t := (∫ D · 𝟙{T_rv=t} dμ) / periodMass t - ∫ D dμ.

Definition (Lean source)
noncomputable def panelPropensityHat (μ : Measure Ω) (D : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (g : 𝒢) (t : Fin T) : ℝ := cohortBarD μ D G g + ((∫ ω', D ω' * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω' ∂μ) / periodMass μ T_rv t - ∫ ω', D ω' ∂μ)
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.panelPropensityHat · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Integrals.lean:204
def panelMeanRegHat reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

"panel-meanReg hat" analogue for Y.

Definition (Lean source)
noncomputable def panelMeanRegHat (μ : Measure Ω) (Y : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (g : 𝒢) (t : Fin T) : ℝ := ((∫ ω', Y ω' * indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω' ∂μ) / cohortMass μ G g) + ((∫ ω', Y ω' * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω' ∂μ) / periodMass μ T_rv t - ∫ ω', Y ω' ∂μ)
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.panelMeanRegHat · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Integrals.lean:215
theorem integral_mul_panelClass_eq_zero_of_axes reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

If a square-integrable random variable V has zero mean product against every cohort indicator 𝟙{G = g} and zero mean product against every period indicator 𝟙{T_rv = t}, then V is orthogonal, in the L²(μ) sense, to every unit/period-additive combination ∑_g cG(g)·𝟙{G = g} + ∑_t cT(t)·𝟙{T_rv = t}, i.e. to every member of the additive nuisance class panelClass.

Formal statement
V :
Ω → ℝ
G :
Ω → 𝒢
T_rv :
Ω → Fin T
G_meas :
T_meas :
V_memLp :
MemLp V 2 μ
cG :
𝒢 → ℝ
cT :
Fin T → ℝ
hCohort :
∀ g, ∫ ω, V ω * indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω ∂μ = 0
hPeriod :
∀ t, ∫ ω, V ω * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ = 0
∫ ω, V ω * ((∑ g, cG g * indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω) + (∑ t, cT t * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω)) ∂μ
= 0
Proof (Lean source)
theorem integral_mul_panelClass_eq_zero_of_axes (μ : Measure Ω) [IsFiniteMeasure μ] (V : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (G_meas : Measurable G) (T_meas : Measurable T_rv) (V_memLp : MemLp V 2 μ) (cG : 𝒢 → ℝ) (cT : Fin T → ℝ) (hCohort : ∀ g, ∫ ω, V ω * indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω ∂μ = 0) (hPeriod : ∀ t, ∫ ω, V ω * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ = 0) : ∫ ω, V ω * ((∑ g, cG g * indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω) + (∑ t, cT t * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω)) ∂μ = 0 := by classical exact CellBridge.integral_mul_twoAxisIndicatorSpan_eq_zero_of_axes μ V G T_rv G_meas T_meas V_memLp cG cT hCohort hPeriod
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.integral_mul_panelClass_eq_zero_of_axes · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/Integrals.lean:272
15 supporting declarations (lemmas, instances)
Partition 2 core · 0 supporting This file constructs the residualization witnesses for treatment and outcome after projecting on cohort and period cells in a balanced panel.

Goodman-Bacon Residualization Witnesses

This file constructs the residualization witnesses for treatment and outcome after projecting on cohort and period cells in a balanced panel. These witnesses package the fitted component, the residual component, square integrability, decomposition, and orthogonality conditions used by the Goodman-Bacon bridge.

def residWitnessD_panel reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

B3. Residualization witness for D against panelClass. With VH := panelPropensity μ D G T_rv and Vtilde ω := D ω - panelPropensity ω, this packages the four witness obligations:

Definition (Lean source)
noncomputable def residWitnessD_panel (μ : Measure Ω) [IsProbabilityMeasure μ] (D : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → 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) : ResidualizationWitness μ (panelClass μ G T_rv G_meas T_meas) D := by let H := panelClass μ G T_rv G_meas T_meas have hVH_mem : H.mem (panelPropensity μ D G T_rv) := panelPropensity_mem_panelClass μ D G T_rv G_meas T_meas have hD_mem : MemLp D 2 μ := by have hD_bounded : ∀ᵐ ω ∂μ, D ω ∈ Icc (-1 : ℝ) 1 := by filter_upwards [D_binary] with ω hD rcases hD with hD0 | hD1 · simp [hD0] · simp [hD1] exact memLp_of_bounded (f := D) hD_bounded (D_meas.aestronglyMeasurable) (2 : ENNReal) have hVtilde_memLp : MemLp (fun ω => D ω - panelPropensity μ D G T_rv ω) 2 μ := hD_mem.sub (H.memLp hVH_mem) refine { VH := panelPropensity μ D G T_rv , Vtilde := fun ω => D ω - panelPropensity μ D G T_rv ω , VH_mem := hVH_mem , Vtilde_memLp := hVtilde_memLp , decomp := by filter_upwards [] with ω change D ω = panelPropensity μ D G T_rv ω + (D ω - panelPropensity μ D G T_rv ω) ring , orthogonal := by intro h hh rcases hh with ⟨cG, cT, hh_eq⟩ have hVtilde := hVtilde_memLp calc ∫ ω, (D ω - panelPropensity μ D G T_rv ω) * h ω ∂μ = ∫ ω, (D ω - panelPropensity μ D G T_rv ω) * ((∑ g, cG g * indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω) + (∑ t, cT t * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω)) ∂μ := by refine integral_congr_ae ?_ filter_upwards [hh_eq] with ω hω rw [hω] _ = 0 := integral_mul_panelClass_eq_zero_of_axes μ (fun ω => D ω - panelPropensity μ D G T_rv ω) G T_rv G_meas T_meas hVtilde cG cT (fun g => residD_cohort_orthogonal μ D G T_rv G_meas T_meas D_meas D_binary B_balanced g) (fun t => residD_period_orthogonal μ D G T_rv G_meas T_meas D_meas D_binary B_balanced t) }
def residWitnessY_panel reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

B3. Residualization witness for Y against panelClass.

Definition (Lean source)
noncomputable def residWitnessY_panel (μ : Measure Ω) [IsProbabilityMeasure μ] (Y : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (G_meas : Measurable G) (T_meas : Measurable T_rv) (Y_memLp : MemLp Y 2 μ) (B_balanced : IsBalancedPanelLaw μ G T_rv) : ResidualizationWitness μ (panelClass μ G T_rv G_meas T_meas) Y := by let H := panelClass μ G T_rv G_meas T_meas have hVH_mem : H.mem (panelMeanReg μ Y G T_rv) := panelMeanReg_mem_panelClass μ Y G T_rv G_meas T_meas have hVtilde_memLp : MemLp (fun ω => Y ω - panelMeanReg μ Y G T_rv ω) 2 μ := Y_memLp.sub (H.memLp hVH_mem) refine { VH := panelMeanReg μ Y G T_rv , Vtilde := fun ω => Y ω - panelMeanReg μ Y G T_rv ω , VH_mem := hVH_mem , Vtilde_memLp := hVtilde_memLp , decomp := by filter_upwards [] with ω change Y ω = panelMeanReg μ Y G T_rv ω + (Y ω - panelMeanReg μ Y G T_rv ω) ring , orthogonal := by intro h hh rcases hh with ⟨cG, cT, hh_eq⟩ have hVtilde := hVtilde_memLp calc ∫ ω, (Y ω - panelMeanReg μ Y G T_rv ω) * h ω ∂μ = ∫ ω, (Y ω - panelMeanReg μ Y G T_rv ω) * ((∑ g, cG g * indicator {ω' | G ω' = g} (fun _ => (1 : ℝ)) ω) + (∑ t, cT t * indicator {ω' | T_rv ω' = t} (fun _ => (1 : ℝ)) ω)) ∂μ := by refine integral_congr_ae ?_ filter_upwards [hh_eq] with ω hω rw [hω] _ = 0 := integral_mul_panelClass_eq_zero_of_axes μ (fun ω => Y ω - panelMeanReg μ Y G T_rv ω) G T_rv G_meas T_meas hVtilde cG cT (fun g => residY_cohort_orthogonal μ Y G T_rv G_meas T_meas Y_memLp B_balanced g) (fun t => residY_period_orthogonal μ Y G T_rv G_meas T_meas Y_memLp B_balanced t) }
Per­Cell 2 core · 1 supporting This file proves the cell-level integral identities that express the residualized-treatment denominator and the residualized-outcome numerator in terms of cohort-period panel statistics. ★ num_per_cell_panel

Goodman-Bacon Per-Cell Bridge Identities

This file proves the cell-level integral identities that express the residualized-treatment denominator and the residualized-outcome numerator in terms of cohort-period panel statistics. These identities supply the local algebra needed to connect the measure-theoretic bridge with the finite Goodman-Bacon decomposition.

def panelDtilde reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

The "panel-residualized treatment hat" Dtilde_{gt} value of the in-class residual on cell (g, t): equals D_{gt} - barD_g - (E[D | T=t] - E[D]), the LaTeX double-demeaning formula.

Definition (Lean source)
noncomputable def panelDtilde (μ : Measure Ω) (D : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (g : 𝒢) (t : Fin T) : ℝ := ((∫ ω, D ω * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ) / cellMass μ G T_rv g t) - panelPropensityHat μ D G T_rv g t
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.panelDtilde · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/PerCell.lean:31
theorem num_per_cell_panel reviewed
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition

Per-cell numerator identity. On the cohort-period cell (g, t), if the treatment D is almost-everywhere equal, on that cell, to its own cell mean (cell-measurability of D), then the integral of the propensity-residual D - panelPropensity times the outcome Y over the cell equals the cell mass times the cell's residualized treatment panelDtilde times the outcome's cell mean:

Formal statement
D Y :
Ω → ℝ
G :
Ω → 𝒢
T_rv :
Ω → Fin T
G_meas :
T_meas :
g :
𝒢
t :
Fin T
hD_cell :
∀ᵐ ω ∂μ.restrict {ω' | G ω' = g ∧ T_rv ω' = t},
D ω
= (∫ ω', D ω' * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω' ∂μ) / cellMass μ G T_rv g t
∫ ω, (D ω - panelPropensity μ D G T_rv ω) * Y ω * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ
= cellMass μ G T_rv g t * panelDtilde μ D G T_rv g t * cellMean μ Y G T_rv g t
Proof (Lean source)
theorem num_per_cell_panel (μ : Measure Ω) [IsFiniteMeasure μ] (D Y : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (G_meas : Measurable G) (T_meas : Measurable T_rv) (g : 𝒢) (t : Fin T) (hD_cell : ∀ᵐ ω ∂μ.restrict {ω' | G ω' = g ∧ T_rv ω' = t}, D ω = (∫ ω', D ω' * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω' ∂μ) / cellMass μ G T_rv g t) : ∫ ω, (D ω - panelPropensity μ D G T_rv ω) * Y ω * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ = cellMass μ G T_rv g t * panelDtilde μ D G T_rv g t * cellMean μ Y G T_rv g t := by classical let s : Set Ω := {ω | G ω = g ∧ T_rv ω = t} let I : Ω → ℝ := fun ω => indicator s (fun _ => (1 : ℝ)) ω let q : ℝ := panelDtilde μ D G T_rv g t let mY : ℝ := cellMean μ Y G T_rv g t have hs : MeasurableSet s := by have hG : MeasurableSet {ω : Ω | G ω = g} := G_meas (measurableSet_singleton g) have hT : MeasurableSet {ω : Ω | T_rv ω = t} := T_meas (measurableSet_singleton t) simpa [s, Set.inter_def] using hG.inter hT change ∫ ω, (D ω - panelPropensity μ D G T_rv ω) * Y ω * I ω ∂μ = cellMass μ G T_rv g t * q * mY have h_on : (fun ω => (D ω - panelPropensity μ D G T_rv ω) * Y ω * I ω) =ᵐ[μ.restrict s] (fun ω => q * (Y ω * I ω)) := by filter_upwards [hD_cell, MeasureTheory.ae_restrict_mem hs] with ω hDω hωs rcases hωs with ⟨hGω, hTω⟩ have hpω : panelPropensity μ D G T_rv ω = panelPropensityHat μ D G T_rv g t := panelPropensity_eq_hat_of_mem μ D G T_rv hGω hTω have hres : D ω - panelPropensity μ D G T_rv ω = q := by rw [hDω, hpω] simp [q, panelDtilde] simp [I, s, hGω, hTω, hres] have h_off : (fun ω => (D ω - panelPropensity μ D G T_rv ω) * Y ω * I ω) =ᵐ[μ.restrict sᶜ] (fun ω => q * (Y ω * I ω)) := by rw [EventuallyEq, MeasureTheory.ae_restrict_iff' hs.compl] filter_upwards with ω hωs have hω_not_s : ω ∉ s := by simpa using hωs simp [I, indicator, hω_not_s] have h_ae : (fun ω => (D ω - panelPropensity μ D G T_rv ω) * Y ω * I ω) =ᵐ[μ] (fun ω => q * (Y ω * I ω)) := MeasureTheory.ae_of_ae_restrict_of_ae_restrict_compl s h_on h_off have hmean : mY * cellMass μ G T_rv g t = ∫ ω, Y ω * I ω ∂μ := by simpa [mY, cellMean, I, s] using (panel_cell_integral_div_mul_cellMass μ Y G T_rv G_meas T_meas g t) calc ∫ ω, (D ω - panelPropensity μ D G T_rv ω) * Y ω * I ω ∂μ = ∫ ω, q * (Y ω * I ω) ∂μ := integral_congr_ae h_ae _ = q * ∫ ω, Y ω * I ω ∂μ := integral_const_mul q (fun ω => Y ω * I ω) _ = q * (mY * cellMass μ G T_rv g t) := by rw [hmean] _ = cellMass μ G T_rv g t * q * mY := by ring
Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.num_per_cell_panel · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/PerCell.lean:120 · uses cellMass , cellMean , panelDtilde , panelPropensity
1 supporting declaration (lemmas, instances)
  • denom_per_cell_panel theorem — Per-cell denominator identity. On the cell {G = g ∧ T_rv = t}, (D - panelPropensity)(ω) = panelDtilde μ D G T_rv g t; squaring and integrating over the cell gives
    D :
    Ω → ℝ
    G :
    Ω → 𝒢
    T_rv :
    Ω → Fin T
    G_meas :
    T_meas :
    g :
    𝒢
    t :
    Fin T
    hD_cell :
    ∀ᵐ ω ∂μ.restrict {ω' | G ω' = g ∧ T_rv ω' = t},
    D ω
    = (∫ ω', D ω' * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω' ∂μ) / cellMass μ G T_rv g t
    ∫ ω, (D ω - panelPropensity μ D G T_rv ω) * (D ω - panelPropensity μ D G T_rv ω) * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ
    = cellMass μ G T_rv g t * (panelDtilde μ D G T_rv g t)^2
    Proof (Lean source)
    theorem denom_per_cell_panel (μ : Measure Ω) [IsFiniteMeasure μ] (D : Ω → ℝ) (G : Ω → 𝒢) (T_rv : Ω → Fin T) (G_meas : Measurable G) (T_meas : Measurable T_rv) (g : 𝒢) (t : Fin T) (hD_cell : ∀ᵐ ω ∂μ.restrict {ω' | G ω' = g ∧ T_rv ω' = t}, D ω = (∫ ω', D ω' * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω' ∂μ) / cellMass μ G T_rv g t) : ∫ ω, (D ω - panelPropensity μ D G T_rv ω) * (D ω - panelPropensity μ D G T_rv ω) * indicator {ω' | G ω' = g ∧ T_rv ω' = t} (fun _ => (1 : ℝ)) ω ∂μ = cellMass μ G T_rv g t * (panelDtilde μ D G T_rv g t)^2 := by classical let s : Set Ω := {ω | G ω = g ∧ T_rv ω = t} let I : Ω → ℝ := fun ω => indicator s (fun _ => (1 : ℝ)) ω let q : ℝ := panelDtilde μ D G T_rv g t have hs : MeasurableSet s := by have hG : MeasurableSet {ω : Ω | G ω = g} := G_meas (measurableSet_singleton g) have hT : MeasurableSet {ω : Ω | T_rv ω = t} := T_meas (measurableSet_singleton t) simpa [s, Set.inter_def] using hG.inter hT change ∫ ω, (D ω - panelPropensity μ D G T_rv ω) * (D ω - panelPropensity μ D G T_rv ω) * I ω ∂μ = cellMass μ G T_rv g t * q^2 have h_on : (fun ω => (D ω - panelPropensity μ D G T_rv ω) * (D ω - panelPropensity μ D G T_rv ω) * I ω) =ᵐ[μ.restrict s] (fun ω => q^2 * I ω) := by filter_upwards [hD_cell, MeasureTheory.ae_restrict_mem hs] with ω hDω hωs rcases hωs with ⟨hGω, hTω⟩ have hpω : panelPropensity μ D G T_rv ω = panelPropensityHat μ D G T_rv g t := panelPropensity_eq_hat_of_mem μ D G T_rv hGω hTω have hres : D ω - panelPropensity μ D G T_rv ω = q := by rw [hDω, hpω] simp [q, panelDtilde] simp [I, s, hGω, hTω, hres, pow_two] have h_off : (fun ω => (D ω - panelPropensity μ D G T_rv ω) * (D ω - panelPropensity μ D G T_rv ω) * I ω) =ᵐ[μ.restrict sᶜ] (fun ω => q^2 * I ω) := by rw [EventuallyEq, MeasureTheory.ae_restrict_iff' hs.compl] filter_upwards with ω hωs have hω_not_s : ω ∉ s := by simpa using hωs simp [I, indicator, hω_not_s] have h_ae : (fun ω => (D ω - panelPropensity μ D G T_rv ω) * (D ω - panelPropensity μ D G T_rv ω) * I ω) =ᵐ[μ] (fun ω => q^2 * I ω) := MeasureTheory.ae_of_ae_restrict_of_ae_restrict_compl s h_on h_off calc ∫ ω, (D ω - panelPropensity μ D G T_rv ω) * (D ω - panelPropensity μ D G T_rv ω) * I ω ∂μ = ∫ ω, q^2 * I ω ∂μ := integral_congr_ae h_ae _ = q^2 * ∫ ω, I ω ∂μ := integral_const_mul (q^2) I _ = q^2 * cellMass μ G T_rv g t := by rw [integral_panel_cell_indicator_one_eq_cellMass μ G T_rv G_meas T_meas g t] _ = cellMass μ G T_rv g t * q^2 := by ring
    Causalean.Panel.EstimandCharacterization.StaggeredTWFEDecomposition.denom_per_cell_panel · Causalean/Panel/EstimandCharacterization/StaggeredTWFEDecomposition/Support/PerCell.lean:48