Stat.Linear­Model.OLSAsymptotics

Heteroskedastic OLS asymptotics: population and sample moment objects, sandwich covariance estimators, and score regularity conditions.

Basic 30 core · 2 supporting This module defines the projection coefficient, the ordinary least-squares estimator with a totalized inverse, the heteroskedastic sandwich covariance, and the HC0/HC1 estimators. ★ olsHC0Meat_eq_direct

Population and sample objects for heteroskedastic OLS

This module defines the projection coefficient, the ordinary least-squares estimator with a totalized inverse, the heteroskedastic sandwich covariance, and the HC0/HC1 estimators. A single finite raw-moment vector records every monomial of degree at most four needed by the consistency proofs.

abbrev OLSAugIndex reviewed
Causalean.Stat

For a finite regressor-coordinate type, the augmented OLS coordinate type contains a constant coordinate, the outcome coordinate, and every regressor coordinate.

Definition (Lean source)
K :
Type*
OLSAugIndex K :
Type u_1
abbrev OLSMomentIndex reviewed
Causalean.Stat

For a finite regressor-coordinate type, an OLS raw-moment index selects four augmented coordinates whose product is averaged.

Definition (Lean source)
K :
Type*
OLSMomentIndex K :
Type u_1
abbrev OLSMoment reviewed
Causalean.Stat

For a finite regressor-coordinate type, the OLS raw-moment space assigns a real number to every four-coordinate monomial.

Definition (Lean source)
K :
Type*
OLSMoment K :
Type u_1
OLSMomentIndex K → ℝ
def olsAugmented reviewed
Causalean.Stat

Given a regressor, an outcome and an observation, the augmented OLS coordinate is one for none, the outcome for some none, and the selected regressor for some (some i).

Definition (Lean source)
X K :
Type*
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
z :
X
olsAugmented x y z :
OLSAugIndex K → ℝ
clause 1
| none => 1
clause 2
| some none => y z
clause 3
| some (some i) => x z i
def olsMomentIndex reviewed
Causalean.Stat

Given four augmented coordinates, the corresponding raw moment index places them in slots zero through three.

Definition (Lean source)
K :
Type*
a b c d :
olsMomentIndex a b c d :
clause 1
| 0 => a
clause 2
| 1 => b
clause 3
| 2 => c
clause 4
| 3 => d
def olsRawMoment reviewed
Causalean.Stat

Given a regressor, an outcome, and an observation, the raw OLS moment vector contains every product of four augmented coordinates, with constant coordinates representing lower degree monomials.

Definition (Lean source)
X K :
Type*
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
z :
X
olsRawMoment x y z :
fun a => ∏ t : Fin 4, olsAugmented x y z (a t)
def olsPopulationMoments reviewed
Causalean.Stat

Given a population law, a regressor, and an outcome, the population OLS raw moments are the expectations of all degree-at-most-four augmented monomials.

Definition (Lean source)
X K :
P :
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
olsPopulationMoments P x y :
∫ z, olsRawMoment x y z ∂P
Causalean.Stat.olsPopulationMoments · Causalean/Stat/LinearModel/OLSAsymptotics/Basic.lean:71 · uses OLSMoment
def olsEmpiricalMoments reviewed
Causalean.Stat

Given an iid sample, a regressor, an outcome, and a sample size, the empirical OLS raw moments are the averages of all degree-at-most-four augmented monomials.

Definition (Lean source)
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
n :
ℕ
olsEmpiricalMoments S x y n :
Ω → OLSMoment K
S.sampleMeanVec (olsRawMoment x y) n
def olsQFromMoments reviewed
Causalean.Stat

Given a raw-moment vector, the design second-moment matrix extracts the xᵢxⱼ coordinates.

Definition (Lean source)
K :
Type*
M :
olsQFromMoments M :
Matrix K K ℝ
fun i j => M (olsMomentIndex (some (some i)) (some (some j)) none none)
def olsRFromMoments reviewed
Causalean.Stat

Given a raw-moment vector, the regressor-outcome cross moment extracts the xᵢy coordinates.

Definition (Lean source)
K :
Type*
M :
olsRFromMoments M :
K → ℝ
fun i => M (olsMomentIndex (some (some i)) (some none) none none)
def olsBetaFromMoments reviewed
Causalean.Stat

Given a raw-moment vector, the OLS coefficient is the ordinary inverse of its design moment matrix applied to its regressor-outcome moment, with the ordinary matrix-inverse convention off invertibility.

Definition (Lean source)
K :
M :
olsBetaFromMoments M :
(olsQFromMoments M)⁻¹.toEuclideanLin (toLp 2 (olsRFromMoments M))
def olsQ reviewed
Causalean.Stat

Given a population law, a regressor, and an outcome, the population design moment matrix is E[xx′].

Definition (Lean source)
X K :
P :
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
olsQ P x y :
Matrix K K ℝ
def olsBeta reviewed
Causalean.Stat

Given a population law, a regressor, and an outcome, the population projection coefficient is E[xx′]⁻¹E[xy].

Definition (Lean source)
P :
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
olsBeta P x y :
def olsQHat reviewed
Causalean.Stat

Given an iid sample, a regressor, an outcome, and a sample size, the empirical design moment matrix is the average n⁻¹Σxᵢxᵢ′.

Definition (Lean source)
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
n :
ℕ
olsQHat S x y n :
Ω → Matrix K K ℝ
fun ω => olsQFromMoments (olsEmpiricalMoments S x y n ω)
def olsRHat reviewed
Causalean.Stat

Given an iid sample, a regressor, an outcome, and a sample size, the empirical regressor-outcome moment is the average n⁻¹Σxᵢyᵢ.

Definition (Lean source)
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
n :
ℕ
olsRHat S x y n :
Ω → K → ℝ
fun ω => olsRFromMoments (olsEmpiricalMoments S x y n ω)
def olsBetaHat reviewed
Causalean.Stat

Given an iid sample, a regressor, and an outcome, the ordinary least-squares estimator at each sample size is Q̂⁻¹(n⁻¹Σxᵢyᵢ), using the ordinary matrix-inverse convention when Q̂ is singular.

Definition (Lean source)
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
olsBetaHat S x y :
ℕ → Ω → EuclideanSpace ℝ K
fun n ω => olsBetaFromMoments (olsEmpiricalMoments S x y n ω)
def olsResidual reviewed
Causalean.Stat

Given a regressor, an outcome, a coefficient vector, and an observation, the linear-projection residual is y-x′b.

Definition (Lean source)
X K :
Type*
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
b :
z :
X
olsResidual x y b z :
ℝ
y z - ∑ i, x z i * b i
def olsMeatFromMoments reviewed
Causalean.Stat

Given raw moments and a coefficient vector, the heteroskedastic meat matrix is the polynomial expansion of E[xx′(y-x′b)²].

