Stat.Sample.Stratified.Treatment­Regression

This module collects finite-sample design, occupancy, residual-noise, and clipped-risk bounds for within-cell treatment regression under arbitrary finite categorical covariate distributions.

Basic 14 core · 9 supporting Counts, empirical treatment fractions, the residualized treatment Gram sum, and the real-outcome regression estimator for an arbitrary finite cell type. ★ observed_design_pushforward

Categorical within-cell regression statistics

Counts, empirical treatment fractions, the residualized treatment Gram sum, and the real-outcome regression estimator for an arbitrary finite cell type. Empty cells contribute zero and the estimator is zero when the Gram sum is zero. These definitions are independent of any paper or causal model.

def cellCount reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The cell count of a cell k in a sample of n cell labels x is the number of labels equal to k.

Definition (Lean source)
κ :
Type u_1
shared
n :
ℕ
x :
Fin n → κ
k :
κ
cellCount x k :
ℕ
∑ i, if x i = k then 1 else 0
Causalean.Stat.Sample.Stratified.TreatmentRegression.cellCount · Causalean/Stat/Sample/Stratified/TreatmentRegression/Basic.lean:24
def treatedCount reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The treated count of a cell k in a design d of n cell-treatment pairs is the number of observations whose cell is k and whose treatment is true.

Definition (Lean source)
κ :
Type u_1
shared
n :
ℕ
d :
Fin n → κ × Bool
k :
κ
treatedCount d k :
ℕ
∑ i, if (d i).1 = k ∧ (d i).2 = true then 1 else 0
Causalean.Stat.Sample.Stratified.TreatmentRegression.treatedCount · Causalean/Stat/Sample/Stratified/TreatmentRegression/Basic.lean:29
def repeatCount reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The repeat count of a sample of n cell labels x sums, over all cells, the cell count minus one (truncated at zero): the number of observations beyond the first in each occupied cell.

Definition (Lean source)
κ :
Type u_1
shared
n :
ℕ
x :
Fin n → κ
repeatCount x :
ℕ
∑ k, (cellCount x k - 1)
Causalean.Stat.Sample.Stratified.TreatmentRegression.repeatCount · Causalean/Stat/Sample/Stratified/TreatmentRegression/Basic.lean:34
def treatmentFraction reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The empirical treatment fraction of a cell k in a design d of n cell-treatment pairs is the cell's treated count divided by its count, with value zero at an empty cell.

Definition (Lean source)
κ :
Type u_1
shared
n :
ℕ
d :
Fin n → κ × Bool
k :
κ
treatmentFraction d k :
ℝ
if cellCount (fun i => (d i).1) k
= 0 then 0 else (treatedCount d k : ℝ) / cellCount (fun i => (d i).1) k
Causalean.Stat.Sample.Stratified.TreatmentRegression.treatmentFraction · Causalean/Stat/Sample/Stratified/TreatmentRegression/Basic.lean:40
def cellGram reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The Gram contribution of a cell with total count m and treated count t is t(m − t)/m, with value zero when the cell is empty; the difference m − t is taken in the natural numbers (truncated at zero).

Definition (Lean source)
m t :
ℕ
cellGram m t :
ℝ
if m = 0 then 0 else (t : ℝ) * (m - t : ℕ) / m
Causalean.Stat.Sample.Stratified.TreatmentRegression.cellGram · Causalean/Stat/Sample/Stratified/TreatmentRegression/Basic.lean:47
def gram reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The Gram denominator of a design d of n cell-treatment pairs is the sum over all cells of the cell Gram contributions t(m − t)/m, where m is the cell count and t the treated count (an empty cell contributes zero).

Definition (Lean source)
κ :
Type u_1
shared
n :
ℕ
d :
Fin n → κ × Bool
gram d :
ℝ
∑ k, cellGram (cellCount (fun i => (d i).1) k) (treatedCount d k)
Causalean.Stat.Sample.Stratified.TreatmentRegression.gram · Causalean/Stat/Sample/Stratified/TreatmentRegression/Basic.lean:53
def residualWeight reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The residualized treatment weight of observation i in a design d of n cell-treatment pairs is its treatment indicator minus the empirical treatment fraction of its own cell.

Definition (Lean source)
κ :
Type u_1
shared
n :
ℕ
d :
Fin n → κ × Bool
i :
Fin n
residualWeight d i :
ℝ
(if (d i).2 then (1 : ℝ) else 0) - treatmentFraction d (d i).1
Causalean.Stat.Sample.Stratified.TreatmentRegression.residualWeight · Causalean/Stat/Sample/Stratified/TreatmentRegression/Basic.lean:59
def numerator reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The regression numerator of a design d of n cell-treatment pairs with real outcomes y is the sum over observations of the residualized treatment weight times the outcome.

Definition (Lean source)
κ :
Type u_1
shared
n :
ℕ
d :
Fin n → κ × Bool
y :
Fin n → ℝ
numerator d y :
ℝ
∑ i, residualWeight d i * y i
Causalean.Stat.Sample.Stratified.TreatmentRegression.numerator · Causalean/Stat/Sample/Stratified/TreatmentRegression/Basic.lean:65
def inverseGram reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The guarded inverse Gram of a design d of n cell-treatment pairs is the reciprocal of its Gram denominator when that denominator is positive, and zero otherwise.

Definition (Lean source)
κ :
Type u_1
shared
n :
ℕ
d :
Fin n → κ × Bool
inverseGram d :
ℝ
if 0 < gram d then (gram d)⁻¹ else 0
Causalean.Stat.Sample.Stratified.TreatmentRegression.inverseGram · Causalean/Stat/Sample/Stratified/TreatmentRegression/Basic.lean:71
def regression reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The un-clipped within-cell regression coefficient of real outcomes y on the treatment in a design d of n cell-treatment pairs is the regression numerator divided by the Gram denominator when the latter is positive, and zero otherwise.

Definition (Lean source)
κ :
Type u_1
shared
n :
ℕ
d :
Fin n → κ × Bool
y :
Fin n → ℝ
regression d y :
ℝ
if 0 < gram d then numerator d y / gram d else 0
Causalean.Stat.Sample.Stratified.TreatmentRegression.regression · Causalean/Stat/Sample/Stratified/TreatmentRegression/Basic.lean:76
def clip reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

Interval clipping of a real estimate t at radius R is max(−R, min(R, t)); for nonnegative R this confines t to the symmetric interval from −R to R.

Definition (Lean source)
R t :
ℝ
clip R t :
ℝ
max (-R) (min R t)
Causalean.Stat.Sample.Stratified.TreatmentRegression.clip · Causalean/Stat/Sample/Stratified/TreatmentRegression/Basic.lean:82
def clippedEstimator reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The clipped observed estimator reads the cell label X, the Boolean treatment A and the real outcome Y off each draw of a sample z of n observations, computes the within-cell regression of the outcomes on the treatment, and clips it at radius R.

Definition (Lean source)
κ :
Type u_1
shared
Ω :
Type u_2
shared
n :
ℕ
X :
Ω → κ
A :
Ω → Bool
Y :
Ω → ℝ
R :
ℝ
z :
Fin n → Ω
clippedEstimator X A Y R z :
ℝ
clip R (regression (sampleDesign X A z) (fun i => Y (z i)))
Causalean.Stat.Sample.Stratified.TreatmentRegression.clippedEstimator · Causalean/Stat/Sample/Stratified/TreatmentRegression/Basic.lean:86
def residualRegression reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The regression residual coefficient runs the guarded within-cell regression on a sample z of n observations, with design given by the cell label X and the Boolean treatment A, and with outcome the real outcome Y minus an arm-and-cell centre evaluated at the observation's treatment and cell; it is zero when the Gram denominator is zero.

Definition (Lean source)
κ :
Type u_1
shared
Ω :
Type u_2
shared
n :
ℕ
X :
Ω → κ
A :
Ω → Bool
Y :
Ω → ℝ
center :
Bool → κ → ℝ
z :
Fin n → Ω
residualRegression X A Y center z :
ℝ
regression (sampleDesign X A z) (fun i => Y (z i) - center (A (z i)) (X (z i)))
Causalean.Stat.Sample.Stratified.TreatmentRegression.residualRegression · Causalean/Stat/Sample/Stratified/TreatmentRegression/Basic.lean:94
theorem observed_design_pushforward reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

For n independent draws from a probability law carrying measurable cell and Boolean-treatment labels, the law of the observed design — the vector of the n cell-treatment pairs read off the draws — is the n-fold product of the joint law of one draw's cell and treatment.