Definition (Lean source)
K :
Type*
M :
b :
olsMeatFromMoments M b :
Matrix K K ℝ
fun i j
=> M (olsMomentIndex (some (some i)) (some (some j)) (some none) (some none))
- 2 * ∑ l, b l * M (olsMomentIndex (some (some i)) (some (some j)) (some none) (some (some l)))
+ ∑ l, ∑ m, b l * b m * M (olsMomentIndex (some (some i)) (some (some j)) (some (some l)) (some (some m)))
def olsOmega reviewed
Causalean.Stat

Given a population law, a regressor, and an outcome, the heteroskedastic score second-moment matrix is Ω = E[xx′e²] at the population projection coefficient.

Definition (Lean source)
P :
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
olsOmega P x y :
Matrix K K ℝ
def olsAsymptoticCovariance reviewed
Causalean.Stat

Given a population law, a regressor, and an outcome, the heteroskedastic OLS asymptotic covariance is the sandwich V = Q⁻¹ΩQ⁻¹.

Definition (Lean source)
P :
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
olsAsymptoticCovariance P x y :
Matrix K K ℝ
(olsQ P x y)⁻¹ * olsOmega P x y * (olsQ P x y)⁻¹
Causalean.Stat.olsAsymptoticCovariance · Causalean/Stat/LinearModel/OLSAsymptotics/Basic.lean:197
def olsContrastVariance reviewed
Causalean.Stat

Given a square matrix and a contrast vector, the variance of that linear contrast is the quadratic form c′Vc.

Definition (Lean source)
K :
Type*
V :
Matrix K K ℝ
c :
olsContrastVariance V c :
ℝ
∑ i, ∑ j, c i * V i j * c j
def olsHC0MeatDirect reviewed
Causalean.Stat

Given an iid sample, a regressor, an outcome, a sample size, and a sample outcome, the direct HC0 meat matrix is n⁻¹Σxᵢxᵢ′êᵢ², where the residuals use the sample OLS coefficient.

Definition (Lean source)
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
n :
ℕ
ω :
Ω
olsHC0MeatDirect S x y n ω :
Matrix K K ℝ
fun i j
=> (n : ℝ)⁻¹ * ∑ t ∈ range n, x (S.Z t ω) i * x (S.Z t ω) j * olsResidual x y (olsBetaHat S x y n ω) (S.Z t ω) ^ 2
def olsHC0Meat reviewed
Causalean.Stat

Given an iid sample, a regressor, an outcome, a sample size, and a sample outcome, the HC0 meat matrix is the raw-moment polynomial expansion of n⁻¹Σxᵢxᵢ′êᵢ².

Definition (Lean source)
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
n :
ℕ
ω :
Ω
olsHC0Meat S x y n ω :
Matrix K K ℝ
theorem olsHC0Meat_eq_direct reviewed
Causalean.Stat

Given an iid sample, a regressor, an outcome, a sample size, and a sample outcome, the raw-moment HC0 meat equals the textbook residual sum n⁻¹Σxᵢxᵢ′êᵢ².

Formal statement
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
n :
ℕ
ω :
Ω
olsHC0Meat S x y n ω = olsHC0MeatDirect S x y n ω
Proof (Lean source)
theorem olsHC0Meat_eq_direct {Ω X K : Type*} [MeasurableSpace Ω] [MeasurableSpace X] [Fintype K] [DecidableEq K] {μ : Measure Ω} {P : Measure X} (S : IIDSample Ω X μ P) (x : X → EuclideanSpace ℝ K) (y : X → ℝ) (n : ℕ) (ω : Ω) : olsHC0Meat S x y n ω = olsHC0MeatDirect S x y n ω := by ext i j simp [olsHC0Meat, olsHC0MeatDirect, olsMeatFromMoments, olsEmpiricalMoments, IIDSample.sampleMeanVec, olsRawMoment, Fin.prod_univ_four, olsMomentIndex, olsAugmented, olsResidual, smul_eq_mul] rw [show 2 * (∑ l, (olsBetaHat S x y n ω) l * ((n : ℝ)⁻¹ * ∑ t ∈ range n, x (S.Z t ω) i * x (S.Z t ω) j * y (S.Z t ω) * x (S.Z t ω) l)) = 2 * (n : ℝ)⁻¹ * ∑ t ∈ range n, (x (S.Z t ω) i * x (S.Z t ω) j * y (S.Z t ω)) * ∑ l, x (S.Z t ω) l * (olsBetaHat S x y n ω) l by calc _ = 2 * (n : ℝ)⁻¹ * ∑ l, (olsBetaHat S x y n ω) l * ∑ t ∈ range n, (x (S.Z t ω) i * x (S.Z t ω) j * y (S.Z t ω)) * x (S.Z t ω) l := by repeat rw [Finset.mul_sum] apply Finset.sum_congr rfl intro l _ ring _ = _ := by rw [ols_cross_sum]] rw [show (∑ l, ∑ m, (olsBetaHat S x y n ω) l * (olsBetaHat S x y n ω) m * ((n : ℝ)⁻¹ * ∑ t ∈ range n, x (S.Z t ω) i * x (S.Z t ω) j * x (S.Z t ω) l * x (S.Z t ω) m)) = (n : ℝ)⁻¹ * ∑ t ∈ range n, (x (S.Z t ω) i * x (S.Z t ω) j) * (∑ l, x (S.Z t ω) l * (olsBetaHat S x y n ω) l) ^ 2 by calc _ = (n : ℝ)⁻¹ * ∑ l, ∑ m, (olsBetaHat S x y n ω) l * (olsBetaHat S x y n ω) m * ∑ t ∈ range n, (x (S.Z t ω) i * x (S.Z t ω) j) * x (S.Z t ω) l * x (S.Z t ω) m := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro l _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro m _ ring _ = _ := by rw [ols_quad_sum]] repeat rw [Finset.mul_sum] rw [← Finset.sum_sub_distrib, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro t _ ring
def olsHC0 reviewed
Causalean.Stat

Given an iid sample, a regressor, and an outcome, the HC0 covariance estimator at each sample size is the sample sandwich Q̂⁻¹(n⁻¹Σxx′ê²)Q̂⁻¹.

Definition (Lean source)
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
olsHC0 S x y :
ℕ → Ω → Matrix K K ℝ
fun n ω => (olsQHat S x y n ω)⁻¹ * olsHC0Meat S x y n ω * (olsQHat S x y n ω)⁻¹
def olsHC1 reviewed
Causalean.Stat

Given an iid sample, a regressor, and an outcome, the HC1 covariance estimator at each sample size multiplies HC0 by n/(n-k), with ordinary real division providing a total convention at small sample sizes.

Definition (Lean source)
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
olsHC1 S x y :
ℕ → Ω → Matrix K K ℝ
fun n ω => ((n : ℝ) / ((n : ℝ) - card K)) • olsHC0 S x y n ω
def olsScore reviewed
Causalean.Stat

Given a regressor, an outcome, a coefficient vector, and an observation, the OLS score is x(y-x′b).

Definition (Lean source)
X K :
Type*
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
b :
z :
X
olsScore x y b z :
olsResidual x y b z • x z
def olsRegressorFunctional reviewed
Causalean.Stat

Given a regressor and an observation, the regressor functional sends a coefficient increment h to the dot product x′h.

Definition (Lean source)
X K :
Type*
x :
X → EuclideanSpace ℝ K
z :
X
olsRegressorFunctional x z :
EuclideanSpace ℝ K →L[ℝ] ℝ
innerSL ℝ (x z)
Causalean.Stat.olsRegressorFunctional · Causalean/Stat/LinearModel/OLSAsymptotics/Basic.lean:371
def olsScoreDerivative reviewed
Causalean.Stat

Given a regressor and an observation, the observationwise OLS score derivative sends h to -x(x′h).

Definition (Lean source)
X K :
Type*
x :
X → EuclideanSpace ℝ K
z :
X
olsScoreDerivative x z :
EuclideanSpace ℝ K →L[ℝ] EuclideanSpace ℝ K
(-(olsRegressorFunctional x z)).smulRight (x z)
def olsInfluence reviewed
Causalean.Stat

Given a population law, a regressor, an outcome, and an observation, the OLS influence function is Q⁻¹x e.

Definition (Lean source)
P :
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
z :
X
olsInfluence P x y z :
(olsQ P x y)⁻¹.toEuclideanLin (olsScore x y (olsBeta P x y) z)
2 supporting declarations (lemmas, instances)
Score 3 core · 10 supporting This module verifies the smooth Z-estimator assumptions for the linear OLS score. ★ integrable_sq_olsScore

Smooth-score regularity for heteroskedastic OLS

This module verifies the smooth Z-estimator assumptions for the linear OLS score. The observationwise derivative is h ↦ -x(x′h), so its Lipschitz envelope is identically zero.

theorem integrable_sq_olsScore reviewed
Causalean.Stat

For a population law, a regressor and outcome, integrable OLS raw moments through degree four, and a fixed coefficient, the squared norm of the OLS score is integrable.

Formal statement
X :
Type u_1
shared
K :
Type u_2
shared
P :
shared
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
hraw :
b :
Integrable (fun z => ‖olsScore x y b z‖ ^ 2) P
Proof (Lean source)
@[fun_prop] theorem integrable_sq_olsScore {x : X → EuclideanSpace ℝ K} {y : X → ℝ} (hraw : Integrable (olsRawMoment x y) P) (b : EuclideanSpace ℝ K) : Integrable (fun z => ‖olsScore x y b z‖ ^ 2) P := by rw [show (fun z => ‖olsScore x y b z‖ ^ 2) = fun z => ∑ i, (olsScore x y b z i) ^ 2 by funext z exact EuclideanSpace.real_norm_sq_eq _] exact integrable_finsetSum _ fun i _ => integrable_olsScoreCoordinateSq hraw b i
def olsJacobianInverse reviewed
Causalean.Stat

Given a population law, regressors, and an outcome, the inverse OLS score Jacobian is the negative of the linear operator induced by Q⁻¹.

Definition (Lean source)
X :
Type u_1
shared
K :
Type u_2
shared
P :
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
olsJacobianInverse P x y :
EuclideanSpace ℝ K →L[ℝ] EuclideanSpace ℝ K
-((olsQ P x y)⁻¹.toEuclideanLin.toContinuousLinearMap)
def olsSmoothZRegularity reviewed
Causalean.Stat

Under a probability population law, measurable regressors, a measurable outcome, integrable OLS raw moments through degree four, and a positive-definite population design moment, the linear OLS score satisfies the complete smooth Z-estimator regularity package at the projection coefficient.

Definition (Lean source)
X :
Type u_1
shared
K :
Type u_2
shared
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
hx :
hy :
hraw :
hQ :
(olsQ P x y).PosDef
olsSmoothZRegularity hx hy hraw hQ :
clause 1
identification := integral_olsScore_olsBeta hx hy hraw hQ
clause 2
score_meas := measurable_olsScore hx hy _
clause 3
score_finite_var := integrable_sq_olsScore hraw _
clause 4
clause 5
hasFDeriv := fun θ z => hasFDerivAt_olsScore x y θ z
clause 6
deriv_at_target_meas := measurable_olsScoreDerivative hx
clause 7
deriv_at_target_integrable := integrable_olsScoreDerivative_of_rawMoment hx hraw
clause 8
deriv_lipschitz := by refine ⟨1, zero_lt_one, fun _
=> 0, measurable_const, MeasureTheory.integrable_zero X ℝ P, fun _ => le_rfl, ?_⟩ intro θ _ θ' _ z simp
clause 9
jacobianInv := olsJacobianInverse P x y
clause 10
jacobian_inverse := by have hdet : IsUnit (olsQ P x y).det := (Matrix.isUnit_iff_isUnit_det _).mp hQ.isUnit have hmul : olsQ P x y * (olsQ P x y)⁻¹
= 1 := Matrix.mul_nonsing_inv _ hdet rw [integral_olsScoreDerivative hx hraw] ext h i simp [olsJacobianInverse, Matrix.toEuclideanLin_apply, Matrix.mulVec_mulVec, hmul]
10 supporting declarations (lemmas, instances)
Asymptotic­Normality 1 core · 7 supporting This module proves that the data-defined OLS estimator is an exact empirical score root whenever its sample Gram matrix is nonsingular. ★ olsBetaHat_tendsto_normal

Asymptotic normality of heteroskedastic OLS

This module proves that the data-defined OLS estimator is an exact empirical score root whenever its sample Gram matrix is nonsingular. The vector weak law makes the exceptional singular event asymptotically negligible, so the smooth-score Z-estimator theorem yields the heteroskedastic OLS central limit theorem without assuming a CLT or an asymptotic-linear expansion.

theorem olsBetaHat_tendsto_normal reviewed
Causalean.Stat

Heteroskedastic OLS central limit theorem. Under iid sampling, measurable regressors, a measurable outcome, integrable OLS raw moments through degree four, and a positive-definite population Gram matrix, the law of √n(β̂ₙ-β) converges to the centered Gaussian generated by the OLS score influence function.

Formal statement
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
hx :
hy :
hraw :
hQ :
(olsQ P x y).PosDef
reg :
olsSmoothZRegularity hx hy hraw hQ
Tendsto (β := ProbabilityMeasure (EuclideanSpace ℝ K)) (fun n => ⟨μ.map (IsAsymLinearVec.rescaledEstimator (olsBetaHat S x y) (olsBeta P x y) (fun m => range m) n), Measure.isProbabilityMeasure_map (aemeasurable_ols_rescaled S hx hy n)⟩) atTop (𝓝 ⟨gaussianLimit reg.influence_measurable reg.influence_integrable_sq, inferInstance⟩)
Proof (Lean source)
theorem olsBetaHat_tendsto_normal [IsProbabilityMeasure μ] [IsProbabilityMeasure P] (S : IIDSample Ω X μ P) {x : X → EuclideanSpace ℝ K} {y : X → ℝ} (hx : Measurable x) (hy : Measurable y) (hraw : Integrable (olsRawMoment x y) P) (hQ : (olsQ P x y).PosDef) : let reg := olsSmoothZRegularity hx hy hraw hQ Tendsto (β := ProbabilityMeasure (EuclideanSpace ℝ K)) (fun n => ⟨μ.map (IsAsymLinearVec.rescaledEstimator (olsBetaHat S x y) (olsBeta P x y) (fun m => range m) n), Measure.isProbabilityMeasure_map (aemeasurable_ols_rescaled S hx hy n)⟩) atTop (𝓝 ⟨gaussianLimit reg.influence_measurable reg.influence_integrable_sq, inferInstance⟩) := by dsimp only exact zEstimator_tendsto_normal_of_smoothScore (olsScore x y) (olsBeta P x y) P (olsSmoothZRegularity hx hy hraw hQ) S (olsBetaHat S x y) (olsBetaHat_consistent S hx hy hraw hQ) (ols_score_residual_isLittleOp S hx hy hraw hQ) (aemeasurable_ols_rescaled S hx hy)
7 supporting declarations (lemmas, instances)
Consistency 2 core · 6 supporting This module obtains both consistency results from one finite-dimensional weak law for raw moments. ★ olsBetaHat_consistent★ olsHC0_contrast_tendsto_inProb

Consistency of OLS and the HC0 sandwich covariance

This module obtains both consistency results from one finite-dimensional weak law for raw moments. Matrix inversion is used only through its continuity at the positive-definite population design matrix.

theorem olsBetaHat_consistent reviewed
Causalean.Stat

OLS consistency. Under iid sampling, measurable regressors, a measurable outcome, integrable OLS raw moments through degree four, and a positive-definite population design second moment, for every positive tolerance, the probability that the OLS coefficient is farther than that tolerance from the projection coefficient converges to zero.

Formal statement
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
hx :
hy :
hraw :
hQ :
(olsQ P x y).PosDef
ε :
ℝ
hε :
0 < ε
Tendsto (fun n => μ {ω | ε < ‖olsBetaHat S x y n ω - olsBeta P x y‖}) atTop (𝓝 0)
Proof (Lean source)
theorem olsBetaHat_consistent [IsProbabilityMeasure μ] (S : IIDSample Ω X μ P) {x : X → EuclideanSpace ℝ K} {y : X → ℝ} (hx : Measurable x) (hy : Measurable y) (hraw : Integrable (olsRawMoment x y) P) (hQ : (olsQ P x y).PosDef) (ε : ℝ) (hε : 0 < ε) : Tendsto (fun n => μ {ω | ε < ‖olsBetaHat S x y n ω - olsBeta P x y‖}) atTop (𝓝 0) := by letI : IsProbabilityMeasure P := by rw [← S.law] exact Measure.isProbabilityMeasure_map (S.meas 0).aemeasurable let M₀ := olsPopulationMoments P x y have hM := S.sampleMeanVec_tendstoInMeasure (measurable_olsRawMoment hx hy) hraw have hb := continuousAt_olsBetaFromMoments M₀ (ols_population_det_ne_zero hQ) have hg : ContinuousAt (fun M : OLSMoment K => ‖olsBetaFromMoments M - olsBetaFromMoments M₀‖) M₀ := continuous_norm.continuousAt.comp (hb.sub continuousAt_const) have hnorm := tendstoInMeasure_comp_continuousAt_const hg hM rw [tendstoInMeasure_iff_norm] at hnorm have ht := hnorm ε hε refine tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds ht (fun _ => zero_le) ?_ intro n apply measure_mono intro ω hω simpa [M₀, olsBetaHat, olsEmpiricalMoments, olsBeta, olsPopulationMoments, Real.norm_eq_abs, abs_of_nonneg] using le_of_lt hω
theorem olsHC0_contrast_tendsto_inProb reviewed
Causalean.Stat

HC0 contrast-variance consistency. For an iid sample, measurable regressors, a measurable outcome, integrable OLS raw moments through degree four, a positive-definite population design second moment, and a contrast vector, the HC0 estimate of c′Vc converges in probability to c′Vc.

Formal statement
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
hx :
hy :
hraw :
hQ :
(olsQ P x y).PosDef
c :
Modes.TendstoInProbability (fun _ : ℕ => μ) (fun n ω => olsContrastVariance (olsHC0 S x y n ω) c) atTop (fun _ _ => olsContrastVariance (olsAsymptoticCovariance P x y) c)
Proof (Lean source)
theorem olsHC0_contrast_tendsto_inProb [IsProbabilityMeasure μ] (S : IIDSample Ω X μ P) {x : X → EuclideanSpace ℝ K} {y : X → ℝ} (hx : Measurable x) (hy : Measurable y) (hraw : Integrable (olsRawMoment x y) P) (hQ : (olsQ P x y).PosDef) (c : EuclideanSpace ℝ K) : Modes.TendstoInProbability (fun _ : ℕ => μ) (fun n ω => olsContrastVariance (olsHC0 S x y n ω) c) atTop (fun _ _ => olsContrastVariance (olsAsymptoticCovariance P x y) c) := by letI : IsProbabilityMeasure P := by rw [← S.law] exact Measure.isProbabilityMeasure_map (S.meas 0).aemeasurable have hM := S.sampleMeanVec_tendstoInMeasure (measurable_olsRawMoment hx hy) hraw have hcont := continuousAt_olsHC0FromMoments (olsPopulationMoments P x y) (ols_population_det_ne_zero hQ) have hcontrast : ContinuousAt (fun N : OLSMoment K => olsContrastVariance ((olsQFromMoments N)⁻¹ * olsMeatFromMoments N (olsBetaFromMoments N) * (olsQFromMoments N)⁻¹) c) (olsPopulationMoments P x y) := by have hc : Continuous (fun V : Matrix K K ℝ => olsContrastVariance V c) := by unfold olsContrastVariance fun_prop exact hc.continuousAt.comp hcont change TendstoInMeasure μ (fun n ω => olsContrastVariance (olsHC0 S x y n ω) c) atTop (fun _ => olsContrastVariance (olsAsymptoticCovariance P x y) c) simpa [olsHC0, olsHC0Meat, olsQHat, olsBetaHat, olsEmpiricalMoments, olsAsymptoticCovariance, olsOmega, olsQ, olsBeta] using tendstoInMeasure_comp_continuousAt_const hcontrast hM
6 supporting declarations (lemmas, instances)
HC1­Wald 9 core · 4 supporting This module supplies the degrees-of-freedom-corrected HC1 t statistic in both true-parameter and null-value forms, together with its standard-normal limit and the asymptotic coverage of the corresponding two-sided Wald i ★ olsHC1TStatistic_tendsto_normal★ olsHC1_wald_coverage★ olsHC1_wald_coverage_one_sub

HC1 studentization and Wald inference for OLS

This module supplies the degrees-of-freedom-corrected HC1 t statistic in both true-parameter and null-value forms, together with its standard-normal limit and the asymptotic coverage of the corresponding two-sided Wald interval.

def olsHC1ContrastSE reviewed
Causalean.Stat

Given an iid sample, regressors, an outcome, a contrast, a sample size, and a sample outcome, the HC1 standard error for the rescaled contrast is √(c′V̂₁c).

Definition (Lean source)
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
c :
n :
ℕ
ω :
Ω
olsHC1ContrastSE S x y c n ω :
ℝ
def olsHC1TStatistic reviewed
Causalean.Stat

Given an iid sample, regressors, an outcome, a contrast, a sample size, and a sample outcome, the HC1 heteroskedasticity-robust t statistic centered at the true population contrast is (c′β̂ₙ-c′β)/√(c′V̂₁c/n).

Definition (Lean source)
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
c :
n :
ℕ
ω :
Ω
olsHC1TStatistic S x y c n ω :
ℝ
(inner ℝ c (olsBetaHat S x y n ω) - inner ℝ c (olsBeta P x y)) / sqrt (olsContrastVariance (olsHC1 S x y n ω) c / (n : ℝ))
def olsHC1NullTStatistic reviewed
Causalean.Stat

Given an iid sample, regressors, an outcome, a contrast, a hypothesized null value, a sample size, and a sample outcome, the HC1 t statistic for the null c′β = r is (c′β̂ₙ-r)/√(c′V̂₁c/n).

Definition (Lean source)
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
c :
r :
ℝ
n :
ℕ
ω :
Ω
olsHC1NullTStatistic S x y c r n ω :
ℝ
(inner ℝ c (olsBetaHat S x y n ω) - r) / sqrt (olsContrastVariance (olsHC1 S x y n ω) c / (n : ℝ))
def olsHC1WaldRadius reviewed
Causalean.Stat

Given an iid sample, regressors, an outcome, a contrast, a critical value, a sample size, and a sample outcome, the HC1 Wald half-width is z√(c′V̂₁c/n).

Definition (Lean source)
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
c :
z :
ℝ
n :
ℕ
ω :
Ω
olsHC1WaldRadius S x y c z n ω :
ℝ
z * sqrt (olsContrastVariance (olsHC1 S x y n ω) c / (n : ℝ))
def olsHC1WaldCovers reviewed
Causalean.Stat

Given an iid sample, regressors, an outcome, a contrast, a critical value, a sample size, and a sample outcome, the two-sided HC1 Wald interval covers the population contrast exactly when c′β lies between c′β̂ₙ ± z√(c′V̂₁c/n).

Definition (Lean source)
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
c :
z :
ℝ
n :
ℕ
ω :
Ω
olsHC1WaldCovers S x y c z n ω :
Prop
inner ℝ c (olsBeta P x y) ∈ Icc (inner ℝ c (olsBetaHat S x y n ω) - olsHC1WaldRadius S x y c z n ω) (inner ℝ c (olsBetaHat S x y n ω) + olsHC1WaldRadius S x y c z n ω)
def olsHC1WaldCoverageProbability reviewed
Causalean.Stat

Given an iid sample, regressors, an outcome, a contrast, a critical value, and a sample size, the true coverage probability of the two-sided HC1 Wald interval is the sampling probability that c′β lies between its two endpoints.

Definition (Lean source)
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
c :
z :
ℝ
n :
ℕ
olsHC1WaldCoverageProbability S x y c z n :
ℝ
μ.real {ω | olsHC1WaldCovers S x y c z n ω}
Causalean.Stat.olsHC1WaldCoverageProbability · Causalean/Stat/LinearModel/OLSAsymptotics/HC1Wald.lean:82 · uses IIDSample
theorem olsHC1TStatistic_tendsto_normal reviewed
Causalean.Stat

Under iid sampling, measurable regressors, a measurable outcome, integrable OLS raw moments through degree four, a positive-definite population Gram matrix, a contrast vector, and a nondegenerate contrast variance, the true-value HC1 t statistic converges in distribution to the standard normal law.

Formal statement
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
hx :
hy :
hraw :
hQ :
(olsQ P x y).PosDef
c :
Modes.TendstoInLaw (fun _ : ℕ => μ) (olsHC1TStatistic S x y c) atTop (gaussianMeasure 0 1)
Proof (Lean source)
theorem olsHC1TStatistic_tendsto_normal [IsProbabilityMeasure μ] [IsProbabilityMeasure P] (S : IIDSample Ω X μ P) {x : X → EuclideanSpace ℝ K} {y : X → ℝ} (hx : Measurable x) (hy : Measurable y) (hraw : Integrable (olsRawMoment x y) P) (hQ : (olsQ P x y).PosDef) (c : EuclideanSpace ℝ K) (hpos : 0 < olsContrastVariance (olsAsymptoticCovariance P x y) c) : Modes.TendstoInLaw (fun _ : ℕ => μ) (olsHC1TStatistic S x y c) atTop (gaussianMeasure 0 1) := by have hstud : Modes.TendstoInLaw (fun _ : ℕ => μ) (olsHC1Studentized S x y c) atTop (gaussianMeasure 0 1) := olsHC1Studentized_tendsto S hx hy hraw hQ c hpos apply Modes.TendstoInLaw.congr_ae hstud (fun n => (measurable_olsHC1TStatistic S hx hy c n).aemeasurable) filter_upwards [eventually_gt_atTop 0] with n hn filter_upwards with ω exact (olsHC1TStatistic_eq_studentized S x y c hn ω).symm
theorem olsHC1_wald_coverage reviewed
Causalean.Stat

Under iid sampling, measurable regressors, a measurable outcome, integrable OLS raw moments through degree four, a positive-definite population Gram matrix, a contrast with positive asymptotic variance, and a positive critical value, the coverage probability of the HC1 interval c′β̂ₙ ± z√(c′V̂₁c/n) converges to the standard-normal probability of [-z,z].

Formal statement
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
hx :
hy :
hraw :
hQ :
(olsQ P x y).PosDef
c :
z :
ℝ
hz :
0 < z
Proof (Lean source)
theorem olsHC1_wald_coverage [IsProbabilityMeasure μ] [IsProbabilityMeasure P] (S : IIDSample Ω X μ P) {x : X → EuclideanSpace ℝ K} {y : X → ℝ} (hx : Measurable x) (hy : Measurable y) (hraw : Integrable (olsRawMoment x y) P) (hQ : (olsQ P x y).PosDef) (c : EuclideanSpace ℝ K) (hpos : 0 < olsContrastVariance (olsAsymptoticCovariance P x y) c) {z : ℝ} (hz : 0 < z) : Tendsto (olsHC1WaldCoverageProbability S x y c z) atTop (𝓝 ((gaussianMeasure 0 1) (Icc (-z) z)).toReal) := by let f : ℕ → Ω → ℝ := fun n ω => olsContrastVariance (olsHC1 S x y n ω) c let v : ℝ := olsContrastVariance (olsAsymptoticCovariance P x y) c let A : ℕ → Set Ω := fun n => {ω | olsHC1WaldCovers S x y c z n ω} let B : ℕ → Set Ω := fun n => {ω | olsHC1TStatistic S x y c n ω ∈ Icc (-z) z} let D : ℕ → Set Ω := fun n => {ω | f n ω ≤ 0} have hf : TendstoInMeasure μ f atTop (fun _ => v) := olsHC1_contrast_tendsto_inProb S hx hy hraw hQ c have herr : Tendsto (fun n => μ.real {ω | v ≤ ‖f n ω - v‖}) atTop (𝓝 0) := (tendstoInMeasure_iff_measureReal_norm.mp hf) v hpos have hD_le : ∀ n, μ.real (D n) ≤ μ.real {ω | v ≤ ‖f n ω - v‖} := by intro n apply measureReal_mono · intro ω hω change v ≤ ‖f n ω - v‖ rw [Real.norm_eq_abs, abs_of_nonpos] · change f n ω ≤ 0 at hω change 0 < v at hpos linarith · exact sub_nonpos.mpr (hω.trans hpos.le) · exact measure_ne_top _ _ have hD : Tendsto (fun n => μ.real (D n)) atTop (𝓝 0) := by exact tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds herr (Eventually.of_forall fun _ => measureReal_nonneg) (Eventually.of_forall hD_le) have hA : ∀ n, MeasurableSet (A n) := fun n => measurableSet_olsHC1WaldCovers S hx hy c z n have hB : ∀ n, MeasurableSet (B n) := fun n => measurableSet_Icc.preimage (measurable_olsHC1TStatistic S hx hy c n) have hsymm : ∀ᶠ n in atTop, symmDiff (A n) (B n) ⊆ D n := by filter_upwards [eventually_gt_atTop 0] with n hn intro ω hω rw [Set.mem_symmDiff] at hω by_contra hnot have hvhat : 0 < f n ω := lt_of_not_ge hnot have heq := olsHC1WaldCovers_iff_statistic S x y c z hn ω hvhat rcases hω with ⟨ha, hnb⟩ | ⟨hb, hna⟩ · exact hnb (heq.mp ha) · exact hna (heq.mpr hb) have hgap_abs : Tendsto (fun n => |olsHC1WaldCoverageProbability S x y c z n - μ.real (B n)|) atTop (𝓝 0) := by apply tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds hD · exact Eventually.of_forall fun _ => abs_nonneg _ · filter_upwards [hsymm] with n hn calc |olsHC1WaldCoverageProbability S x y c z n - μ.real (B n)| = |μ.real (A n) - μ.real (B n)| := by rfl _ ≤ μ.real (symmDiff (A n) (B n)) := abs_measureReal_sub_le_measureReal_symmDiff (hA n).nullMeasurableSet (hB n).nullMeasurableSet _ ≤ μ.real (D n) := measureReal_mono hn (measure_ne_top _ _) have hbridge : Tendsto (fun n => olsHC1WaldCoverageProbability S x y c z n - μ.real (B n)) atTop (𝓝 0) := by rw [tendsto_iff_dist_tendsto_zero] simpa [Real.dist_eq] using hgap_abs have hstat : Modes.TendstoInLaw (fun _ : ℕ => μ) (olsHC1TStatistic S x y c) atTop (gaussianMeasure 0 1) := olsHC1TStatistic_tendsto_normal S hx hy hraw hQ c hpos exact Modes.TendstoInLaw.wald_coverage hstat hz (olsHC1WaldCoverageProbability S x y c z) (by simpa [B, measureReal_def] using hbridge)
theorem olsHC1_wald_coverage_one_sub reviewed
Causalean.Stat

Under iid sampling, measurable regressors, a measurable outcome, integrable OLS raw moments through degree four, a positive-definite population Gram matrix, a contrast with positive asymptotic variance, a positive critical value, and standard-normal calibration to 1-α, the HC1 Wald interval has asymptotic coverage 1-α.

Formal statement
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
hx :
hy :
hraw :
hQ :
(olsQ P x y).PosDef
c :
α z :
ℝ
hz :
0 < z
hcal :
((gaussianMeasure 0 1) (Icc (-z) z)).toReal = 1 - α
Tendsto (olsHC1WaldCoverageProbability S x y c z) atTop (𝓝 (1 - α))
Proof (Lean source)
theorem olsHC1_wald_coverage_one_sub [IsProbabilityMeasure μ] [IsProbabilityMeasure P] (S : IIDSample Ω X μ P) {x : X → EuclideanSpace ℝ K} {y : X → ℝ} (hx : Measurable x) (hy : Measurable y) (hraw : Integrable (olsRawMoment x y) P) (hQ : (olsQ P x y).PosDef) (c : EuclideanSpace ℝ K) (hpos : 0 < olsContrastVariance (olsAsymptoticCovariance P x y) c) {α z : ℝ} (hz : 0 < z) (hcal : ((gaussianMeasure 0 1) (Icc (-z) z)).toReal = 1 - α) : Tendsto (olsHC1WaldCoverageProbability S x y c z) atTop (𝓝 (1 - α)) := by rw [← hcal] exact olsHC1_wald_coverage S hx hy hraw hQ c hpos hz
4 supporting declarations (lemmas, instances)
Score­Moment­Conditions 1 core · 3 supporting This module proves measurability of the OLS score and its derivative, and records global boundedness as a simple sufficient condition for their integrability. ★ integrable_sq_olsScore_of_bounded

Elementary score moment conditions for OLS

This module proves measurability of the OLS score and its derivative, and records global boundedness as a simple sufficient condition for their integrability.

theorem integrable_sq_olsScore_of_bounded reviewed
Causalean.Stat

Under a finite population law, measurable regressors, a measurable outcome, uniform regressor and outcome bounds, and a fixed coefficient, the squared norm of the OLS score is integrable.

Formal statement
X :
Type u_1
shared
K :
Type u_2
shared
P :
shared
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
hx :
hy :
hx_bdd :
∃ C, ∀ z, ‖x z‖ ≤ C
hy_bdd :
∃ C, ∀ z, |y z| ≤ C
b :
Integrable (fun z => ‖olsScore x y b z‖ ^ 2) P
Proof (Lean source)
@[fun_prop] theorem integrable_sq_olsScore_of_bounded [IsFiniteMeasure P] {x : X → EuclideanSpace ℝ K} {y : X → ℝ} (hx : Measurable x) (hy : Measurable y) (hx_bdd : ∃ C, ∀ z, ‖x z‖ ≤ C) (hy_bdd : ∃ C, ∀ z, |y z| ≤ C) (b : EuclideanSpace ℝ K) : Integrable (fun z => ‖olsScore x y b z‖ ^ 2) P := by rcases hx_bdd with ⟨Cx, hxC⟩ rcases hy_bdd with ⟨Cy, hyC⟩ let B := (|Cy| + |Cx| * ‖b‖) * |Cx| have hB : 0 ≤ B := mul_nonneg (add_nonneg (abs_nonneg _) (mul_nonneg (abs_nonneg _) (norm_nonneg _))) (abs_nonneg _) have hscore : ∀ z, ‖olsScore x y b z‖ ≤ B := by intro z have hxabs : ‖x z‖ ≤ |Cx| := (hxC z).trans (le_abs_self Cx) have hyabs : |y z| ≤ |Cy| := (hyC z).trans (le_abs_self Cy) have hdot : |⟪x z, b⟫| ≤ |Cx| * ‖b‖ := (abs_real_inner_le_norm (x z) b).trans (mul_le_mul_of_nonneg_right hxabs (norm_nonneg _)) calc ‖olsScore x y b z‖ = |y z - ⟪x z, b⟫| * ‖x z‖ := by simp [olsScore, olsResidual, EuclideanSpace.inner_eq_star_dotProduct, dotProduct, mul_comm, norm_smul, Real.norm_eq_abs] _ ≤ (|Cy| + |Cx| * ‖b‖) * |Cx| := by gcongr exact (abs_sub _ _).trans (add_le_add hyabs hdot) _ = B := rfl apply Integrable.of_bound ((measurable_olsScore hx hy b).norm.pow_const 2).aestronglyMeasurable (B ^ 2) filter_upwards with z rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)] nlinarith [norm_nonneg (olsScore x y b z), hscore z]
Causalean.Stat.integrable_sq_olsScore_of_bounded · Causalean/Stat/LinearModel/OLSAsymptotics/ScoreMomentConditions.lean:43 · uses olsScore
3 supporting declarations (lemmas, instances)
Wald 8 core · 6 supporting This module projects the vector OLS central limit theorem onto a fixed linear contrast, combines it with HC0 consistency, and proves the standard robust t-statistic limit and two-sided Wald-interval coverage. ★ olsHC0TStatistic_tendsto_normal★ olsHC0_wald_coverage