Formal statement
κ :
Type u_1
shared
Ω :
Type u_2
shared
n :
ℕ
X :
Ω → κ
A :
Ω → Bool
hX :
hA :
(Measure.pi (fun _ : Fin n => μ)).map (sampleDesign X A)
= Measure.pi (fun _ : Fin n => μ.map (fun ω => (X ω, A ω)))
Proof (Lean source)
theorem observed_design_pushforward (n : ℕ) (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (hX : Measurable X) (hA : Measurable A) : (Measure.pi (fun _ : Fin n => μ)).map (sampleDesign X A) = Measure.pi (fun _ : Fin n => μ.map (fun ω => (X ω, A ω))) := map_pi_finCoordinatewise n μ (hX.prodMk hA)
Causalean.Stat.Sample.Stratified.TreatmentRegression.observed_design_pushforward · Causalean/Stat/Sample/Stratified/TreatmentRegression/Basic.lean:200 · uses sampleDesign
9 supporting declarations (lemmas, instances)
Treatment­Moments 2 core · 4 supporting Explicit enumeration of independent Boolean assignments at fixed categorical labels. ★ assignment_gram_mean_lower

Finite conditional treatment moments

Explicit enumeration of independent Boolean assignments at fixed categorical labels. The expected cell Gram is (N-1)_+ times pi(1-pi), including empty and singleton cells. Bernoulli design moments in Causalean provide the independent one- and two-coordinate expectations; these statements expose the required count and denominator algebra.

def assignmentWeight reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The conditional weight of a treatment assignment a of n Boolean treatments at fixed cell labels x, under cell propensities p, is the product over observations of p at the observation's cell when it is treated and one minus that value when it is not.

Definition (Lean source)
κ :
Type u_1
shared
n :
ℕ
p :
κ → ℝ
x :
Fin n → κ
a :
Fin n → Bool
assignmentWeight p x a :
ℝ
∏ i, if a i then p (x i) else 1 - p (x i)
Causalean.Stat.Sample.Stratified.TreatmentRegression.assignmentWeight · Causalean/Stat/Sample/Stratified/TreatmentRegression/TreatmentMoments.lean:25
theorem assignment_gram_mean_lower reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

Given fixed labels x and cell propensities p, if ε is an overlap margin and every occupied cell has propensity between ε and 1 − ε, then the assignment-weighted sum of the Gram denominator is at least ε(1 − ε) times the repeat count of the labels.

Formal statement
κ :
Type u_1
shared
n :
ℕ
p :
κ → ℝ
x :
Fin n → κ
epsilon :
ℝ
hoverlap :
∀ k
if
0 < cellCount x k
then
epsilon ≤ p k ∧ p k ≤ 1 - epsilon
epsilon * (1 - epsilon) * (repeatCount x : ℝ)
≤ ∑ a : Fin n → Bool, assignmentWeight p x a * gram (fun i => (x i, a i))
Proof (Lean source)
theorem assignment_gram_mean_lower {n : ℕ} (p : κ → ℝ) (x : Fin n → κ) (epsilon : ℝ) (hoverlap : ∀ k, 0 < cellCount x k → epsilon ≤ p k ∧ p k ≤ 1 - epsilon) : epsilon * (1 - epsilon) * (repeatCount x : ℝ) ≤ ∑ a : Fin n → Bool, assignmentWeight p x a * gram (fun i => (x i, a i)) := by rw [assignment_gram_mean] simp only [repeatCount, Nat.cast_sum, Finset.mul_sum] apply Finset.sum_le_sum intro k _ by_cases hk : cellCount x k = 0 · simp [hk] · obtain ⟨hl, hu⟩ := hoverlap k (Nat.pos_of_ne_zero hk) have hv : epsilon * (1 - epsilon) ≤ p k * (1 - p k) := by nlinarith [mul_nonneg (sub_nonneg.mpr hl) (sub_nonneg.mpr hu)] have hn : (0 : ℝ) ≤ (cellCount x k - 1 : ℕ) := Nat.cast_nonneg _ nlinarith [mul_le_mul_of_nonneg_right hv hn]
Causalean.Stat.Sample.Stratified.TreatmentRegression.assignment_gram_mean_lower · Causalean/Stat/Sample/Stratified/TreatmentRegression/TreatmentMoments.lean:225 · uses assignmentWeight , cellCount , gram , repeatCount
4 supporting declarations (lemmas, instances)
  • sum_assignmentWeight lemma — For arbitrary real cell weights p and fixed labels x of n observations, the conditional weights of all Boolean treatment assignments sum to one.
    κ :
    Type u_1
    shared
    n :
    ℕ
    p :
    κ → ℝ
    x :
    Fin n → κ
    (∑ a : Fin n → Bool, assignmentWeight p x a) = 1
    Proof (Lean source)
    lemma sum_assignmentWeight {n : ℕ} (p : κ → ℝ) (x : Fin n → κ) : (∑ a : Fin n → Bool, assignmentWeight p x a) = 1 := by have h := assignment_prod_mean p x (fun _ _ => 1) simpa using h
    Causalean.Stat.Sample.Stratified.TreatmentRegression.sum_assignmentWeight · Causalean/Stat/Sample/Stratified/TreatmentRegression/TreatmentMoments.lean:90
  • assignment_treatedCount_mean lemma — For arbitrary real cell weights p and fixed labels x of n observations, and a cell k, the assignment-weighted sum of the treated count of k equals the cell count of k times p at k.
    κ :
    Type u_1
    shared
    n :
    ℕ
    p :
    κ → ℝ
    x :
    Fin n → κ
    k :
    κ
    (∑ a : Fin n → Bool, assignmentWeight p x a * (treatedCount (fun i => (x i, a i)) k : ℝ))
    = (cellCount x k : ℝ) * p k
    Proof (Lean source)
    lemma assignment_treatedCount_mean {n : ℕ} (p : κ → ℝ) (x : Fin n → κ) (k : κ) : (∑ a : Fin n → Bool, assignmentWeight p x a * (treatedCount (fun i => (x i, a i)) k : ℝ)) = (cellCount x k : ℝ) * p k := by classical have hc (a : Fin n → Bool) : (treatedCount (fun i => (x i, a i)) k : ℝ) = ∑ i, if x i = k then (if a i then (1 : ℝ) else 0) else 0 := by simp only [treatedCount, Nat.cast_sum] apply Finset.sum_congr rfl intro i _ by_cases hx : x i = k <;> by_cases ha : a i = true <;> simp [hx, ha] simp_rw [hc, Finset.mul_sum] rw [Finset.sum_comm] have hm (i : Fin n) : (∑ a : Fin n → Bool, assignmentWeight p x a * (if x i = k then (if a i then (1 : ℝ) else 0) else 0)) = if x i = k then p k else 0 := by by_cases hx : x i = k · simpa [hx] using assignment_coord_mean p x i (fun b => if b then (1 : ℝ) else 0) · simp [hx] simp_rw [hm] simp only [cellCount, Nat.cast_sum, Nat.cast_ite, Nat.cast_one, Nat.cast_zero, Finset.sum_mul, ite_mul, one_mul, zero_mul]
    Causalean.Stat.Sample.Stratified.TreatmentRegression.assignment_treatedCount_mean · Causalean/Stat/Sample/Stratified/TreatmentRegression/TreatmentMoments.lean:98
  • assignment_treated_control_mean lemma — For arbitrary real cell weights p and fixed labels x of n observations, and a cell k, the assignment-weighted sum of the treated count of k times its control count equals N(N − 1)·p(1 − p), where N is the cell count of k, p is the weight at k, and N − 1 is truncated at zero; it is zero in empty and singleton cells.
    κ :
    Type u_1
    shared
    n :
    ℕ
    p :
    κ → ℝ
    x :
    Fin n → κ
    k :
    κ
    (∑ a : Fin n → Bool, assignmentWeight p x a * ((treatedCount (fun i => (x i, a i)) k : ℝ) * (cellCount x k - treatedCount (fun i => (x i, a i)) k : ℕ)))
    = (cellCount x k : ℝ) * (cellCount x k - 1 : ℕ) * p k * (1 - p k)
    Proof (Lean source)
    lemma assignment_treated_control_mean {n : ℕ} (p : κ → ℝ) (x : Fin n → κ) (k : κ) : (∑ a : Fin n → Bool, assignmentWeight p x a * ((treatedCount (fun i => (x i, a i)) k : ℝ) * (cellCount x k - treatedCount (fun i => (x i, a i)) k : ℕ))) = (cellCount x k : ℝ) * (cellCount x k - 1 : ℕ) * p k * (1 - p k) := by classical let S : Finset (Fin n) := Finset.univ.filter (fun i => x i = k) have hs : S.card = cellCount x k := by simp [S, cellCount] have hx {i : Fin n} (hi : i ∈ S) : x i = k := (Finset.mem_filter.mp hi).2 have ht (a : Fin n → Bool) : (treatedCount (fun i => (x i, a i)) k : ℝ) = ∑ i ∈ S, if a i then (1 : ℝ) else 0 := by simp only [treatedCount, Nat.cast_sum, Finset.sum_filter, S] apply Finset.sum_congr rfl intro i _ by_cases hi : x i = k <;> by_cases ha : a i = true <;> simp [hi, ha] have hc (a : Fin n → Bool) : (cellCount x k - treatedCount (fun i => (x i, a i)) k : ℕ) = (∑ i ∈ S, if a i then (0 : ℝ) else 1) := by rw [Nat.cast_sub (treatedCount_le (fun i => (x i, a i)) k), ht, ← hs] have hcard : (S.card : ℝ) = ∑ i ∈ S, (1 : ℝ) := by simp rw [hcard, ← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro i _ by_cases ha : a i = true <;> simp [ha] simp_rw [ht, hc, Finset.sum_mul, Finset.mul_sum] rw [Finset.sum_comm] have hm (i : Fin n) (hi : i ∈ S) (j : Fin n) (hj : j ∈ S) : (∑ a : Fin n → Bool, assignmentWeight p x a * ((if a i then (1 : ℝ) else 0) * (if a j then (0 : ℝ) else 1))) = if j = i then 0 else p k * (1 - p k) := by by_cases hij : j = i · subst j have hz (a : Fin n → Bool) : (if a i then (1 : ℝ) else 0) * (if a i then (0 : ℝ) else 1) = 0 := by by_cases ha : a i = true <;> simp [ha] simp [hz] · simpa [hx hi, hx hj, hij] using assignment_pair_mean p x i j (Ne.symm hij) (fun b => if b then (1 : ℝ) else 0) (fun b => if b then (0 : ℝ) else 1) have hiMean (i : Fin n) (hi : i ∈ S) : (∑ j ∈ S, ∑ a : Fin n → Bool, assignmentWeight p x a * ((if a i then (1 : ℝ) else 0) * (if a j then (0 : ℝ) else 1))) = (S.card - 1 : ℕ) * (p k * (1 - p k)) := by calc _ = ∑ j ∈ S, if j = i then (0 : ℝ) else p k * (1 - p k) := Finset.sum_congr rfl (hm i hi) _ = _ := by rw [← Finset.sum_erase_add _ _ hi] simp only [ite_true, add_zero] calc _ = ∑ _j ∈ S.erase i, p k * (1 - p k) := Finset.sum_congr rfl (fun j hj => if_neg (Finset.ne_of_mem_erase hj)) _ = _ := by simp [Finset.card_erase_of_mem hi] calc _ = ∑ i ∈ S, ∑ j ∈ S, ∑ a : Fin n → Bool, assignmentWeight p x a * ((if a i then (1 : ℝ) else 0) * (if a j then (0 : ℝ) else 1)) := by apply Finset.sum_congr rfl intro i hi rw [Finset.sum_comm] _ = ∑ i ∈ S, (S.card - 1 : ℕ) * (p k * (1 - p k)) := Finset.sum_congr rfl hiMean _ = _ := by simp [hs]; ring
    Causalean.Stat.Sample.Stratified.TreatmentRegression.assignment_treated_control_mean · Causalean/Stat/Sample/Stratified/TreatmentRegression/TreatmentMoments.lean:131
  • assignment_gram_mean theorem — For arbitrary real cell weights p and fixed labels x of n observations, the assignment-weighted sum of the Gram denominator equals the sum over cells of (N − 1)·p(1 − p), where N is the cell count, N − 1 is truncated at zero, and p is the weight at that cell — the repeated counts times the Bernoulli variances.
    κ :
    Type u_1
    shared
    n :
    ℕ
    p :
    κ → ℝ
    x :
    Fin n → κ
    (∑ a : Fin n → Bool, assignmentWeight p x a * gram (fun i => (x i, a i)))
    = ∑ k, (cellCount x k - 1 : ℕ) * p k * (1 - p k)
    Proof (Lean source)
    theorem assignment_gram_mean {n : ℕ} (p : κ → ℝ) (x : Fin n → κ) : (∑ a : Fin n → Bool, assignmentWeight p x a * gram (fun i => (x i, a i))) = ∑ k, (cellCount x k - 1 : ℕ) * p k * (1 - p k) := by classical simp only [gram, Finset.mul_sum] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro k _ by_cases hm : cellCount x k = 0 · simp [cellGram, hm] · have hmR : (cellCount x k : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr hm simp only [cellGram, hm, if_false] simp_rw [← mul_div_assoc] rw [← Finset.sum_div, assignment_treated_control_mean] field_simp
    Causalean.Stat.Sample.Stratified.TreatmentRegression.assignment_gram_mean · Causalean/Stat/Sample/Stratified/TreatmentRegression/TreatmentMoments.lean:204
Categorical­Law 5 core · 6 supporting An arbitrary joint law of a finite cell and a Boolean treatment is disintegrated by explicit finite sums. ★ conditional_gram_mean_lower

Categorical conditioning, including null cells

An arbitrary joint law of a finite cell and a Boolean treatment is disintegrated by explicit finite sums. Treatment propensity is guarded at zero cell mass; zero-mass label vectors have zero product weight. The fixed-label Gram identity is consequently a genuine conditional expectation statement on every occupied label fiber, without requiring overlap in null cells.

def cellProbability reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The cell probability of a cell k under a joint law ν of a cell and a Boolean treatment is the mass ν assigns to that cell, summed over both treatment values, as a real number.

Definition (Lean source)
κ :
Type u_1
shared
ν :
Measure (κ × Bool)
k :
κ
cellProbability ν k :
ℝ
(ν {v | v.1 = k}).toReal
Causalean.Stat.Sample.Stratified.TreatmentRegression.cellProbability · Causalean/Stat/Sample/Stratified/TreatmentRegression/CategoricalLaw.lean:25
def propensity reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The treatment propensity of a cell k under a joint law ν of a cell and a Boolean treatment is the mass of the treated pair (k, true) divided by the cell probability of k, with value zero in a null cell.

Definition (Lean source)
κ :
Type u_1
shared
ν :
Measure (κ × Bool)
k :
κ
propensity ν k :
ℝ
if cellProbability ν k = 0 then 0 else (ν {(k, true)}).toReal / cellProbability ν k
Causalean.Stat.Sample.Stratified.TreatmentRegression.propensity · Causalean/Stat/Sample/Stratified/TreatmentRegression/CategoricalLaw.lean:31
def labelWeight reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The product weight of a fixed vector x of n cell labels under a joint law ν of a cell and a Boolean treatment is the product of the cell probabilities of its labels.

Definition (Lean source)
κ :
Type u_1
shared
n :
ℕ
ν :
Measure (κ × Bool)
x :
Fin n → κ
labelWeight ν x :
ℝ
∏ i, cellProbability ν (x i)
Causalean.Stat.Sample.Stratified.TreatmentRegression.labelWeight · Causalean/Stat/Sample/Stratified/TreatmentRegression/CategoricalLaw.lean:37
def labelFiber reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The label fiber of a vector x of n cell labels is the set of designs of n cell-treatment pairs whose cell coordinates equal x.

Definition (Lean source)
κ :
Type u_1
shared
n :
ℕ
x :
Fin n → κ
labelFiber x :
Set (Fin n → κ × Bool)
{d | ∀ i, (d i).1 = x i}
Causalean.Stat.Sample.Stratified.TreatmentRegression.labelFiber · Causalean/Stat/Sample/Stratified/TreatmentRegression/CategoricalLaw.lean:43
theorem conditional_gram_mean_lower reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

Under the n-fold product of a joint probability law ν of a cell and a Boolean treatment, if a fixed label vector x has positive product weight, ε is an overlap margin and every cell of positive probability has propensity between ε and 1 − ε, then the conditional mean of the Gram denominator given the labels x is at least ε(1 − ε) times the repeat count of x.

Formal statement
κ :
Type u_1
shared
n :
ℕ
x :
Fin n → κ
hx :
0 < labelWeight ν x
epsilon :
ℝ
hoverlap :
∀ k
if
then
epsilon ≤ propensity ν k ∧ propensity ν k ≤ 1 - epsilon
epsilon * (1 - epsilon) * (repeatCount x : ℝ)
≤ (∫ d in labelFiber x, gram d ∂Measure.pi (fun _ : Fin n => ν)) / labelWeight ν x
Proof (Lean source)
theorem conditional_gram_mean_lower (n : ℕ) (ν : Measure (κ × Bool)) [IsProbabilityMeasure ν] (x : Fin n → κ) (hx : 0 < labelWeight ν x) (epsilon : ℝ) (hoverlap : ∀ k, 0 < cellProbability ν k → epsilon ≤ propensity ν k ∧ propensity ν k ≤ 1 - epsilon) : epsilon * (1 - epsilon) * (repeatCount x : ℝ) ≤ (∫ d in labelFiber x, gram d ∂Measure.pi (fun _ : Fin n => ν)) / labelWeight ν x := by have hocc : ∀ k, 0 < cellCount x k → epsilon ≤ propensity ν k ∧ propensity ν k ≤ 1 - epsilon := by intro k hk have hex : ∃ i, x i = k := by by_contra h have hz : cellCount x k = 0 := by simp [cellCount, not_exists.mp h] omega obtain ⟨i, hi⟩ := hex have hn : ∀ j : Fin n, cellProbability ν (x j) ≠ 0 := by intro j exact (Finset.prod_ne_zero_iff.mp (ne_of_gt hx)) j (Finset.mem_univ j) apply hoverlap k rw [← hi] exact lt_of_le_of_ne ENNReal.toReal_nonneg (Ne.symm (hn i)) rw [conditional_gram_mean n ν x hx, ← assignment_gram_mean] exact assignment_gram_mean_lower (propensity ν) x epsilon hocc
6 supporting declarations (lemmas, instances)
Concentration 3 core · 3 supporting In a regression of an outcome on a binary treatment with cell fixed effects, the denominator of the treatment coefficient is the within-cell treatment variation ∑ₖ tₖ (mₖ − tₖ) / mₖ, where cell k holds mₖ observations of ★ observed_gram_lower_tail

Lower-tail bound for within-cell treatment variation

In a regression of an outcome on a binary treatment with cell fixed effects, the denominator of the treatment coefficient is the within-cell treatment variation ∑ₖ tₖ (mₖ − tₖ) / mₖ, where cell k holds mₖ observations of which tₖ are treated. For n i.i.d. draws of (cell, treatment) with at most n cells and propensity in [ε, 1 − ε] in every cell of positive probability (0 < ε ≤ 1/2), this denominator has mean at least ε(1 − ε) n / 4 when n ≥ 2, and falls below ε(1 − ε) n / 8 with probability at most exp(−2 (ε(1 − ε)/8)² n), hence at most C(ε)/n with C(ε) = 1 / (2 (ε(1 − ε)/8)²) for every n ≥ 1. The bounds are uniform over all such laws; the tail bound is McDiarmid's inequality, since replacing one observation changes the denominator by at most one.

Main definitions and results

* gramThreshold, gramTailConstant — the constants ε(1 − ε)/8 and C(ε). * integral_gram_lower — the lower bound on the expected denominator (n ≥ 2). * gram_lower_tail_exp — the exponential lower-tail bound (n ≥ 2). * gram_lower_tail — the C(ε)/n bound for every n ≥ 1; at n = 1 it holds because C(ε) ≥ 1. * observed_gram_lower_tail — the same bound for the design observed from any i.i.d. sample with a measurable cell label and Boolean treatment; no overlap condition is imposed on null cells.

McDiarmid's inequality is taken from Causalean.Stat.Concentration.TailBounds.McDiarmid (formalized in FoML, github.com/auto-res/lean-rademacher).

def gramThreshold reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The good-design Gram threshold per observation at overlap margin ε is ε(1 − ε)/8.

Definition (Lean source)
epsilon :
ℝ
gramThreshold epsilon :
ℝ
epsilon * (1 - epsilon) / 8
Causalean.Stat.Sample.Stratified.TreatmentRegression.gramThreshold · Causalean/Stat/Sample/Stratified/TreatmentRegression/Concentration.lean:43
def gramTailConstant reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The uniform Gram lower-tail constant at overlap margin ε is the reciprocal of twice the squared good-design threshold, 1/(2·(ε(1 − ε)/8)²).

Definition (Lean source)
epsilon :
ℝ
gramTailConstant epsilon :
ℝ
1 / (2 * gramThreshold epsilon ^ 2)
Causalean.Stat.Sample.Stratified.TreatmentRegression.gramTailConstant · Causalean/Stat/Sample/Stratified/TreatmentRegression/Concentration.lean:47
theorem observed_gram_lower_tail reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

Draw n iid observations from a probability law μ carrying a measurable cell label X and a measurable Boolean treatment A. If there is at least one observation, the number of cells is at most n, the overlap margin ε is positive and at most one half, and every cell of positive probability under the joint law of (X, A) has propensity between ε and 1 − ε, then the probability that the Gram denominator of the observed design falls below the good-design threshold times n is at most the uniform Gram lower-tail constant divided by n.

Formal statement
κ :
Type u_1
shared
Ω :
Type u_2
shared
n :
ℕ
X :
Ω → κ
A :
Ω → Bool
hX :
hA :
hn :
0 < n
hcard :
card κ ≤ n
epsilon :
ℝ
hepsilon :
0 < epsilon
hhalf :
epsilon ≤ 1 / 2
hoverlap :
∀ k
if
0 < cellProbability (μ.map (fun ω => (X ω, A ω))) k
then
epsilon ≤ propensity (μ.map (fun ω => (X ω, A ω))) k ∧
propensity (μ.map (fun ω => (X ω, A ω))) k ≤ 1 - epsilon
((Measure.pi (fun _ : Fin n => μ)) {z | gram (sampleDesign X A z) < gramThreshold epsilon * n}).toReal
≤ gramTailConstant epsilon / n
Proof (Lean source)
theorem observed_gram_lower_tail (n : ℕ) (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (hX : Measurable X) (hA : Measurable A) (hn : 0 < n) (hcard : card κ ≤ n) (epsilon : ℝ) (hepsilon : 0 < epsilon) (hhalf : epsilon ≤ 1 / 2) (hoverlap : ∀ k, 0 < cellProbability (μ.map (fun ω => (X ω, A ω))) k → epsilon ≤ propensity (μ.map (fun ω => (X ω, A ω))) k ∧ propensity (μ.map (fun ω => (X ω, A ω))) k ≤ 1 - epsilon) : ((Measure.pi (fun _ : Fin n => μ)) {z | gram (sampleDesign X A z) < gramThreshold epsilon * n}).toReal ≤ gramTailConstant epsilon / n := by let ν := μ.map (fun ω => (X ω, A ω)) have hν : IsProbabilityMeasure ν := Measure.isProbabilityMeasure_map (hX.prodMk hA).aemeasurable have hbad : MeasurableSet {d : Fin n → κ × Bool | gram d < gramThreshold epsilon * n} := measurableSet_lt (measurable_designStatistic gram) measurable_const have hmap := observed_design_pushforward n μ X A hX hA have hevent : (Measure.pi (fun _ : Fin n => μ)) {z | gram (sampleDesign X A z) < gramThreshold epsilon * n} = (Measure.pi (fun _ : Fin n => ν)) {d | gram d < gramThreshold epsilon * n} := by rw [← hmap, Measure.map_apply (measurable_sampleDesign X A hX hA) hbad] rfl rw [hevent] exact gram_lower_tail n ν hn hcard epsilon hepsilon hhalf hoverlap
3 supporting declarations (lemmas, instances)
  • integral_gram_lower theorem — Let the design be n iid draws from a joint probability law ν of a cell and a Boolean treatment. If there are at least two observations, the number of cells is at most n, the overlap margin ε is positive and at most one half, and every cell of positive probability has propensity between ε and 1 − ε, then the expected Gram denominator is at least twice the good-design threshold times n, that is ε(1 − ε)n/4.
    κ :
    Type u_1
    shared
    n :
    ℕ
    hn :
    2 ≤ n
    hcard :
    card κ ≤ n
    epsilon :
    ℝ
    hepsilon :
    0 < epsilon
    hhalf :
    epsilon ≤ 1 / 2
    hoverlap :
    ∀ k
    if
    then
    epsilon ≤ propensity ν k ∧ propensity ν k ≤ 1 - epsilon
    2 * gramThreshold epsilon * n
    ≤ ∫ d : Fin n → κ × Bool, gram d ∂Measure.pi (fun _ : Fin n => ν)
    Proof (Lean source)
    theorem integral_gram_lower (n : ℕ) (ν : Measure (κ × Bool)) [IsProbabilityMeasure ν] (hn : 2 ≤ n) (hcard : card κ ≤ n) (epsilon : ℝ) (hepsilon : 0 < epsilon) (hhalf : epsilon ≤ 1 / 2) (hoverlap : ∀ k, 0 < cellProbability ν k → epsilon ≤ propensity ν k ∧ propensity ν k ≤ 1 - epsilon) : 2 * gramThreshold epsilon * n ≤ ∫ d : Fin n → κ × Bool, gram d ∂Measure.pi (fun _ : Fin n => ν) := by classical let P := Measure.pi (fun _ : Fin n => ν) let Q := ν.map Prod.fst have hQ : IsProbabilityMeasure Q := Measure.isProbabilityMeasure_map measurable_fst.aemeasurable have hfiber (F : (Fin n → κ × Bool) → ℝ) : (∫ d, F d ∂P) = ∑ x : Fin n → κ, ∫ d in labelFiber x, F d ∂P := by simp_rw [← integral_indicator (Set.to_countable _ |>.measurableSet)] rw [← integral_finsetSum _ (fun _ _ => Integrable.of_finite)] apply integral_congr_ae filter_upwards with d have hx (x : Fin n → κ) : d ∈ labelFiber x ↔ x = fun i => (d i).1 := by simp only [labelFiber, mem_ofPred_eq] exact ⟨fun h => funext (fun i => (h i).symm), fun h i => congrFun h.symm i⟩ simp [indicator, hx] have hmass (k : κ) : (Q {k}).toReal = cellProbability ν k := by dsimp only [Q] rw [Measure.map_apply measurable_fst (measurableSet_singleton k)] rfl have hrepeat : (∫ x : Fin n → κ, (repeatCount x : ℝ) ∂Measure.pi (fun _ : Fin n => Q)) = ∑ x : Fin n → κ, labelWeight ν x * (repeatCount x : ℝ) := by rw [integral_fintype Integrable.of_finite] simp [Measure.real, Measure.pi_singleton, ENNReal.toReal_prod, hmass, labelWeight] have hlower (x : Fin n → κ) : epsilon * (1 - epsilon) * (labelWeight ν x * (repeatCount x : ℝ)) ≤ ∫ d in labelFiber x, gram d ∂P := by have hw : 0 ≤ labelWeight ν x := Finset.prod_nonneg (fun _ _ => ENNReal.toReal_nonneg) by_cases hx : 0 < labelWeight ν x · have h := conditional_gram_mean_lower n ν x hx epsilon hoverlap have h' := (le_div_iff₀ hx).mp h simpa [P, mul_assoc, mul_left_comm, mul_comm] using h' · have hz : labelWeight ν x = 0 := le_antisymm (le_of_not_gt hx) hw simp [P, integral_gram_labelFiber, hz] have hoc := integral_repeatCount_lower n Q hn hcard have hp : 0 ≤ epsilon * (1 - epsilon) := mul_nonneg hepsilon.le (by linarith) calc 2 * gramThreshold epsilon * n = epsilon * (1 - epsilon) * ((n : ℝ) / 4) := by unfold gramThreshold ring _ ≤ epsilon * (1 - epsilon) * (∫ x : Fin n → κ, (repeatCount x : ℝ) ∂Measure.pi (fun _ : Fin n => Q)) := mul_le_mul_of_nonneg_left hoc hp _ = ∑ x : Fin n → κ, epsilon * (1 - epsilon) * (labelWeight ν x * (repeatCount x : ℝ)) := by rw [hrepeat, Finset.mul_sum] _ ≤ ∑ x : Fin n → κ, ∫ d in labelFiber x, gram d ∂P := Finset.sum_le_sum (fun x _ => hlower x) _ = ∫ d, gram d ∂P := (hfiber gram).symm
    Causalean.Stat.Sample.Stratified.TreatmentRegression.integral_gram_lower · Causalean/Stat/Sample/Stratified/TreatmentRegression/Concentration.lean:54
  • gram_lower_tail_exp theorem — Let the design be n iid draws from a joint probability law ν of a cell and a Boolean treatment. If there are at least two observations, the number of cells is at most n, the overlap margin ε is positive and at most one half, and every cell of positive probability has propensity between ε and 1 − ε, then the probability that the Gram denominator falls below the good-design threshold times n is at most exp(−2·(ε(1 − ε)/8)²·n), uniformly over all such laws.
    κ :
    Type u_1
    shared
    n :
    ℕ
    hn :
    2 ≤ n
    hcard :
    card κ ≤ n
    epsilon :
    ℝ
    hepsilon :
    0 < epsilon
    hhalf :
    epsilon ≤ 1 / 2
    hoverlap :
    ∀ k
    if
    then
    epsilon ≤ propensity ν k ∧ propensity ν k ≤ 1 - epsilon
    ((Measure.pi (fun _ : Fin n => ν)) {d | gram d < gramThreshold epsilon * n}).toReal
    ≤ exp (-2 * gramThreshold epsilon ^ 2 * n)
    Proof (Lean source)
    theorem gram_lower_tail_exp (n : ℕ) (ν : Measure (κ × Bool)) [IsProbabilityMeasure ν] (hn : 2 ≤ n) (hcard : card κ ≤ n) (epsilon : ℝ) (hepsilon : 0 < epsilon) (hhalf : epsilon ≤ 1 / 2) (hoverlap : ∀ k, 0 < cellProbability ν k → epsilon ≤ propensity ν k ∧ propensity ν k ≤ 1 - epsilon) : ((Measure.pi (fun _ : Fin n => ν)) {d | gram d < gramThreshold epsilon * n}).toReal ≤ exp (-2 * gramThreshold epsilon ^ 2 * n) := by classical have : Nonempty (κ × Bool) := nonempty_of_isProbabilityMeasure ν have hnpos : (0 : ℝ) < n := by exact_mod_cast (by omega : 0 < n) have hgpos : 0 < gramThreshold epsilon := by unfold gramThreshold exact div_pos (mul_pos hepsilon (by linarith)) (by norm_num) let P := Measure.pi (fun _ : Fin n => ν) have hmean := integral_gram_lower n ν hn hcard epsilon hepsilon hhalf hoverlap have ht : (1 / (n : ℝ)) * ∑ _ : Fin n, (1 : ℝ) ^ 2 ≤ 1 := by simp [ne_of_gt hnpos] have hmc := mcdiarmid_inequality_neg (μ := P) (fun (i : Fin n) (d : Fin n → κ × Bool) => d i) (fun i => measurable_pi_apply i) (pi_comp_eval_iIndepFun (μ := ν) (ι := Fin n) measurable_id) gram (fun _ => (1 : ℝ)) (fun i d v => gram_update_oscillation d i v) (measurable_designStatistic gram) (gramThreshold epsilon * n) (mul_nonneg hgpos.le hnpos.le) (1 / n) ht have hmc' : (P {d | gram d - (∫ d, gram d ∂P) ≤ -(gramThreshold epsilon * n)}).toReal ≤ exp (-2 * (gramThreshold epsilon * n) ^ 2 * (1 / n)) := by exact hmc have hsub : {d : Fin n → κ × Bool | gram d < gramThreshold epsilon * n} ⊆ {d | gram d - (∫ d, gram d ∂P) ≤ -(gramThreshold epsilon * n)} := by intro d hd dsimp only [mem_ofPred_eq] at * change 2 * gramThreshold epsilon * n ≤ ∫ d, gram d ∂P at hmean linarith calc _ ≤ (P {d | gram d - (∫ d, gram d ∂P) ≤ -(gramThreshold epsilon * n)}).toReal := ENNReal.toReal_mono (measure_ne_top P _) (measure_mono hsub) _ ≤ exp (-2 * (gramThreshold epsilon * n) ^ 2 * (1 / n)) := hmc' _ = _ := by congr 1 field_simp
    Causalean.Stat.Sample.Stratified.TreatmentRegression.gram_lower_tail_exp · Causalean/Stat/Sample/Stratified/TreatmentRegression/Concentration.lean:120
  • gram_lower_tail theorem — Let the design be n iid draws from a joint probability law ν of a cell and a Boolean treatment. If there is at least one observation, the number of cells is at most n, the overlap margin ε is positive and at most one half, and every cell of positive probability has propensity between ε and 1 − ε, then the probability that the Gram denominator falls below the good-design threshold times n is at most the uniform Gram lower-tail constant divided by n, including the one-observation case.
    κ :
    Type u_1
    shared
    n :
    ℕ
    hn :
    0 < n
    hcard :
    card κ ≤ n
    epsilon :
    ℝ
    hepsilon :
    0 < epsilon
    hhalf :
    epsilon ≤ 1 / 2
    hoverlap :
    ∀ k
    if
    then
    epsilon ≤ propensity ν k ∧ propensity ν k ≤ 1 - epsilon
    ((Measure.pi (fun _ : Fin n => ν)) {d | gram d < gramThreshold epsilon * n}).toReal
    ≤ gramTailConstant epsilon / n
    Proof (Lean source)
    theorem gram_lower_tail (n : ℕ) (ν : Measure (κ × Bool)) [IsProbabilityMeasure ν] (hn : 0 < n) (hcard : card κ ≤ n) (epsilon : ℝ) (hepsilon : 0 < epsilon) (hhalf : epsilon ≤ 1 / 2) (hoverlap : ∀ k, 0 < cellProbability ν k → epsilon ≤ propensity ν k ∧ propensity ν k ≤ 1 - epsilon) : ((Measure.pi (fun _ : Fin n => ν)) {d | gram d < gramThreshold epsilon * n}).toReal ≤ gramTailConstant epsilon / n := by have hnpos : (0 : ℝ) < n := by exact_mod_cast hn have hgpos : 0 < gramThreshold epsilon := by unfold gramThreshold exact div_pos (mul_pos hepsilon (by linarith)) (by norm_num) by_cases hn2 : 2 ≤ n · have hu : 0 < 2 * gramThreshold epsilon ^ 2 * (n : ℝ) := by positivity have hexp : exp (-(2 * gramThreshold epsilon ^ 2 * (n : ℝ))) ≤ 1 / (2 * gramThreshold epsilon ^ 2 * (n : ℝ)) := by rw [Real.exp_neg, ← one_div] apply one_div_le_one_div_of_le hu linarith [Real.add_one_le_exp (2 * gramThreshold epsilon ^ 2 * (n : ℝ))] calc _ ≤ exp (-2 * gramThreshold epsilon ^ 2 * n) := gram_lower_tail_exp n ν hn2 hcard epsilon hepsilon hhalf hoverlap _ ≤ 1 / (2 * gramThreshold epsilon ^ 2 * (n : ℝ)) := by simpa only [neg_mul] using hexp _ = gramTailConstant epsilon / n := by unfold gramTailConstant rw [div_div] · have hn1 : n = 1 := by omega subst n have hgsmall : gramThreshold epsilon ≤ 1 / 8 := by unfold gramThreshold nlinarith [sq_nonneg epsilon] have hdpos : 0 < 2 * gramThreshold epsilon ^ 2 := by positivity have hdsmall : 2 * gramThreshold epsilon ^ 2 ≤ 1 := by nlinarith calc _ ≤ 1 := by exact ENNReal.toReal_mono ENNReal.one_ne_top (prob_le_one) _ ≤ gramTailConstant epsilon / (1 : ℕ) := by simp only [Nat.cast_one, div_one, gramTailConstant] exact (le_div_iff₀ hdpos).mpr (by simpa using hdsmall)
    Causalean.Stat.Sample.Stratified.TreatmentRegression.gram_lower_tail · Causalean/Stat/Sample/Stratified/TreatmentRegression/Concentration.lean:179
Residual 2 core · 4 supporting Arm-cell residuals need only be centered and square integrable with their conditional second moments bounded by M². ★ conditional_regression_error_sq_le

Conditional regression residual second moments

Arm-cell residuals need only be centered and square integrable with their conditional second moments bounded by M². Arbitrary nonnegative functions of the finite observed design can weight the residual regression square. Cross-coordinate terms vanish, and the sum of squared residualized treatment weights equals the Gram, leaving the guarded reciprocal Gram envelope. Conditional moments are stated as normalized positive-mass design-fiber integrals, rather than choosing a conditional-expectation version on null fibers.

structure ResidualAssumptions reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The residual assumptions on an observation law μ with cell label X, Boolean treatment A, real outcome Y, arm-and-cell centres and second-moment envelope M require that the label, the treatment and the outcome are measurable, that on each arm-cell event the residual Y minus its centre is square-integrable, integrates to zero, and has integral of its square at most the event's mass times M². Null arm-cells are allowed; outcomes need not be bounded.

Definition (Lean source)
Ω :
Type u_1
shared
κ :
Type u_2
shared
μ :
X :
Ω → κ
A :
Ω → Bool
Y :
Ω → ℝ
center :
Bool → κ → ℝ
M :
ℝ
X_measurable :
A_measurable :
Y_measurable :
residual_L2 :
∀ a k, MemLp (supportedArmGroupResidual X A Y center a k) 2 μ
residual_centered :
∀ a k, ∫ ω in armGroupEvent X A a k, armGroupResidual Y center a k ω ∂μ = 0
residual_second_moment :
∀ a k,
∫ ω in armGroupEvent X A a k, (armGroupResidual Y center a k ω) ^ 2 ∂μ
≤ (μ (armGroupEvent X A a k)).toReal * M ^ 2
Causalean.Stat.Sample.Stratified.TreatmentRegression.ResidualAssumptions · Causalean/Stat/Sample/Stratified/TreatmentRegression/Residual.lean:31
theorem conditional_regression_error_sq_le reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

If the observation law μ, label X, treatment A, outcome Y, centres and envelope M satisfy the residual assumptions, on every cell of positive probability the treated centre minus the control centre equals a common contrast θ, and a design d of n cell-treatment pairs has positive Gram denominator D and positive probability of being observed, then the conditional mean squared error of the un-clipped regression coefficient about θ, given that the observed design equals d, is at most M²/D.

Formal statement
Ω :
Type u_1
shared
κ :
Type u_2
shared
n :
ℕ
X :
Ω → κ
A :
Ω → Bool
Y :
Ω → ℝ
center :
Bool → κ → ℝ
M theta :
ℝ
h :
ResidualAssumptions μ X A Y center M
hcontrast :
∀ k
if
0 < cellProbability (μ.map (fun ω => (X ω, A ω))) k
then
center true k - center false k = theta
d :
Fin n → κ × Bool
hD :
0 < gram d
hd :
0 < ((Measure.pi (fun _ : Fin n => μ)) {z | sampleDesign X A z = d}).toReal
(∫ z in {z | sampleDesign X A z = d}, (regression (sampleDesign X A z) (fun i => Y (z i)) - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => μ)) / ((Measure.pi (fun _ : Fin n => μ)) {z | sampleDesign X A z = d}).toReal
≤ M ^ 2 / gram d
Proof (Lean source)
theorem conditional_regression_error_sq_le (n : ℕ) (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (Y : Ω → ℝ) (center : Bool → κ → ℝ) (M theta : ℝ) (h : ResidualAssumptions μ X A Y center M) (hcontrast : ∀ k, 0 < cellProbability (μ.map (fun ω => (X ω, A ω))) k → center true k - center false k = theta) (d : Fin n → κ × Bool) (hD : 0 < gram d) (hd : 0 < ((Measure.pi (fun _ : Fin n => μ)) {z | sampleDesign X A z = d}).toReal) : (∫ z in {z | sampleDesign X A z = d}, (regression (sampleDesign X A z) (fun i => Y (z i)) - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => μ)) / ((Measure.pi (fun _ : Fin n => μ)) {z | sampleDesign X A z = d}).toReal ≤ M ^ 2 / gram d := by have hS : MeasurableSet {z : Fin n → Ω | sampleDesign X A z = d} := (measurable_sampleDesign X A h.X_measurable h.A_measurable) (measurableSet_singleton d) have heq : (∫ z in {z | sampleDesign X A z = d}, (regression (sampleDesign X A z) (fun i => Y (z i)) - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => μ)) = ∫ z in {z | sampleDesign X A z = d}, residualRegression X A Y center z ^ 2 ∂Measure.pi (fun _ : Fin n => μ) := by apply integral_congr_ae filter_upwards [ae_restrict_of_ae (ae_sample_cell_positive n μ X A h.X_measurable h.A_measurable), ae_restrict_mem hS] with z hz hzd have hg : 0 < gram (sampleDesign X A z) := by rw [hzd]; exact hD rw [regression_sub_eq_residualRegression X A Y center theta z hg (fun i => hcontrast _ (hz i))] rw [heq] exact conditional_residualRegression_sq_le n μ X A Y center M h d hD hd
Causalean.Stat.Sample.Stratified.TreatmentRegression.conditional_regression_error_sq_le · Causalean/Stat/Sample/Stratified/TreatmentRegression/Residual.lean:194 · uses ResidualAssumptions , cellProbability , gram , regression , sampleDesign
4 supporting declarations (lemmas, instances)
Clip­Bounds 1 core · 1 supporting Clipping a real estimate to a symmetric interval contracts its squared error at every target in that interval and bounds the error by four times the squared interval radius. ★ clip_sq_error_le

Squared-error bounds for interval clipping

Clipping a real estimate to a symmetric interval contracts its squared error at every target in that interval and bounds the error by four times the squared interval radius. These deterministic facts require no sampling law.

lemma clip_sq_error_le reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

If the clipping radius R is nonnegative and the target θ lies in the interval from −R to R, then for every real estimate t the squared error of the clipped estimate about θ is at most the squared error of t about θ.

Formal statement
R t theta :
ℝ
hR :
0 ≤ R
htheta :
theta ∈ Icc (-R) R
(clip R t - theta) ^ 2 ≤ (t - theta) ^ 2
Proof (Lean source)
lemma clip_sq_error_le (R t theta : ℝ) (hR : 0 ≤ R) (htheta : theta ∈ Icc (-R) R) : (clip R t - theta) ^ 2 ≤ (t - theta) ^ 2 := by rcases htheta with ⟨hlo, hhi⟩ unfold clip by_cases hlow : t < -R · rw [min_eq_right (by linarith), max_eq_left (by linarith)] nlinarith [sq_nonneg (t + R)] · by_cases hhigh : R < t · rw [min_eq_left hhigh.le, max_eq_right (by linarith)] nlinarith [sq_nonneg (t - R)] · rw [min_eq_right (le_of_not_gt hhigh), max_eq_right (le_of_not_gt hlow)]
Causalean.Stat.Sample.Stratified.TreatmentRegression.clip_sq_error_le · Causalean/Stat/Sample/Stratified/TreatmentRegression/ClipBounds.lean:18 · uses clip
1 supporting declaration (lemmas, instances)
  • clip_sq_error_le_four lemma — If the clipping radius R is nonnegative and the target θ lies in the interval from −R to R, then for every real estimate t the squared error of the clipped estimate about θ is at most 4R², irrespective of the un-clipped estimate.
    R t theta :
    ℝ
    hR :
    0 ≤ R
    htheta :
    theta ∈ Icc (-R) R
    (clip R t - theta) ^ 2 ≤ 4 * R ^ 2
    Proof (Lean source)
    lemma clip_sq_error_le_four (R t theta : ℝ) (hR : 0 ≤ R) (htheta : theta ∈ Icc (-R) R) : (clip R t - theta) ^ 2 ≤ 4 * R ^ 2 := by rcases htheta with ⟨hlo, hhi⟩ have hcliplo : -R ≤ clip R t := le_max_left _ _ have hcliphi : clip R t ≤ R := max_le (by linarith) (min_le_left _ _) have hdifflo : -(2 * R) ≤ clip R t - theta := by linarith have hdiffhi : clip R t - theta ≤ 2 * R := by linarith nlinarith [mul_nonneg (sub_nonneg.mpr hdiffhi) (sub_nonneg.mpr hdifflo)]
    Causalean.Stat.Sample.Stratified.TreatmentRegression.clip_sq_error_le_four · Causalean/Stat/Sample/Stratified/TreatmentRegression/ClipBounds.lean:36
Design­Algebra 1 core · 10 supporting The Gram is both a sum of squared residualized treatment weights and the treatment-weighted residualized numerator. ★ gram_update_oscillation

Algebra and coordinate oscillation of the categorical Gram denominator

The Gram is both a sum of squared residualized treatment weights and the treatment-weighted residualized numerator. Adding a single observation to a cell changes its Gram by a number in [0,1]; deleting and adding an observation therefore gives a coordinate-replacement oscillation bound of one.

theorem gram_update_oscillation reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

For a design d of n cell-treatment pairs, replacing the observation at a coordinate i by any cell-treatment pair v changes the Gram denominator by at most one in absolute value.

Formal statement
κ :
Type u_1
shared
n :
ℕ
d :
Fin n → κ × Bool
i :
Fin n
v :
κ × Bool
|gram d - gram (update d i v)| ≤ 1
Proof (Lean source)
theorem gram_update_oscillation {n : ℕ} (d : Fin n → κ × Bool) (i : Fin n) (v : κ × Bool) : |gram d - gram (update d i v)| ≤ 1 := by classical let s : Finset (Fin n) := Finset.univ.erase i let m (k : κ) : ℕ := ∑ j ∈ s, if (d j).1 = k then 1 else 0 let t (k : κ) : ℕ := ∑ j ∈ s, if (d j).1 = k ∧ (d j).2 = true then 1 else 0 have ht (k : κ) : t k ≤ m k := by apply Finset.sum_le_sum intro j hj by_cases hk : (d j).1 = k <;> by_cases ha : (d j).2 = true <;> simp [hk, ha] have hcounts (w : κ × Bool) (k : κ) : cellCount (fun j => (update d i w j).1) k = m k + (if w.1 = k then 1 else 0) ∧ treatedCount (update d i w) k = t k + if w.1 = k ∧ w.2 = true then 1 else 0 := by constructor · rw [cellCount, ← Finset.sum_erase_add _ _ (Finset.mem_univ i)] simp only [Function.update_self] congr 1 apply Finset.sum_congr rfl intro j hj have hji : j ≠ i := (Finset.mem_erase.mp hj).1 simp [Function.update_of_ne hji] · rw [treatedCount, ← Finset.sum_erase_add _ _ (Finset.mem_univ i)] simp only [Function.update_self] congr 1 apply Finset.sum_congr rfl intro j hj have hji : j ≠ i := (Finset.mem_erase.mp hj).1 simp [Function.update_of_ne hji] have hg (w : κ × Bool) : gram (update d i w) = ∑ k, cellGram (m k + if w.1 = k then 1 else 0) (t k + if w.1 = k ∧ w.2 = true then 1 else 0) := by unfold gram apply Finset.sum_congr rfl intro k hk rw [(hcounts w k).1, (hcounts w k).2] have hold := sum_cellGram_add m t ht (d i) have hnew := sum_cellGram_add m t ht v rw [← hg (d i), Function.update_eq_self] at hold rw [← hg v] at hnew rw [abs_le] constructor <;> linarith [hold.1, hold.2, hnew.1, hnew.2]
Causalean.Stat.Sample.Stratified.TreatmentRegression.gram_update_oscillation · Causalean/Stat/Sample/Stratified/TreatmentRegression/DesignAlgebra.lean:248 · uses gram
10 supporting declarations (lemmas, instances)
  • cellGram_add_treated lemma — If a cell has total count m and treated count t with the treated count not exceeding the total, then adding one treated observation increases the cell Gram contribution by an amount between zero and one, even when the cell was empty.
    m t :
    ℕ
    ht :
    t ≤ m
    conclusion 1
    0 ≤ cellGram (m + 1) (t + 1) - cellGram m t
    conclusion 2
    cellGram (m + 1) (t + 1) - cellGram m t ≤ 1
    Proof (Lean source)
    lemma cellGram_add_treated (m t : ℕ) (ht : t ≤ m) : 0 ≤ cellGram (m + 1) (t + 1) - cellGram m t ∧ cellGram (m + 1) (t + 1) - cellGram m t ≤ 1 := by by_cases hm : m = 0 · subst m have ht0 : t = 0 := Nat.eq_zero_of_le_zero ht subst t simp [cellGram] have hmpos : (0 : ℝ) < m := by exact_mod_cast Nat.pos_of_ne_zero hm have hmp : (0 : ℝ) < (m : ℝ) + 1 := by positivity have htr : (t : ℝ) ≤ m := by exact_mod_cast ht have htpos : (0 : ℝ) ≤ t := by positivity have heq : cellGram (m + 1) (t + 1) - cellGram m t = ((m : ℝ) - t) ^ 2 / ((m : ℝ) * (m + 1)) := by simp [cellGram, hm, Nat.cast_sub ht, Nat.add_sub_add_right, Nat.cast_add, Nat.cast_one] field_simp ring rw [heq] constructor · positivity · apply (div_le_iff₀ (mul_pos hmpos hmp)).2 nlinarith
    Causalean.Stat.Sample.Stratified.TreatmentRegression.cellGram_add_treated · Causalean/Stat/Sample/Stratified/TreatmentRegression/DesignAlgebra.lean:22
  • cellGram_add_control lemma — If a cell has total count m and treated count t with the treated count not exceeding the total, then adding one control observation increases the cell Gram contribution by an amount between zero and one, even when the cell was empty.
    m t :
    ℕ
    ht :
    t ≤ m
    conclusion 1
    0 ≤ cellGram (m + 1) t - cellGram m t
    conclusion 2
    cellGram (m + 1) t - cellGram m t ≤ 1
    Proof (Lean source)
    lemma cellGram_add_control (m t : ℕ) (ht : t ≤ m) : 0 ≤ cellGram (m + 1) t - cellGram m t ∧ cellGram (m + 1) t - cellGram m t ≤ 1 := by by_cases hm : m = 0 · subst m have ht0 : t = 0 := Nat.eq_zero_of_le_zero ht subst t simp [cellGram] have hmpos : (0 : ℝ) < m := by exact_mod_cast Nat.pos_of_ne_zero hm have hmp : (0 : ℝ) < (m : ℝ) + 1 := by positivity have htr : (t : ℝ) ≤ m := by exact_mod_cast ht have htpos : (0 : ℝ) ≤ t := by positivity have heq : cellGram (m + 1) t - cellGram m t = (t : ℝ) ^ 2 / ((m : ℝ) * (m + 1)) := by simp [cellGram, hm, Nat.cast_sub ht, Nat.cast_sub (le_trans ht (le_succ m)), Nat.cast_add, Nat.cast_one] field_simp ring rw [heq] constructor · positivity · apply (div_le_iff₀ (mul_pos hmpos hmp)).2 nlinarith
    Causalean.Stat.Sample.Stratified.TreatmentRegression.cellGram_add_control · Causalean/Stat/Sample/Stratified/TreatmentRegression/DesignAlgebra.lean:53
  • sum_cell_constant lemma — In a design d of n cell-treatment pairs, summing a real constant c over the observations in a cell k gives the cell count of k times c.
    κ :
    Type u_1
    shared
    n :
    ℕ
    d :
    Fin n → κ × Bool
    k :
    κ
    c :
    ℝ
    (∑ i, if (d i).1 = k then c else 0) = (cellCount (fun i => (d i).1) k : ℝ) * c
    Proof (Lean source)
    lemma sum_cell_constant {n : ℕ} (d : Fin n → κ × Bool) (k : κ) (c : ℝ) : (∑ i, if (d i).1 = k then c else 0) = (cellCount (fun i => (d i).1) k : ℝ) * c := by rw [cellCount, Nat.cast_sum, Finset.sum_mul] apply Finset.sum_congr rfl intro i hi split_ifs <;> simp
    Causalean.Stat.Sample.Stratified.TreatmentRegression.sum_cell_constant · Causalean/Stat/Sample/Stratified/TreatmentRegression/DesignAlgebra.lean:86
  • sum_cell_treatment lemma — In a design d of n cell-treatment pairs, summing the treatment indicators over the observations in a cell k gives the treated count of k.
    κ :
    Type u_1
    shared
    n :
    ℕ
    d :
    Fin n → κ × Bool
    k :
    κ
    (∑ i, if (d i).1 = k then (if (d i).2 then (1 : ℝ) else 0) else 0)
    = (treatedCount d k : ℝ)
    Proof (Lean source)
    lemma sum_cell_treatment {n : ℕ} (d : Fin n → κ × Bool) (k : κ) : (∑ i, if (d i).1 = k then (if (d i).2 then (1 : ℝ) else 0) else 0) = (treatedCount d k : ℝ) := by rw [treatedCount, Nat.cast_sum] apply Finset.sum_congr rfl intro i hi by_cases hk : (d i).1 = k <;> cases (d i).2 <;> simp [hk]
    Causalean.Stat.Sample.Stratified.TreatmentRegression.sum_cell_treatment · Causalean/Stat/Sample/Stratified/TreatmentRegression/DesignAlgebra.lean:97
  • sum_residualWeight_cell lemma — In a design d of n cell-treatment pairs, the residualized treatment weights of the observations in any cell k sum to zero, including in empty cells.
    κ :
    Type u_1
    shared
    n :
    ℕ
    d :
    Fin n → κ × Bool
    k :
    κ
    (∑ i, if (d i).1 = k then residualWeight d i else 0) = 0
    Proof (Lean source)
    lemma sum_residualWeight_cell {n : ℕ} (d : Fin n → κ × Bool) (k : κ) : (∑ i, if (d i).1 = k then residualWeight d i else 0) = 0 := by have heq : (∑ i, if (d i).1 = k then residualWeight d i else 0) = (treatedCount d k : ℝ) - (cellCount (fun i => (d i).1) k : ℝ) * treatmentFraction d k := by rw [← sum_cell_treatment d k, ← sum_cell_constant d k, ← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro i hi by_cases hk : (d i).1 = k <;> simp [residualWeight, hk] rw [heq] have ht := treatedCount_le d k unfold treatmentFraction split_ifs with hm · have ht0 : treatedCount d k = 0 := Nat.eq_zero_of_le_zero (hm ▸ ht) simp [hm, ht0] · have hm' : (cellCount (fun i => (d i).1) k : ℝ) ≠ 0 := by exact_mod_cast hm field_simp ring
    Causalean.Stat.Sample.Stratified.TreatmentRegression.sum_residualWeight_cell · Causalean/Stat/Sample/Stratified/TreatmentRegression/DesignAlgebra.lean:108
  • sum_cell_residual_treatment lemma — In a design d of n cell-treatment pairs, summing the residualized treatment weight times the treatment indicator over the observations in a cell k gives that cell's Gram contribution.
    κ :
    Type u_1
    shared
    n :
    ℕ
    d :
    Fin n → κ × Bool
    k :
    κ
    (∑ i, if (d i).1 = k then residualWeight d i * (if (d i).2 then (1 : ℝ) else 0) else 0)
    = cellGram (cellCount (fun i => (d i).1) k) (treatedCount d k)
    Proof (Lean source)
    lemma sum_cell_residual_treatment {n : ℕ} (d : Fin n → κ × Bool) (k : κ) : (∑ i, if (d i).1 = k then residualWeight d i * (if (d i).2 then (1 : ℝ) else 0) else 0) = cellGram (cellCount (fun i => (d i).1) k) (treatedCount d k) := by have heq : (∑ i, if (d i).1 = k then residualWeight d i * (if (d i).2 then (1 : ℝ) else 0) else 0) = (treatedCount d k : ℝ) * (1 - treatmentFraction d k) := by rw [← sum_cell_treatment d k, Finset.sum_mul] apply Finset.sum_congr rfl intro i hi by_cases hk : (d i).1 = k <;> cases ha : (d i).2 <;> simp [residualWeight, hk, ha] rw [heq] have ht := treatedCount_le d k unfold treatmentFraction cellGram split_ifs with hm · have ht0 : treatedCount d k = 0 := Nat.eq_zero_of_le_zero (hm ▸ ht) simp [ht0] · rw [Nat.cast_sub ht] have hm' : (cellCount (fun i => (d i).1) k : ℝ) ≠ 0 := by exact_mod_cast hm field_simp
    Causalean.Stat.Sample.Stratified.TreatmentRegression.sum_cell_residual_treatment · Causalean/Stat/Sample/Stratified/TreatmentRegression/DesignAlgebra.lean:131
  • sum_residualWeight_sq lemma — For every design d of n cell-treatment pairs, the sum of the squared residualized treatment weights equals the Gram denominator.
    κ :
    Type u_1
    shared
    n :
    ℕ
    d :
    Fin n → κ × Bool
    (∑ i, residualWeight d i ^ 2) = gram d
    Proof (Lean source)
    lemma sum_residualWeight_sq {n : ℕ} (d : Fin n → κ × Bool) : (∑ i, residualWeight d i ^ 2) = gram d := by have hcell (k : κ) : (∑ i, if (d i).1 = k then residualWeight d i ^ 2 else 0) = cellGram (cellCount (fun i => (d i).1) k) (treatedCount d k) := by rw [← sum_cell_residual_treatment d k] have heq : (∑ i, if (d i).1 = k then residualWeight d i ^ 2 else 0) = (∑ i, if (d i).1 = k then residualWeight d i * (if (d i).2 then (1 : ℝ) else 0) else 0) - treatmentFraction d k * (∑ i, if (d i).1 = k then residualWeight d i else 0) := by rw [Finset.mul_sum, ← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro i hi by_cases hk : (d i).1 = k · cases ha : (d i).2 <;> simp [hk, residualWeight, ha] <;> ring · simp [hk] rw [heq, sum_residualWeight_cell, mul_zero, sub_zero] unfold gram simp_rw [← hcell] rw [Finset.sum_comm] simp
    Causalean.Stat.Sample.Stratified.TreatmentRegression.sum_residualWeight_sq · Causalean/Stat/Sample/Stratified/TreatmentRegression/DesignAlgebra.lean:157
  • sum_residualWeight_treatment lemma — For every design d of n cell-treatment pairs, the sum of the treatment indicators weighted by their residualized treatment weights equals the Gram denominator.
    κ :
    Type u_1
    shared
    n :
    ℕ
    d :
    Fin n → κ × Bool
    (∑ i, residualWeight d i * (if (d i).2 then (1 : ℝ) else 0)) = gram d
    Proof (Lean source)
    lemma sum_residualWeight_treatment {n : ℕ} (d : Fin n → κ × Bool) : (∑ i, residualWeight d i * (if (d i).2 then (1 : ℝ) else 0)) = gram d := by unfold gram simp_rw [← sum_cell_residual_treatment d] rw [Finset.sum_comm] simp
    Causalean.Stat.Sample.Stratified.TreatmentRegression.sum_residualWeight_treatment · Causalean/Stat/Sample/Stratified/TreatmentRegression/DesignAlgebra.lean:183
  • gram_le_sample_quarter lemma — For every design d of n cell-treatment pairs, the Gram denominator is at most n/4.
    κ :
    Type u_1
    shared
    n :
    ℕ
    d :
    Fin n → κ × Bool
    gram d ≤ (n : ℝ) / 4
    Proof (Lean source)
    lemma gram_le_sample_quarter {n : ℕ} (d : Fin n → κ × Bool) : gram d ≤ (n : ℝ) / 4 := by have hcell (k : κ) : cellGram (cellCount (fun i => (d i).1) k) (treatedCount d k) ≤ (cellCount (fun i => (d i).1) k : ℝ) / 4 := by have ht := treatedCount_le d k unfold cellGram split_ifs with hm · simp [hm] · rw [Nat.cast_sub ht] have hmpos : (0 : ℝ) < cellCount (fun i => (d i).1) k := by exact_mod_cast Nat.pos_of_ne_zero hm apply (div_le_iff₀ hmpos).2 nlinarith [sq_nonneg ((cellCount (fun i => (d i).1) k : ℝ) - 2 * (treatedCount d k : ℝ))] calc gram d ≤ ∑ k, (cellCount (fun i => (d i).1) k : ℝ) / 4 := Finset.sum_le_sum fun k _ => hcell k _ = (n : ℝ) / 4 := by rw [← Finset.sum_div, ← Nat.cast_sum, sum_cellCount]
    Causalean.Stat.Sample.Stratified.TreatmentRegression.gram_le_sample_quarter · Causalean/Stat/Sample/Stratified/TreatmentRegression/DesignAlgebra.lean:192
  • sum_cellGram_add lemma — If cell total counts m and treated counts t satisfy treated count at most total count in every cell, then adding one observation v increases the summed cell Gram contributions by an amount between zero and one.
    κ :
    Type u_1
    shared
    m t :
    κ → ℕ
    ht :
    ∀ k, t k ≤ m k
    v :
    κ × Bool
    conclusion 1
    0
    ≤ (∑ k, cellGram (m k + if v.1 = k then 1 else 0) (t k + if v.1 = k ∧ v.2 = true then 1 else 0))
    - (∑ k, cellGram (m k) (t k))
    conclusion 2
    (∑ k, cellGram (m k + if v.1 = k then 1 else 0) (t k + if v.1 = k ∧ v.2 = true then 1 else 0))
    - (∑ k, cellGram (m k) (t k))
    ≤ 1
    Proof (Lean source)
    lemma sum_cellGram_add (m t : κ → ℕ) (ht : ∀ k, t k ≤ m k) (v : κ × Bool) : 0 ≤ (∑ k, cellGram (m k + if v.1 = k then 1 else 0) (t k + if v.1 = k ∧ v.2 = true then 1 else 0)) - (∑ k, cellGram (m k) (t k)) ∧ (∑ k, cellGram (m k + if v.1 = k then 1 else 0) (t k + if v.1 = k ∧ v.2 = true then 1 else 0)) - (∑ k, cellGram (m k) (t k)) ≤ 1 := by have heq : (∑ k, cellGram (m k + if v.1 = k then 1 else 0) (t k + if v.1 = k ∧ v.2 = true then 1 else 0)) - (∑ k, cellGram (m k) (t k)) = cellGram (m v.1 + 1) (t v.1 + if v.2 then 1 else 0) - cellGram (m v.1) (t v.1) := by rw [← Finset.sum_sub_distrib] calc _ = ∑ k, if k = v.1 then cellGram (m v.1 + 1) (t v.1 + if v.2 then 1 else 0) - cellGram (m v.1) (t v.1) else 0 := by apply Finset.sum_congr rfl intro k hk by_cases h : k = v.1 · subst k cases v.2 <;> simp · simp [h, Ne.symm h] _ = _ := by simp rw [heq] cases ha : v.2 · simpa [ha] using cellGram_add_control (m v.1) (t v.1) (ht v.1) · simpa [ha] using cellGram_add_treated (m v.1) (t v.1) (ht v.1)
    Causalean.Stat.Sample.Stratified.TreatmentRegression.sum_cellGram_add · Causalean/Stat/Sample/Stratified/TreatmentRegression/DesignAlgebra.lean:215
Observed­Support 1 core · 0 supporting A finite categorical sample almost surely visits only positive-mass cells. ★ ae_sample_cell_positive

Almost-sure support of observed categorical designs

A finite categorical sample almost surely visits only positive-mass cells. This supports occupied-cell assumptions in both conditional residual bounds and risk calculations without imposing assumptions on null cells.

lemma ae_sample_cell_positive reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

An iid sample law and measurable cell and treatment labels ensure that every observed cell has positive population mass almost surely.

Formal statement
Ω :
Type u_1
shared
κ :
Type u_2
shared
n :
ℕ
X :
Ω → κ
A :
Ω → Bool
hX :
hA :
∀ᵐ z : Fin n → Ω ∂Measure.pi (fun _ : Fin n => μ), ∀ i, 0 < cellProbability (μ.map (fun ω => (X ω, A ω))) (X (z i))
Proof (Lean source)
lemma ae_sample_cell_positive (n : ℕ) (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (hX : Measurable X) (hA : Measurable A) : ∀ᵐ z : Fin n → Ω ∂Measure.pi (fun _ : Fin n => μ), ∀ i, 0 < cellProbability (μ.map (fun ω => (X ω, A ω))) (X (z i)) := by let ν : Measure (κ × Bool) := μ.map (fun ω => (X ω, A ω)) let : IsProbabilityMeasure ν := Measure.isProbabilityMeasure_map (hX.prodMk hA).aemeasurable have hv : ∀ᵐ v ∂ν, 0 < cellProbability ν v.1 := by apply ae_iff_of_countable.mpr intro v hv apply ENNReal.toReal_pos _ (measure_ne_top ν _) intro hz have hs : ({v} : Set (κ × Bool)) ⊆ {u | u.1 = v.1} := by rintro u rfl rfl exact hv (measure_mono_null hs hz) have hω : ∀ᵐ ω ∂μ, 0 < cellProbability ν (X ω) := (Measure.tendsto_ae_map (hX.prodMk hA).aemeasurable).eventually hv apply ae_all_iff.mpr intro i have heval := measurePreserving_eval (fun _ : Fin n => μ) i have hmap : ∀ᵐ ω ∂(Measure.pi (fun _ : Fin n => μ)).map (Function.eval i), 0 < cellProbability ν (X ω) := by simpa only [heval.map_eq] using hω exact (Measure.tendsto_ae_map heval.aemeasurable).eventually hmap
Causalean.Stat.Sample.Stratified.TreatmentRegression.ae_sample_cell_positive · Causalean/Stat/Sample/Stratified/TreatmentRegression/ObservedSupport.lean:21 · uses cellProbability
Occupancy 1 core · 2 supporting Under an arbitrary categorical iid law, the expected repeat count is n minus the expected number of occupied cells. ★ integral_repeatCount_lower

Uniform repeat-count expectation

Under an arbitrary categorical iid law, the expected repeat count is n minus the expected number of occupied cells. Convexity of the empty-cell probability shows that the uniform law minimizes repetitions among laws with at most n available cells. For n at least two this gives n/4; at n=1 repetitions are identically zero. Null cells are included throughout.

theorem integral_repeatCount_lower reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

In an iid sample of size n from any probability law Q on cells, if there are at least two observations and the number of cells is at most n, then the expected repeat count is at least n/4.

Formal statement
κ :
Type u_1
shared
n :
ℕ
hn :
2 ≤ n
hcard :
card κ ≤ n
(n : ℝ) / 4 ≤ ∫ x : Fin n → κ, (repeatCount x : ℝ) ∂Measure.pi (fun _ : Fin n => Q)
Proof (Lean source)
theorem integral_repeatCount_lower (n : ℕ) (Q : Measure κ) [IsProbabilityMeasure Q] (hn : 2 ≤ n) (hcard : card κ ≤ n) : (n : ℝ) / 4 ≤ ∫ x : Fin n → κ, (repeatCount x : ℝ) ∂Measure.pi (fun _ : Fin n => Q) := by rw [integral_repeatCount] apply occupancy_polynomial_lower n (fun k => (Q {k}).toReal) hn hcard · intro k exact ENNReal.toReal_nonneg · have hsum : ∑ k, Q {k} = 1 := by simp rw [← ENNReal.toReal_sum (fun k _ => measure_ne_top Q {k}), hsum] simp
Causalean.Stat.Sample.Stratified.TreatmentRegression.integral_repeatCount_lower · Causalean/Stat/Sample/Stratified/TreatmentRegression/Occupancy.lean:84 · uses repeatCount
2 supporting declarations (lemmas, instances)
  • probability_empty_cell lemma — In an iid sample of size n from a probability law Q on cells, the probability that a cell k is empty equals (1 − q)ⁿ, where q is the mass Q gives to k.
    κ :
    Type u_1
    shared
    n :
    ℕ
    k :
    κ
    ((Measure.pi (fun _ : Fin n => Q)) {x | cellCount x k = 0}).toReal
    = (1 - (Q {k}).toReal) ^ n
    Proof (Lean source)
    lemma probability_empty_cell (n : ℕ) (Q : Measure κ) [IsProbabilityMeasure Q] (k : κ) : ((Measure.pi (fun _ : Fin n => Q)) {x | cellCount x k = 0}).toReal = (1 - (Q {k}).toReal) ^ n := by classical have hevent : {x : Fin n → κ | cellCount x k = 0} = Set.univ.pi (fun _ : Fin n => ({k} : Set κ)ᶜ) := by ext x simp [cellCount, Set.mem_pi] rw [hevent, Measure.pi_pi] simp only [Finset.prod_const, Finset.card_univ, Fintype.card_fin, ENNReal.toReal_pow] have hc := probReal_add_probReal_compl (μ := Q) (measurableSet_singleton k) have hreal : (Q ({k}ᶜ)).toReal = 1 - (Q {k}).toReal := by change (Q.real {k}ᶜ) = 1 - Q.real {k} linarith rw [hreal]
    Causalean.Stat.Sample.Stratified.TreatmentRegression.probability_empty_cell · Causalean/Stat/Sample/Stratified/TreatmentRegression/Occupancy.lean:26
  • integral_repeatCount theorem — In an iid sample of size n from any probability law Q on cells, the expected repeat count equals n minus the sum over cells of the occupancy probabilities 1 − (1 − q)ⁿ, where q is the cell's mass; zero-mass cells are included.
    κ :
    Type u_1
    shared
    n :
    ℕ
    (∫ x : Fin n → κ, (repeatCount x : ℝ) ∂Measure.pi (fun _ : Fin n => Q))
    = (n : ℝ) - ∑ k, (1 - (1 - (Q {k}).toReal) ^ n)
    Proof (Lean source)
    theorem integral_repeatCount (n : ℕ) (Q : Measure κ) [IsProbabilityMeasure Q] : (∫ x : Fin n → κ, (repeatCount x : ℝ) ∂Measure.pi (fun _ : Fin n => Q)) = (n : ℝ) - ∑ k, (1 - (1 - (Q {k}).toReal) ^ n) := by classical let μ := Measure.pi (fun _ : Fin n => Q) have hidentity (x : Fin n → κ) : (repeatCount x : ℝ) = (n : ℝ) - ∑ k, (1 - if cellCount x k = 0 then (1 : ℝ) else 0) := by have hcell (k : κ) : ((cellCount x k - 1 : ℕ) : ℝ) = (cellCount x k : ℝ) - (1 - if cellCount x k = 0 then (1 : ℝ) else 0) := by by_cases h : cellCount x k = 0 · simp [h] · simp only [h, if_false, sub_zero] rw [Nat.cast_sub (by omega : 1 ≤ cellCount x k), Nat.cast_one] simp only [repeatCount, Nat.cast_sum, hcell, Finset.sum_sub_distrib] rw [← Nat.cast_sum, sum_cellCount] have hempty (k : κ) : (∫ x : Fin n → κ, (if cellCount x k = 0 then (1 : ℝ) else 0) ∂μ) = (1 - (Q {k}).toReal) ^ n := by have hm : MeasurableSet {x : Fin n → κ | cellCount x k = 0} := Set.to_countable _ |>.measurableSet have hf : (fun x : Fin n → κ => if cellCount x k = 0 then (1 : ℝ) else 0) = {x : Fin n → κ | cellCount x k = 0}.indicator (fun _ => (1 : ℝ)) := by funext x simp [indicator] rw [hf, integral_indicator_const 1 hm] simpa [μ, Measure.real] using probability_empty_cell n Q k simp_rw [hidentity] rw [integral_sub (integrable_const _) Integrable.of_finite, integral_finsetSum _ (fun _ _ => Integrable.of_finite)] simp only [integral_const, Measure.real, measure_univ, ENNReal.toReal_one, smul_eq_mul, one_mul] congr 1 apply Finset.sum_congr rfl intro k hk rw [integral_sub (integrable_const _) Integrable.of_finite, hempty] simp
    Causalean.Stat.Sample.Stratified.TreatmentRegression.integral_repeatCount · Causalean/Stat/Sample/Stratified/TreatmentRegression/Occupancy.lean:45
Occupancy­Scalar 1 core · 1 supporting The empty-cell polynomial for any probability vector with at most n entries has at least n/4 expected repetitions for n at least two. ★ occupancy_polynomial_lower

Scalar occupancy inequalities

The empty-cell polynomial for any probability vector with at most n entries has at least n/4 expected repetitions for n at least two. This module isolates the analytic inequalities from the finite-product probability calculations.

lemma occupancy_polynomial_lower reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

For a sample size n and a vector q of cell masses, if n is at least two, there are at most n cells, and the masses are nonnegative and sum to one, then n minus the sum over cells of 1 − (1 − q)ⁿ — the expected repeat count — is at least n/4.

Formal statement
κ :
Type u_1
shared
n :
ℕ
q :
κ → ℝ
hn :
2 ≤ n
hcard :
card κ ≤ n
hq :
∀ k, 0 ≤ q k
hsum :
∑ k, q k = 1
(n : ℝ) / 4 ≤ (n : ℝ) - ∑ k, (1 - (1 - q k) ^ n)
Proof (Lean source)
lemma occupancy_polynomial_lower (n : ℕ) (q : κ → ℝ) (hn : 2 ≤ n) (hcard : Fintype.card κ ≤ n) (hq : ∀ k, 0 ≤ q k) (hsum : ∑ k, q k = 1) : (n : ℝ) / 4 ≤ (n : ℝ) - ∑ k, (1 - (1 - q k) ^ n) := by classical -- Sum q = 1 excludes the empty type and also bounds each mass by one. have hne : Nonempty κ := by by_contra h have : IsEmpty κ := not_nonempty_iff.mp h simp at hsum have hq1 (k : κ) : q k ≤ 1 := by rw [← hsum] exact Finset.single_le_sum (fun i _ => hq i) (Finset.mem_univ k) have hnR : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) have hn0 : (n : ℝ) ≠ 0 := ne_of_gt hnR have hcR : (Fintype.card κ : ℝ) ≤ n := by exact_mod_cast hcard -- Give each actual complement weight 1/n. All n-card κ zero masses have -- complement one, so combine them into one extra point of weight -- (n-card κ)/n. This is precisely Jensen on the zero-padded vector. have hw : (n - (Fintype.card κ : ℝ)) / n + ∑ k : κ, (1 / (n : ℝ)) = 1 := by simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] field_simp ring have hj := (convexOn_pow (𝕜 := ℝ) n).map_add_sum_le (t := univ) (w := fun _ : κ => 1 / (n : ℝ)) (p := fun k => 1 - q k) (v := (n - (Fintype.card κ : ℝ)) / n) (q := (1 : ℝ)) (fun _ _ => by positivity) (by simpa using hw) (fun k _ => show 0 ≤ 1 - q k from sub_nonneg.mpr (hq1 k)) (div_nonneg (sub_nonneg.mpr hcR) hnR.le) (by simp) have havg : (n - (Fintype.card κ : ℝ)) / n + ∑ k : κ, (1 / (n : ℝ)) * (1 - q k) = 1 - 1 / n := by rw [← Finset.mul_sum, Finset.sum_sub_distrib, hsum] simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] field_simp ring simp only [smul_eq_mul, mul_one, one_pow] at hj rw [havg, ← Finset.mul_sum] at hj have hbound := (uniform_empty_probability_lower n hn).trans hj have hscaled := (mul_le_mul_of_nonneg_left hbound hnR.le) have hcancel : (n : ℝ) * ((n - (Fintype.card κ : ℝ)) / n + 1 / (n : ℝ) * ∑ k, (1 - q k) ^ n) = n - (Fintype.card κ : ℝ) + ∑ k, (1 - q k) ^ n := by field_simp rw [hcancel] at hscaled rw [Finset.sum_sub_distrib] simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] linarith
Causalean.Stat.Sample.Stratified.TreatmentRegression.occupancy_polynomial_lower · Causalean/Stat/Sample/Stratified/TreatmentRegression/OccupancyScalar.lean:71
1 supporting declaration (lemmas, instances)
  • uniform_empty_probability_lower lemma — If the sample size n is at least two, then the empty-cell probability under the uniform law on n cells, (1 − 1/n)ⁿ, is at least one quarter.
    n :
    ℕ
    hn :
    2 ≤ n
    (1 / 4 : ℝ) ≤ (1 - 1 / (n : ℝ)) ^ n
    Proof (Lean source)
    lemma uniform_empty_probability_lower (n : ℕ) (hn : 2 ≤ n) : (1 / 4 : ℝ) ≤ (1 - 1 / (n : ℝ)) ^ n := by -- Induct from the exact value at two. The ratio of consecutive bases is -- 1 + 1/(m²-1); Bernoulli bounds its m-th power from below. induction n, hn using Nat.le_induction with | base => norm_num | succ m hm ih => have hmR : (2 : ℝ) ≤ m := by exact_mod_cast hm have hm0 : (m : ℝ) ≠ 0 := by linarith have hmp : (m : ℝ) + 1 ≠ 0 := by linarith have hd : 0 < (m : ℝ) ^ 2 - 1 := by nlinarith have hb : 0 ≤ 1 - 1 / (m : ℝ) := by rw [sub_nonneg, div_le_iff₀ (by linarith : (0 : ℝ) < m)] linarith have hbern := one_add_mul_le_pow (a := 1 / ((m : ℝ) ^ 2 - 1)) (by have hx : (0 : ℝ) ≤ 1 / ((m : ℝ) ^ 2 - 1) := by positivity linarith) m have hfac : 1 ≤ (1 + (m : ℝ) / ((m : ℝ) ^ 2 - 1)) * (1 - 1 / ((m : ℝ) + 1)) := by field_simp nlinarith have hid : 1 - 1 / ((m : ℝ) + 1) = (1 - 1 / (m : ℝ)) * (1 + 1 / ((m : ℝ) ^ 2 - 1)) := by field_simp ring have hstep : (1 - 1 / (m : ℝ)) ^ m ≤ (1 - 1 / ((m : ℝ) + 1)) ^ (m + 1) := by rw [pow_succ, hid, mul_pow] have hnew : 0 ≤ 1 - 1 / ((m : ℝ) + 1) := by rw [sub_nonneg, div_le_iff₀ (by linarith : (0 : ℝ) < m + 1)] linarith have hmul := mul_le_mul_of_nonneg_right hbern hnew have hprod : 1 ≤ (1 + 1 / ((m : ℝ) ^ 2 - 1)) ^ m * ((1 - 1 / (m : ℝ)) * (1 + 1 / ((m : ℝ) ^ 2 - 1))) := by rw [← hid] exact hfac.trans (by simpa only [div_eq_mul_inv, one_mul] using hmul) nlinarith [mul_nonneg (pow_nonneg hb m) (sub_nonneg.mpr hprod)] exact ih.trans (by simpa only [Nat.cast_add, Nat.cast_one] using hstep)
    Causalean.Stat.Sample.Stratified.TreatmentRegression.uniform_empty_probability_lower · Causalean/Stat/Sample/Stratified/TreatmentRegression/OccupancyScalar.lean:26
Residual­Weights 2 core · 2 supporting This module isolates the square-integrability and variance calculation for a sum of arm-cell residuals with arbitrary coefficients depending on the entire observed categorical design. ★ integral_designWeightedResidual_sq_le

Arbitrary finite-design residual coefficients

This module isolates the square-integrability and variance calculation for a sum of arm-cell residuals with arbitrary coefficients depending on the entire observed categorical design. It imposes no bounded-outcome condition. The regression application takes each coefficient to be the residualized treatment weight times the guarded inverse Gram. No categorical conditioning or Gram tail theorem is needed in this lower dependency layer.

def designWeightedResidual reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

The design-weighted residual sum of a sample z of n observations with cell label X, treatment A and outcome Y adds, over observations, the residual of the outcome from its arm-and-cell centre times a coefficient that may depend on the whole observed design.

Definition (Lean source)
Ω :
Type u_1
shared
κ :
Type u_2
shared
n :
ℕ
X :
Ω → κ
A :
Ω → Bool
Y :
Ω → ℝ
center :
Bool → κ → ℝ
b :
(Fin n → κ × Bool) → Fin n → ℝ
z :
Fin n → Ω
designWeightedResidual X A Y center b z :
ℝ
∑ i, b (sampleDesign X A z) i * (Y (z i) - center (A (z i)) (X (z i)))
Causalean.Stat.Sample.Stratified.TreatmentRegression.designWeightedResidual · Causalean/Stat/Sample/Stratified/TreatmentRegression/ResidualWeights.lean:27
theorem integral_designWeightedResidual_sq_le reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

Under a probability law μ of one observation, suppose the cell label X and the treatment A are measurable, and on each arm-cell event the residual of the outcome Y from its centre is square integrable, integrates to zero, and has integral of its square at most the event's mass times M². Then for any design-dependent coefficients b and any nonnegative weight W on designs of n cell-treatment pairs, the expectation under the iid product law of W at the observed design times the squared design-weighted residual sum is at most M² times the expectation of W times the sum of the squared coefficients.

Formal statement
Ω :
Type u_1
shared
κ :
Type u_2
shared
n :
ℕ
X :
Ω → κ
A :
Ω → Bool
Y :
Ω → ℝ
center :
Bool → κ → ℝ
M :
ℝ
hX :
hA :
hmem :
∀ a k, MemLp (supportedArmGroupResidual X A Y center a k) 2 μ
hcenter :
∀ a k, ∫ ω in armGroupEvent X A a k, armGroupResidual Y center a k ω ∂μ = 0
hsq :
∀ a k,
∫ ω in armGroupEvent X A a k, (armGroupResidual Y center a k ω) ^ 2 ∂μ
≤ (μ (armGroupEvent X A a k)).toReal * M ^ 2
b :
(Fin n → κ × Bool) → Fin n → ℝ
W :
(Fin n → κ × Bool) → ℝ
hW :
∀ d, 0 ≤ W d
(∫ z : Fin n → Ω, W (sampleDesign X A z) * designWeightedResidual X A Y center b z ^ 2 ∂Measure.pi (fun _ : Fin n => μ))
≤ M ^ 2 * ∫ z : Fin n → Ω, W (sampleDesign X A z) * (∑ i, b (sampleDesign X A z) i ^ 2) ∂Measure.pi (fun _ : Fin n => μ)
Proof (Lean source)
theorem integral_designWeightedResidual_sq_le (n : ℕ) (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (Y : Ω → ℝ) (center : Bool → κ → ℝ) (M : ℝ) (hX : Measurable X) (hA : Measurable A) (hmem : ∀ a k, MemLp (supportedArmGroupResidual X A Y center a k) 2 μ) (hcenter : ∀ a k, ∫ ω in armGroupEvent X A a k, armGroupResidual Y center a k ω ∂μ = 0) (hsq : ∀ a k, ∫ ω in armGroupEvent X A a k, (armGroupResidual Y center a k ω) ^ 2 ∂μ ≤ (μ (armGroupEvent X A a k)).toReal * M ^ 2) (b : (Fin n → κ × Bool) → Fin n → ℝ) (W : (Fin n → κ × Bool) → ℝ) (hW : ∀ d, 0 ≤ W d) : (∫ z : Fin n → Ω, W (sampleDesign X A z) * designWeightedResidual X A Y center b z ^ 2 ∂Measure.pi (fun _ : Fin n => μ)) ≤ M ^ 2 * ∫ z : Fin n → Ω, W (sampleDesign X A z) * (∑ i, b (sampleDesign X A z) i ^ 2) ∂Measure.pi (fun _ : Fin n => μ) := by classical let ν := Measure.pi (fun _ : Fin n => μ) let T := Fin n × (Bool × κ) let r : T → (Fin n → Ω) → ℝ := fun t z => supportedArmGroupResidual X A Y center t.2.1 t.2.2 (z t.1) let F : T → T → (Fin n → Ω) → ℝ := fun t u z => W (sampleDesign X A z) * b (sampleDesign X A z) t.1 * b (sampleDesign X A z) u.1 * r t z * r u z let G : T → (Fin n → Ω) → ℝ := fun t z => W (sampleDesign X A z) * b (sampleDesign X A z) t.1 ^ 2 * (armGroupEvent X A t.2.1 t.2.2).indicator (fun _ => (1 : ℝ)) (z t.1) have hr (t : T) : MemLp (r t) 2 ν := (hmem t.2.1 t.2.2).comp_measurePreserving (measurePreserving_eval (fun _ : Fin n => μ) t.1) have hF (t u : T) : Integrable (F t u) ν := by exact (memLp_mul_design μ X A hX hA (r t) (hr t) (fun d => W d * b d t.1 * b d u.1)).integrable_mul (hr u) have hG (t : T) : Integrable (G t) ν := by have hc : MemLp ((armGroupEvent X A t.2.1 t.2.2).indicator (fun _ : Ω => (1 : ℝ))) 2 μ := (memLp_const (1 : ℝ)).indicator (measurableSet_armGroupEvent X A hX hA t.2.1 t.2.2) have hi := hc.comp_measurePreserving (measurePreserving_eval (fun _ : Fin n => μ) t.1) exact (memLp_mul_design μ X A hX hA _ hi (fun d => W d * b d t.1 ^ 2)).integrable (by norm_num) have hexpand (z : Fin n → Ω) : W (sampleDesign X A z) * designWeightedResidual X A Y center b z ^ 2 = ∑ t : T, ∑ u : T, F t u z := by have he : designWeightedResidual X A Y center b z = ∑ t : T, b (sampleDesign X A z) t.1 * r t z := by simp only [designWeightedResidual, T, Fintype.sum_prod_type, r, ← Finset.mul_sum, ← residual_eq_sum_supported X A Y center] rw [he, pow_two, Finset.sum_mul_sum, Finset.mul_sum] apply Finset.sum_congr rfl intro t _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro u _ dsimp [F] ring have hoff (t u : T) (htu : t ≠ u) : ∫ z, F t u z ∂ν = 0 := by by_cases hi : t.1 = u.1 · have hc : t.2 ≠ u.2 := fun hc => htu (Prod.ext hi hc) have hz (z : Fin n → Ω) : F t u z = 0 := by have hh := supportedArmGroupResidual_mul_eq_zero_of_ne X A Y center t.2.1 u.2.1 t.2.2 u.2.2 hc (z t.1) dsimp [F, r] rw [← hi, mul_assoc, hh, mul_zero] simp only [hz, integral_zero] · exact integral_designWeight_residual_cross_coordinates_eq_zero μ X A Y center hX hA hmem hcenter (fun d => W d * b d t.1 * b d u.1) t.1 u.1 hi t.2.1 u.2.1 t.2.2 u.2.2 have hdiag (t : T) : (∫ z, F t t z ∂ν) ≤ M ^ 2 * ∫ z, G t z ∂ν := by have hh := integral_designWeight_residual_sq_le_indicator μ X A Y center M hX hA hmem hsq (fun d => W d * b d t.1 ^ 2) (fun d => mul_nonneg (hW d) (sq_nonneg _)) t.1 t.2.1 t.2.2 convert hh using 1 congr 1 funext z dsimp [F, r] ring have hsumG (z : Fin n → Ω) : (∑ t : T, G t z) = W (sampleDesign X A z) * ∑ i, b (sampleDesign X A z) i ^ 2 := by simp only [T, Fintype.sum_prod_type, G] rw [Finset.mul_sum] apply Finset.sum_congr rfl intro i _ simp only [← Finset.mul_sum] have hind : (∑ a : Bool, ∑ k : κ, (armGroupEvent X A a k).indicator (fun _ => (1 : ℝ)) (z i)) = 1 := by cases ha : A (z i) <;> simp [-Finset.sum_boole, armGroupEvent, Set.indicator_apply, ha] rw [hind, mul_one] calc (∫ z, W (sampleDesign X A z) * designWeightedResidual X A Y center b z ^ 2 ∂ν) = ∑ t : T, ∑ u : T, ∫ z, F t u z ∂ν := by simp only [hexpand] rw [integral_finsetSum _ (fun t _ => integrable_finsetSum _ (fun u _ => hF t u))] apply Finset.sum_congr rfl intro t _ exact integral_finsetSum _ (fun u _ => hF t u) _ = ∑ t : T, ∫ z, F t t z ∂ν := by apply Finset.sum_congr rfl intro t _ exact Finset.sum_eq_single t (fun u _ hut => hoff t u (Ne.symm hut)) (fun ht => (ht (Finset.mem_univ t)).elim) _ ≤ ∑ t : T, M ^ 2 * ∫ z, G t z ∂ν := Finset.sum_le_sum (fun t _ => hdiag t) _ = M ^ 2 * ∫ z, W (sampleDesign X A z) * (∑ i, b (sampleDesign X A z) i ^ 2) ∂ν := by rw [← Finset.mul_sum, ← integral_finsetSum _ (fun t _ => hG t)] simp only [hsumG]
2 supporting declarations (lemmas, instances)
  • designWeightedResidual_memLp lemma — Under a probability law μ of one observation, if the cell label X and the treatment A are measurable, Y is the outcome, and each arm-cell-supported residual from the centres is square integrable, then for every sample size n and every design-dependent coefficient the design-weighted residual sum is square integrable under the iid product law.
    Ω :
    Type u_1
    shared
    κ :
    Type u_2
    shared
    n :
    ℕ
    X :
    Ω → κ
    A :
    Ω → Bool
    Y :
    Ω → ℝ
    center :
    Bool → κ → ℝ
    hX :
    hA :
    hmem :
    ∀ a k, MemLp (supportedArmGroupResidual X A Y center a k) 2 μ
    b :
    (Fin n → κ × Bool) → Fin n → ℝ
    MemLp (designWeightedResidual X A Y center b) 2 (Measure.pi (fun _ : Fin n => μ))
    Proof (Lean source)
    lemma designWeightedResidual_memLp (n : ℕ) (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (Y : Ω → ℝ) (center : Bool → κ → ℝ) (hX : Measurable X) (hA : Measurable A) (hmem : ∀ a k, MemLp (supportedArmGroupResidual X A Y center a k) 2 μ) (b : (Fin n → κ × Bool) → Fin n → ℝ) : MemLp (designWeightedResidual X A Y center b) 2 (Measure.pi (fun _ : Fin n => μ)) := by classical have hr : MemLp (fun ω => Y ω - center (A ω) (X ω)) 2 μ := by have hs := memLp_finsetSum univ (fun (c : Bool × κ) _ => hmem c.1 c.2) simpa only [← residual_eq_sum_supported X A Y center] using hs unfold designWeightedResidual exact memLp_finsetSum univ fun i _ => memLp_mul_design μ X A hX hA _ (hr.comp_measurePreserving (measurePreserving_eval (fun _ : Fin n => μ) i)) (fun d => b d i)
    Causalean.Stat.Sample.Stratified.TreatmentRegression.designWeightedResidual_memLp · Causalean/Stat/Sample/Stratified/TreatmentRegression/ResidualWeights.lean:72
  • residualRegression_eq_designWeightedResidual lemma — For a sample z of n observations with any cell label X, treatment A, outcome Y and arm-and-cell centres, the guarded residual regression coefficient equals the design-weighted residual sum whose coefficients are the guarded inverse Gram times the residualized treatment weights, also at a zero Gram.
    Ω :
    Type u_1
    shared
    κ :
    Type u_2
    shared
    n :
    ℕ
    X :
    Ω → κ
    A :
    Ω → Bool
    Y :
    Ω → ℝ
    center :
    Bool → κ → ℝ
    z :
    Fin n → Ω
    residualRegression X A Y center z
    = designWeightedResidual X A Y center (fun d i => inverseGram d * residualWeight d i) z
    Proof (Lean source)
    lemma residualRegression_eq_designWeightedResidual {n : ℕ} (X : Ω → κ) (A : Ω → Bool) (Y : Ω → ℝ) (center : Bool → κ → ℝ) (z : Fin n → Ω) : residualRegression X A Y center z = designWeightedResidual X A Y center (fun d i => inverseGram d * residualWeight d i) z := by classical unfold residualRegression regression designWeightedResidual numerator inverseGram by_cases hp : 0 < gram (sampleDesign X A z) · simp only [hp, if_pos, Finset.mul_sum, div_eq_mul_inv, Finset.sum_mul] apply Finset.sum_congr rfl intro i _ ring · simp [hp]
    Causalean.Stat.Sample.Stratified.TreatmentRegression.residualRegression_eq_designWeightedResidual · Causalean/Stat/Sample/Stratified/TreatmentRegression/ResidualWeights.lean:238
Risk 1 core · 5 supporting The good-design conditional second moment costs M²/(c n). ★ clipped_regression_mse_le

Finite-sample MSE of clipped within-cell regression

The good-design conditional second moment costs M²/(c n). On the bad event, interval clipping bounds squared error by four times the squared interval radius. Combining the derived Gram tail and residual theorem yields a uniform 1/n risk bound, including D=0, n=1, arbitrary masses, and null cells.

The general theorem allows a clipping radius R distinct from the residual moment envelope M. With R=M and epsilon=1/4 its constant is 33152/9, less than the reference constant 72+4(1296+729/64).

theorem clipped_regression_mse_le reviewed
Causalean.Stat.Sample.Stratified.TreatmentRegression

Suppose the observation law μ, label X, treatment A, outcome Y, centres and envelope M satisfy the residual assumptions, the sample size n is positive and at least the number of cells, the clipping radius R is nonnegative, the target θ lies between −R and R, the overlap margin ε is positive and at most one half, every cell of positive probability has propensity between ε and 1 − ε, and on every such cell the treated centre minus the control centre equals θ. Then the mean squared error of the clipped within-cell regression estimator about θ is at most (M²/c + 4R²·C)/n, where c is the good-design threshold and C the uniform Gram lower-tail constant at ε.

Formal statement
Ω :
Type u_1
shared
κ :
Type u_2
shared
n :
ℕ
X :
Ω → κ
A :
Ω → Bool
Y :
Ω → ℝ
center :
Bool → κ → ℝ
M R theta epsilon :
ℝ
h :
ResidualAssumptions μ X A Y center M
hn :
0 < n
hcard :
card κ ≤ n
hR :
0 ≤ R
htheta :
theta ∈ Icc (-R) R
hepsilon :
0 < epsilon
hhalf :
epsilon ≤ 1 / 2
hoverlap :
∀ k
if
0 < cellProbability (μ.map (fun ω => (X ω, A ω))) k
then
epsilon ≤ propensity (μ.map (fun ω => (X ω, A ω))) k ∧
propensity (μ.map (fun ω => (X ω, A ω))) k ≤ 1 - epsilon
hcontrast :
∀ k
if
0 < cellProbability (μ.map (fun ω => (X ω, A ω))) k
then
center true k - center false k = theta
(∫ z : Fin n → Ω, (clippedEstimator X A Y R z - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => μ))
≤ (M ^ 2 / gramThreshold epsilon + 4 * R ^ 2 * gramTailConstant epsilon) / n
Proof (Lean source)
theorem clipped_regression_mse_le (n : ℕ) (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (Y : Ω → ℝ) (center : Bool → κ → ℝ) (M R theta epsilon : ℝ) (h : ResidualAssumptions μ X A Y center M) (hn : 0 < n) (hcard : card κ ≤ n) (hR : 0 ≤ R) (htheta : theta ∈ Icc (-R) R) (hepsilon : 0 < epsilon) (hhalf : epsilon ≤ 1 / 2) (hoverlap : ∀ k, 0 < cellProbability (μ.map (fun ω => (X ω, A ω))) k → epsilon ≤ propensity (μ.map (fun ω => (X ω, A ω))) k ∧ propensity (μ.map (fun ω => (X ω, A ω))) k ≤ 1 - epsilon) (hcontrast : ∀ k, 0 < cellProbability (μ.map (fun ω => (X ω, A ω))) k → center true k - center false k = theta) : (∫ z : Fin n → Ω, (clippedEstimator X A Y R z - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => μ)) ≤ (M ^ 2 / gramThreshold epsilon + 4 * R ^ 2 * gramTailConstant epsilon) / n := by have hc : 0 < gramThreshold epsilon := by unfold gramThreshold have he : 0 < 1 - epsilon := by linarith exact div_pos (mul_pos hepsilon he) (by norm_num) have hnreal : 0 < (n : ℝ) := Nat.cast_pos.mpr hn have hsplit := integral_clipped_error_sq_le_split n μ X A Y center M R theta (gramThreshold epsilon * n) h hR htheta (mul_pos hc hnreal) hcontrast have htail := observed_gram_lower_tail n μ X A h.X_measurable h.A_measurable hn hcard epsilon hepsilon hhalf hoverlap calc _ ≤ M ^ 2 / (gramThreshold epsilon * n) + 4 * R ^ 2 * ((Measure.pi (fun _ : Fin n => μ)) {z | gram (sampleDesign X A z) < gramThreshold epsilon * n}).toReal := hsplit _ ≤ M ^ 2 / (gramThreshold epsilon * n) + 4 * R ^ 2 * (gramTailConstant epsilon / n) := add_le_add le_rfl (mul_le_mul_of_nonneg_left htail (show 0 ≤ 4 * R ^ 2 by positivity)) _ = _ := by field_simp
5 supporting declarations (lemmas, instances)
  • integrable_clipped_error_sq lemma — Clipped regression squared error is integrable under any finite iid law when the observation maps are measurable, the clipping radius is nonnegative, and the target lies in the clipping interval. The integrability conclusion needs no outcome moment bound.
    Ω :
    Type u_1
    shared
    κ :
    Type u_2
    shared
    n :
    ℕ
    X :
    Ω → κ
    A :
    Ω → Bool
    Y :
    Ω → ℝ
    R theta :
    ℝ
    hX :
    hA :
    hY :
    hR :
    0 ≤ R
    htheta :
    theta ∈ Icc (-R) R
    Integrable (fun z : Fin n → Ω => (clippedEstimator X A Y R z - theta) ^ 2) (Measure.pi (fun _ : Fin n => μ))
    Proof (Lean source)
    lemma integrable_clipped_error_sq (n : ℕ) (μ : Measure Ω) [IsFiniteMeasure μ] (X : Ω → κ) (A : Ω → Bool) (Y : Ω → ℝ) (R theta : ℝ) (hX : Measurable X) (hA : Measurable A) (hY : Measurable Y) (hR : 0 ≤ R) (htheta : theta ∈ Icc (-R) R) : Integrable (fun z : Fin n → Ω => (clippedEstimator X A Y R z - theta) ^ 2) (Measure.pi (fun _ : Fin n => μ)) := by have hm : Measurable (fun z : Fin n → Ω => (clippedEstimator X A Y R z - theta) ^ 2) := ((measurable_clippedEstimator X A Y R hX hA hY).sub measurable_const).pow_const 2 apply Integrable.of_bound hm.aestronglyMeasurable (4 * R ^ 2) filter_upwards [] with z rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)] exact clip_sq_error_le_four R _ theta hR htheta
    Causalean.Stat.Sample.Stratified.TreatmentRegression.integrable_clipped_error_sq · Causalean/Stat/Sample/Stratified/TreatmentRegression/Risk.lean:29
  • integral_good_error_sq_le theorem — Suppose the observation law μ, label X, treatment A, outcome Y, centres and envelope M satisfy the residual assumptions, the clipping radius R is nonnegative, the target θ lies between −R and R, and on every cell of positive probability the treated centre minus the control centre equals θ. Then for every positive Gram threshold t and every sample size n, the integral of the squared error of the clipped estimator about θ over samples whose Gram denominator is at least t is at most M²/t.
    Ω :
    Type u_1
    shared
    κ :
    Type u_2
    shared
    n :
    ℕ
    X :
    Ω → κ
    A :
    Ω → Bool
    Y :
    Ω → ℝ
    center :
    Bool → κ → ℝ
    M R theta t :
    ℝ
    h :
    ResidualAssumptions μ X A Y center M
    hR :
    0 ≤ R
    htheta :
    theta ∈ Icc (-R) R
    ht :
    0 < t
    hcontrast :
    ∀ k
    if
    0 < cellProbability (μ.map (fun ω => (X ω, A ω))) k
    then
    center true k - center false k = theta
    (∫ z in {z : Fin n → Ω | t ≤ gram (sampleDesign X A z)}, (clippedEstimator X A Y R z - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => μ))
    ≤ M ^ 2 / t
    Proof (Lean source)
    theorem integral_good_error_sq_le (n : ℕ) (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (Y : Ω → ℝ) (center : Bool → κ → ℝ) (M R theta t : ℝ) (h : ResidualAssumptions μ X A Y center M) (hR : 0 ≤ R) (htheta : theta ∈ Icc (-R) R) (ht : 0 < t) (hcontrast : ∀ k, 0 < cellProbability (μ.map (fun ω => (X ω, A ω))) k → center true k - center false k = theta) : (∫ z in {z : Fin n → Ω | t ≤ gram (sampleDesign X A z)}, (clippedEstimator X A Y R z - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => μ)) ≤ M ^ 2 / t := by classical let P := Measure.pi (fun _ : Fin n => μ) let S : Set (Fin n → Ω) := {z | t ≤ gram (sampleDesign X A z)} let W : (Fin n → κ × Bool) → ℝ := fun d => if t ≤ gram d then 1 else 0 have hS : MeasurableSet S := measurableSet_le measurable_const ((measurable_designStatistic gram).comp (measurable_sampleDesign X A h.X_measurable h.A_measurable)) have hf := integrable_clipped_error_sq n μ X A Y R theta h.X_measurable h.A_measurable h.Y_measurable hR htheta have hg := (residualRegression_memLp n μ X A Y center M h).integrable_sq have hgood : (∫ z in S, (clippedEstimator X A Y R z - theta) ^ 2 ∂P) ≤ ∫ z in S, residualRegression X A Y center z ^ 2 ∂P := by apply setIntegral_mono_ae_restrict hf.integrableOn hg.integrableOn filter_upwards [ae_restrict_of_ae (ae_sample_cell_positive n μ X A h.X_measurable h.A_measurable), ae_restrict_mem hS] with z hz hzt have hD : 0 < gram (sampleDesign X A z) := lt_of_lt_of_le ht hzt have heq := regression_sub_eq_residualRegression X A Y center theta z hD (fun i => hcontrast _ (hz i)) simpa only [clippedEstimator, heq] using clip_sq_error_le R (regression (sampleDesign X A z) (fun i => Y (z i))) theta hR htheta have hw := integral_weighted_residualRegression_sq_le n μ X A Y center M h W (by intro d; dsimp [W]; split_ifs <;> norm_num) have hleft : (fun z : Fin n → Ω => W (sampleDesign X A z) * residualRegression X A Y center z ^ 2) = S.indicator (fun z => residualRegression X A Y center z ^ 2) := by funext z by_cases hz : t ≤ gram (sampleDesign X A z) <;> simp [W, S, hz] rw [hleft, integral_indicator hS] at hw have hb (z : Fin n → Ω) : 0 ≤ W (sampleDesign X A z) * inverseGram (sampleDesign X A z) ∧ W (sampleDesign X A z) * inverseGram (sampleDesign X A z) ≤ 1 / t := by by_cases hz : t ≤ gram (sampleDesign X A z) · have hD := lt_of_lt_of_le ht hz simpa [W, hz, inverseGram, hD, one_div] using intro (inv_nonneg.mpr hD.le) (one_div_le_one_div_of_le ht hz) · simp [W, hz, le_of_lt ht] have hi : Integrable (fun z : Fin n → Ω => W (sampleDesign X A z) * inverseGram (sampleDesign X A z)) P := by apply Integrable.of_bound (((measurable_designStatistic (fun d => W d * inverseGram d)).comp (measurable_sampleDesign X A h.X_measurable h.A_measurable)).aestronglyMeasurable) (1 / t) filter_upwards [] with z dsimp only [Function.comp_def] rw [Real.norm_eq_abs, abs_of_nonneg (hb z).1] exact (hb z).2 have hbound : (∫ z : Fin n → Ω, W (sampleDesign X A z) * inverseGram (sampleDesign X A z) ∂P) ≤ 1 / t := by calc _ ≤ ∫ _ : Fin n → Ω, (1 / t : ℝ) ∂P := integral_mono_ae hi (integrable_const _) (Filter.Eventually.of_forall (fun z => (hb z).2)) _ = 1 / t := by simp [P] calc _ ≤ ∫ z in S, residualRegression X A Y center z ^ 2 ∂P := hgood _ ≤ M ^ 2 * ∫ z : Fin n → Ω, W (sampleDesign X A z) * inverseGram (sampleDesign X A z) ∂P := hw _ ≤ M ^ 2 * (1 / t) := mul_le_mul_of_nonneg_left hbound (sq_nonneg M) _ = M ^ 2 / t := by ring
    Causalean.Stat.Sample.Stratified.TreatmentRegression.integral_good_error_sq_le · Causalean/Stat/Sample/Stratified/TreatmentRegression/Risk.lean:47
  • integral_clipped_error_sq_le_split theorem — Suppose the observation law μ, label X, treatment A, outcome Y, centres and envelope M satisfy the residual assumptions, the clipping radius R is nonnegative, the target θ lies between −R and R, and on every cell of positive probability the treated centre minus the control centre equals θ. Then for every positive Gram threshold t and every sample size n, the mean squared error of the clipped estimator about θ is at most M²/t plus 4R² times the probability that the Gram denominator is below t. That bad-design probability is subsequently bounded by the Gram lower tail.
    Ω :
    Type u_1
    shared
    κ :
    Type u_2
    shared
    n :
    ℕ
    X :
    Ω → κ
    A :
    Ω → Bool
    Y :
    Ω → ℝ
    center :
    Bool → κ → ℝ
    M R theta t :
    ℝ
    h :
    ResidualAssumptions μ X A Y center M
    hR :
    0 ≤ R
    htheta :
    theta ∈ Icc (-R) R
    ht :
    0 < t
    hcontrast :
    ∀ k
    if
    0 < cellProbability (μ.map (fun ω => (X ω, A ω))) k
    then
    center true k - center false k = theta
    (∫ z : Fin n → Ω, (clippedEstimator X A Y R z - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => μ))
    ≤ M ^ 2 / t
    + 4 * R ^ 2 * ((Measure.pi (fun _ : Fin n => μ)) {z | gram (sampleDesign X A z) < t}).toReal
    Proof (Lean source)
    theorem integral_clipped_error_sq_le_split (n : ℕ) (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (Y : Ω → ℝ) (center : Bool → κ → ℝ) (M R theta t : ℝ) (h : ResidualAssumptions μ X A Y center M) (hR : 0 ≤ R) (htheta : theta ∈ Icc (-R) R) (ht : 0 < t) (hcontrast : ∀ k, 0 < cellProbability (μ.map (fun ω => (X ω, A ω))) k → center true k - center false k = theta) : (∫ z : Fin n → Ω, (clippedEstimator X A Y R z - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => μ)) ≤ M ^ 2 / t + 4 * R ^ 2 * ((Measure.pi (fun _ : Fin n => μ)) {z | gram (sampleDesign X A z) < t}).toReal := by let P := Measure.pi (fun _ : Fin n => μ) let S : Set (Fin n → Ω) := {z | t ≤ gram (sampleDesign X A z)} have hS : MeasurableSet S := measurableSet_le measurable_const ((measurable_designStatistic gram).comp (measurable_sampleDesign X A h.X_measurable h.A_measurable)) have hf := integrable_clipped_error_sq n μ X A Y R theta h.X_measurable h.A_measurable h.Y_measurable hR htheta have hgood := integral_good_error_sq_le n μ X A Y center M R theta t h hR htheta ht hcontrast have hbad : (∫ z in Sᶜ, (clippedEstimator X A Y R z - theta) ^ 2 ∂P) ≤ 4 * R ^ 2 * (P Sᶜ).toReal := by calc _ ≤ ∫ _ : Fin n → Ω in Sᶜ, (4 * R ^ 2 : ℝ) ∂P := by apply setIntegral_mono_ae hf.integrableOn (integrable_const _) filter_upwards [] with z exact clip_sq_error_le_four R _ theta hR htheta _ = 4 * R ^ 2 * (P Sᶜ).toReal := by rw [setIntegral_const, smul_eq_mul] exact mul_comm _ _ have hcompl : Sᶜ = {z | gram (sampleDesign X A z) < t} := by ext z simp [S, not_le] rw [← integral_add_compl hS hf] calc _ ≤ M ^ 2 / t + 4 * R ^ 2 * (P Sᶜ).toReal := add_le_add hgood hbad _ = _ := by rw [hcompl]
    Causalean.Stat.Sample.Stratified.TreatmentRegression.integral_clipped_error_sq_le_split · Causalean/Stat/Sample/Stratified/TreatmentRegression/Risk.lean:137
  • clipped_regression_mse_le_quarter theorem — Suppose the observation law μ, label X, treatment A, outcome Y, centres and envelope M satisfy the residual assumptions, the sample size n is positive and at least the number of cells, the envelope M is nonnegative, the target θ lies between −M and M, every cell of positive probability has propensity between 1/4 and 3/4, and on every such cell the treated centre minus the control centre equals θ. Then the within-cell regression estimator clipped at radius M has mean squared error about θ at most (33152/9)·M²/n, uniformly over cell masses.
    Ω :
    Type u_1
    shared
    κ :
    Type u_2
    shared
    n :
    ℕ
    X :
    Ω → κ
    A :
    Ω → Bool
    Y :
    Ω → ℝ
    center :
    Bool → κ → ℝ
    M theta :
    ℝ
    h :
    ResidualAssumptions μ X A Y center M
    hn :
    0 < n
    hcard :
    card κ ≤ n
    hM :
    0 ≤ M
    htheta :
    theta ∈ Icc (-M) M
    hoverlap :
    ∀ k
    if
    0 < cellProbability (μ.map (fun ω => (X ω, A ω))) k
    then
    (1 / 4 : ℝ) ≤ propensity (μ.map (fun ω => (X ω, A ω))) k ∧
    propensity (μ.map (fun ω => (X ω, A ω))) k ≤ 1 - (1 / 4 : ℝ)
    hcontrast :
    ∀ k
    if
    0 < cellProbability (μ.map (fun ω => (X ω, A ω))) k
    then
    center true k - center false k = theta
    (∫ z : Fin n → Ω, (clippedEstimator X A Y M z - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => μ))
    ≤ (33152 / 9 : ℝ) * M ^ 2 / n
    Proof (Lean source)
    theorem clipped_regression_mse_le_quarter (n : ℕ) (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (Y : Ω → ℝ) (center : Bool → κ → ℝ) (M theta : ℝ) (h : ResidualAssumptions μ X A Y center M) (hn : 0 < n) (hcard : card κ ≤ n) (hM : 0 ≤ M) (htheta : theta ∈ Icc (-M) M) (hoverlap : ∀ k, 0 < cellProbability (μ.map (fun ω => (X ω, A ω))) k → (1 / 4 : ℝ) ≤ propensity (μ.map (fun ω => (X ω, A ω))) k ∧ propensity (μ.map (fun ω => (X ω, A ω))) k ≤ 1 - (1 / 4 : ℝ)) (hcontrast : ∀ k, 0 < cellProbability (μ.map (fun ω => (X ω, A ω))) k → center true k - center false k = theta) : (∫ z : Fin n → Ω, (clippedEstimator X A Y M z - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => μ)) ≤ (33152 / 9 : ℝ) * M ^ 2 / n := by have hmse := clipped_regression_mse_le n μ X A Y center M M theta (1 / 4) h hn hcard hM htheta (by norm_num) (by norm_num) hoverlap hcontrast have hconstant : M ^ 2 / gramThreshold (1 / 4) + 4 * M ^ 2 * gramTailConstant (1 / 4) = (33152 / 9 : ℝ) * M ^ 2 := by norm_num [gramThreshold, gramTailConstant] ring rwa [hconstant] at hmse
    Causalean.Stat.Sample.Stratified.TreatmentRegression.clipped_regression_mse_le_quarter · Causalean/Stat/Sample/Stratified/TreatmentRegression/Risk.lean:247
  • quarter_constant_le_paper lemma — The quarter-overlap risk constant 33152/9 is at most the reference constant 72 + 4(1296 + 729/64).
    (33152 / 9 : ℝ) ≤ 72 + 4 * (1296 + 729 / 64)
    Proof (Lean source)
    lemma quarter_constant_le_paper : (33152 / 9 : ℝ) ≤ 72 + 4 * (1296 + 729 / 64) := by norm_num
    Causalean.Stat.Sample.Stratified.TreatmentRegression.quarter_constant_le_paper · Causalean/Stat/Sample/Stratified/TreatmentRegression/Risk.lean:279