Heteroskedasticity-robust OLS contrasts and Wald inference

This module projects the vector OLS central limit theorem onto a fixed linear contrast, combines it with HC0 consistency, and proves the standard robust t-statistic limit and two-sided Wald-interval coverage.

def olsContrastRescaled reviewed
Causalean.Stat

Given an iid sample, regressors, an outcome, a contrast, a sample size, and a sample outcome, the root-sample-size rescaled contrast error is √n (c′β̂ₙ-c′β).

Definition (Lean source)
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
c :
n :
ℕ
ω :
Ω
olsContrastRescaled S x y c n ω :
ℝ
sqrt (n : ℝ) * (inner ℝ c (olsBetaHat S x y n ω) - inner ℝ c (olsBeta P x y))
Causalean.Stat.olsContrastRescaled · Causalean/Stat/LinearModel/OLSAsymptotics/Wald.lean:76 · uses IIDSample
def olsHC0ContrastSE reviewed
Causalean.Stat

Given an iid sample, regressors, an outcome, a contrast, a sample size, and a sample outcome, the HC0 standard error for the rescaled contrast is √(c′V̂c).

Definition (Lean source)
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
c :
n :
ℕ
ω :
Ω
olsHC0ContrastSE S x y c n ω :
ℝ
def olsHC0TStatistic reviewed
Causalean.Stat

Given an iid sample, regressors, an outcome, a contrast, a sample size, and a sample outcome, the heteroskedasticity-robust t-statistic is (c′β̂ₙ-c′β)/√(c′V̂c/n).

Definition (Lean source)
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
c :
n :
ℕ
ω :
Ω
olsHC0TStatistic S x y c n ω :
ℝ
(inner ℝ c (olsBetaHat S x y n ω) - inner ℝ c (olsBeta P x y)) / sqrt (olsContrastVariance (olsHC0 S x y n ω) c / (n : ℝ))
def olsHC0WaldRadius reviewed
Causalean.Stat

Given an iid sample, regressors, an outcome, a contrast, a critical value, a sample size, and a sample outcome, the HC0 Wald half-width is z√(c′V̂c/n).

Definition (Lean source)
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
c :
z :
ℝ
n :
ℕ
ω :
Ω
olsHC0WaldRadius S x y c z n ω :
ℝ
z * sqrt (olsContrastVariance (olsHC0 S x y n ω) c / (n : ℝ))
def olsHC0WaldCovers reviewed
Causalean.Stat

Given an iid sample, regressors, an outcome, a contrast, a critical value, a sample size, and a sample outcome, the two-sided HC0 Wald interval covers the population contrast exactly when c′β lies between c′β̂ₙ ± z√(c′V̂c/n).

Definition (Lean source)
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
c :
z :
ℝ
n :
ℕ
ω :
Ω
olsHC0WaldCovers S x y c z n ω :
Prop
inner ℝ c (olsBeta P x y) ∈ Icc (inner ℝ c (olsBetaHat S x y n ω) - olsHC0WaldRadius S x y c z n ω) (inner ℝ c (olsBetaHat S x y n ω) + olsHC0WaldRadius S x y c z n ω)
def olsHC0WaldCoverageProbability reviewed
Causalean.Stat

Given an iid sample, regressors, an outcome, a contrast, a critical value, and a sample size, the true coverage probability of the two-sided HC0 Wald interval is the sampling probability that c′β lies between its two endpoints.

Definition (Lean source)
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
c :
z :
ℝ
n :
ℕ
olsHC0WaldCoverageProbability S x y c z n :
ℝ
μ.real {ω | olsHC0WaldCovers S x y c z n ω}
Causalean.Stat.olsHC0WaldCoverageProbability · Causalean/Stat/LinearModel/OLSAsymptotics/Wald.lean:130 · uses IIDSample
theorem olsHC0TStatistic_tendsto_normal reviewed
Causalean.Stat

Under iid sampling, measurable regressors, a measurable outcome, integrable OLS raw moments through degree four, a positive-definite population Gram matrix, a contrast vector, and a nondegenerate contrast variance, the HC0 t-statistic converges in distribution to the standard normal law.

Formal statement
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
hx :
hy :
hraw :
hQ :
(olsQ P x y).PosDef
c :
Modes.TendstoInLaw (fun _ : ℕ => μ) (olsHC0TStatistic S x y c) atTop (gaussianMeasure 0 1)
Proof (Lean source)
theorem olsHC0TStatistic_tendsto_normal [IsProbabilityMeasure μ] [IsProbabilityMeasure P] (S : IIDSample Ω X μ P) {x : X → EuclideanSpace ℝ K} {y : X → ℝ} (hx : Measurable x) (hy : Measurable y) (hraw : Integrable (olsRawMoment x y) P) (hQ : (olsQ P x y).PosDef) (c : EuclideanSpace ℝ K) (hpos : 0 < olsContrastVariance (olsAsymptoticCovariance P x y) c) : Modes.TendstoInLaw (fun _ : ℕ => μ) (olsHC0TStatistic S x y c) atTop (gaussianMeasure 0 1) := by have hstud : Modes.TendstoInLaw (fun _ : ℕ => μ) (olsHC0Studentized S x y c) atTop (gaussianMeasure 0 1) := olsHC0Studentized_tendsto S hx hy hraw hQ c hpos apply Modes.TendstoInLaw.congr_ae hstud (fun n => (measurable_olsHC0TStatistic S hx hy c n).aemeasurable) filter_upwards [eventually_gt_atTop 0] with n hn filter_upwards with ω exact (olsHC0TStatistic_eq_studentized S x y c hn ω).symm
theorem olsHC0_wald_coverage reviewed
Causalean.Stat

Under iid sampling, measurable regressors, a measurable outcome, integrable OLS raw moments through degree four, a positive-definite population Gram matrix, a contrast with positive asymptotic variance, and a positive critical value, the coverage probability of the HC0 interval c′β̂ₙ ± z√(c′V̂c/n) converges to the standard-normal probability of [-z,z].

Formal statement
Ω :
Type u_1
shared
X :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
x :
X → EuclideanSpace ℝ K
y :
X → ℝ
hx :
hy :
hraw :
hQ :
(olsQ P x y).PosDef
c :
z :
ℝ
hz :
0 < z
Proof (Lean source)
theorem olsHC0_wald_coverage [IsProbabilityMeasure μ] [IsProbabilityMeasure P] (S : IIDSample Ω X μ P) {x : X → EuclideanSpace ℝ K} {y : X → ℝ} (hx : Measurable x) (hy : Measurable y) (hraw : Integrable (olsRawMoment x y) P) (hQ : (olsQ P x y).PosDef) (c : EuclideanSpace ℝ K) (hpos : 0 < olsContrastVariance (olsAsymptoticCovariance P x y) c) {z : ℝ} (hz : 0 < z) : Tendsto (olsHC0WaldCoverageProbability S x y c z) atTop (𝓝 ((gaussianMeasure 0 1) (Icc (-z) z)).toReal) := by let f : ℕ → Ω → ℝ := fun n ω => olsContrastVariance (olsHC0 S x y n ω) c let v : ℝ := olsContrastVariance (olsAsymptoticCovariance P x y) c let A : ℕ → Set Ω := fun n => {ω | olsHC0WaldCovers S x y c z n ω} let B : ℕ → Set Ω := fun n => {ω | olsHC0TStatistic S x y c n ω ∈ Icc (-z) z} let D : ℕ → Set Ω := fun n => {ω | f n ω ≤ 0} have hf : TendstoInMeasure μ f atTop (fun _ => v) := olsHC0_contrast_tendsto_inProb S hx hy hraw hQ c have herr : Tendsto (fun n => μ.real {ω | v ≤ ‖f n ω - v‖}) atTop (𝓝 0) := (tendstoInMeasure_iff_measureReal_norm.mp hf) v hpos have hD_le : ∀ n, μ.real (D n) ≤ μ.real {ω | v ≤ ‖f n ω - v‖} := by intro n apply measureReal_mono · intro ω hω change v ≤ ‖f n ω - v‖ rw [Real.norm_eq_abs, abs_of_nonpos] · change f n ω ≤ 0 at hω change 0 < v at hpos linarith · exact sub_nonpos.mpr (hω.trans hpos.le) · exact measure_ne_top _ _ have hD : Tendsto (fun n => μ.real (D n)) atTop (𝓝 0) := by exact tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds herr (Eventually.of_forall fun n => measureReal_nonneg) (Eventually.of_forall hD_le) have hA : ∀ n, MeasurableSet (A n) := fun n => measurableSet_olsHC0WaldCovers S hx hy c z n have hB : ∀ n, MeasurableSet (B n) := fun n => measurableSet_Icc.preimage (measurable_olsHC0TStatistic S hx hy c n) have hsymm : ∀ᶠ n in atTop, symmDiff (A n) (B n) ⊆ D n := by filter_upwards [eventually_gt_atTop 0] with n hn intro ω hω rw [Set.mem_symmDiff] at hω by_contra hnot have hvhat : 0 < f n ω := lt_of_not_ge hnot have heq := olsHC0WaldCovers_iff_statistic S x y c z hn ω hvhat rcases hω with ⟨ha, hnb⟩ | ⟨hb, hna⟩ · exact hnb (heq.mp ha) · exact hna (heq.mpr hb) have hgap_abs : Tendsto (fun n => |olsHC0WaldCoverageProbability S x y c z n - μ.real (B n)|) atTop (𝓝 0) := by apply tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds hD · exact Eventually.of_forall fun n => abs_nonneg _ · filter_upwards [hsymm] with n hn calc |olsHC0WaldCoverageProbability S x y c z n - μ.real (B n)| = |μ.real (A n) - μ.real (B n)| := by rfl _ ≤ μ.real (symmDiff (A n) (B n)) := abs_measureReal_sub_le_measureReal_symmDiff (hA n).nullMeasurableSet (hB n).nullMeasurableSet _ ≤ μ.real (D n) := measureReal_mono hn (measure_ne_top _ _) have hbridge : Tendsto (fun n => olsHC0WaldCoverageProbability S x y c z n - μ.real (B n)) atTop (𝓝 0) := by rw [tendsto_iff_dist_tendsto_zero] simpa [Real.dist_eq] using hgap_abs have hstat : Modes.TendstoInLaw (fun _ : ℕ => μ) (olsHC0TStatistic S x y c) atTop (gaussianMeasure 0 1) := olsHC0TStatistic_tendsto_normal S hx hy hraw hQ c hpos exact Modes.TendstoInLaw.wald_coverage hstat hz (olsHC0WaldCoverageProbability S x y c z) (by simpa [B, measureReal_def] using hbridge)
6 supporting declarations (lemmas, instances)