Estimation.GaussMarkov
The Gauss-Markov theorem for linear models: best linear unbiased estimation under spherical errors.
QuadForm 3 core · 2 supporting This file provides the deterministic quadratic-form layer of the finite Gauss-Markov theory. ★ quadVar_spherical
Quadratic Variance Form
This file provides the deterministic quadratic-form layer of the finite
Gauss-Markov theory. The definition quadVar S w = w ⬝ᵥ S *ᵥ w is the
weight-covariance-weight variance functional for a finite linear estimator, and
SphericalErrors S σ records the scalar-identity covariance condition
S = σ² • I.
The main reusable facts are quadVar_nonneg, nonnegativity under a
positive-semidefinite covariance matrix, and quadVar_spherical, the reduction
quadVar S w = σ² * (w ⬝ᵥ w) under spherical errors. The probability-theoretic
bridge to actual random variables is in GaussMarkov/Variance.lean; the
least-variance ordering theorems are in GaussMarkov/LeastNorm.lean.
This is the covariance quadratic form that gives the variance of a linear estimator.
This condition says the covariance matrix has homoskedastic uncorrelated errors.
Under spherical errors, i.e. when the error covariance matrix S equals σ² times the identity, the linear-estimator variance functional at weight vector w reduces to the common variance σ² times the squared Euclidean length of w.
Formal statement
Proof (Lean source)
2 supporting declarations (lemmas, instances)
-
quadVar_nonneglemma — A positive-semidefinite covariance matrix gives a nonnegative variance for every linear weight.
Variance 3 core · 1 supporting This file connects the deterministic Gauss-Markov quadratic form to the probability theory of finite random families. ★ variance_linearCombination
Variance Bridge
This file connects the deterministic Gauss-Markov quadratic form to the
probability theory of finite random families. It defines covMatrix Y μ, the
covariance matrix of the observations Y i, and proves
variance_linearCombination: the variance of ∑ i, w i * Y i is exactly
quadVar (covMatrix Y μ) w.
It also defines SphericalFamily, the probabilistic condition that all cells
have variance σ² and distinct cells are uncorrelated, and proves
sphericalFamily_covMatrix, which turns that condition into the deterministic
SphericalErrors hypothesis used by the Gauss-Markov ordering theorems.
Covariance matrix of a finite family of random variables Y i.
Variance of a linear combination = covariance quadratic form. For a finite family of random variables Y i, each square-integrable, and any weight vector w, the variance of the random linear combination ∑ i, w i * Y i equals the quadratic form wᵀ Σ w, where Σ is the family's covariance matrix.
Formal statement
Proof (Lean source)
A random family has spherical errors with scale σ: distinct cells are uncorrelated and each has variance σ².
Definition (Lean source)
1 supporting declaration (lemmas, instances)
-
sphericalFamily_covMatrixlemma — A spherical random family has a spherical (scalar-identity) covariance matrix.hypothesesconclusionSphericalErrors (covMatrix Y μ) σProof (Lean source)
lemma sphericalFamily_covMatrix [DecidableEq Obs] {Y : Obs → Ω → ℝ} {σ : ℝ} (hY : ∀ i, AEMeasurable (Y i) μ) (h : SphericalFamily Y μ σ) : SphericalErrors (covMatrix Y μ) σ := by ext i j simp only [covMatrix, Matrix.smul_apply, Matrix.one_apply, smul_eq_mul] by_cases hij : i = j · subst hij rw [covariance_self (hY i), h.1 i] simp · rw [h.2 i j hij] simp [hij]
BLUE 2 core · 1 supporting This file states the finite Gauss-Markov conclusions in probabilistic variance language. ★ variance_blue_spherical★ variance_blue_gls
Best Linear Unbiased Estimation
This file states the finite Gauss-Markov conclusions in probabilistic variance language. It combines the covariance-matrix bridge with the least-norm ordering theorems to prove the best-linear-unbiased-estimator results for spherical errors and for a known covariance matrix.
BLUE under spherical errors (variance form). For a finite family of random variables Y i, each square-integrable, suppose the family is spherical: distinct cells are uncorrelated and every cell has the same variance σ². Among all linear combinations ∑ i, w i * Y i whose weights satisfy the same unbiasedness constraint w ᵥ* X = c relative to a design X and target combination c, if wStar lies in the column span of X, wStar = X *ᵥ g, then the linear combination built from wStar (the OLS weight) has variance no larger than that of any other unbiased linear combination.
Formal statement
Proof (Lean source)
BLUE for known covariance (GLS, variance form). For a finite family of random variables Y i, each square-integrable, consider linear combinations ∑ i, w i * Y i whose weights satisfy the same unbiasedness constraint w ᵥ* X = c relative to a design X and target combination c. If the weight wStar is a generalized-least-squares (GLS) weight — i.e. the family's covariance matrix applied to wStar lies in the column span of X, then the linear combination built from wStar has variance no larger than that of any other unbiased linear combination.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
covMatrix_posSemideflemma — A covariance matrix of an L² random family is positive semidefinite: it is symmetric (cov is symmetric) and its quadratic form is a genuine variance, hence nonnegative. (Fintype Obs appears only under the PosSemidef definition, which the unusedFintypeInType linter cannot see; it is genuinely required.)hypothesesconclusion(covMatrix Y μ).PosSemidefProof (Lean source)
lemma covMatrix_posSemidef [IsProbabilityMeasure μ] (Y : Obs → Ω → ℝ) (hY : ∀ i, MemLp (Y i) 2 μ) : (covMatrix Y μ).PosSemidef := by refine Matrix.PosSemidef.of_dotProduct_mulVec_nonneg ?_ ?_ · refine Matrix.IsHermitian.ext fun i j => ?_ change star (covMatrix Y μ j i) = covMatrix Y μ i j rw [star_trivial] exact covariance_comm (Y j) (Y i) · intro w have hsw : star w ⬝ᵥ (covMatrix Y μ) *ᵥ w = quadVar (covMatrix Y μ) w := by simp [quadVar, star_trivial] rw [hsw, ← variance_linearCombination Y hY] exact variance_nonneg _ _
LeastNorm 2 core · 2 supporting This file proves the algebraic core of the finite Gauss-Markov theorem. ★ gauss_markov_spherical★ gauss_markov_gls
Least-Norm Gauss-Markov Ordering
This file proves the algebraic core of the finite Gauss-Markov theorem. It
shows that, among linear-estimator weights satisfying the same unbiasedness
constraint w ᵥ* X = c, an ordinary least-squares weight in the column span of
X is variance-minimizing under spherical errors and a generalized least-squares
weight is variance-minimizing under a known positive-semidefinite covariance
matrix.
The main public results are gauss_markov_spherical, the finite BLUE ordering
for spherical covariance Σ = σ² I, and gauss_markov_gls, the corresponding
ordering for a general positive-semidefinite covariance. The supporting lemma
colSpan_dotProduct_leftNull records the orthogonality between the column span
of X and the left null space that drives the Pythagorean variance comparison.
Finite Gauss-Markov theorem, spherical case. Fix a design matrix X, a target combination c, and suppose the covariance matrix S is spherical: S = σ² I for some scale σ. Among all weight vectors w satisfying the same unbiasedness constraint w ᵥ* X = c, if wStar lies in the column span of X, wStar = X *ᵥ g, then the quadratic form wStarᵀ S wStar is no larger than wᵀ S w.
Formal statement
Proof (Lean source)
Finite Gauss-Markov theorem, general covariance (GLS). Fix a design matrix X, a target combination c, and a positive-semidefinite covariance matrix S. Among all weight vectors w satisfying the same unbiasedness constraint w ᵥ* X = c, if wStar is a GLS weight — meaning S *ᵥ wStar lies in the column span of X, then the quadratic form wStarᵀ S wStar is no larger than wᵀ S w. Specializes to gauss_markov_spherical when S = σ² I.
Formal statement
Proof (Lean source)
2 supporting declarations (lemmas, instances)
-
colSpan_dotProduct_leftNulllemma — Column span is Euclidean-orthogonal to the left null space: if z lies in the left null space of X (z ᵥ* X = 0), then any column-span vector X *ᵥ g is orthogonal to z.hypothesesconclusion(X *ᵥ g) ⬝ᵥ z = 0Proof (Lean source)
lemma colSpan_dotProduct_leftNull {X : Matrix Obs Param ℝ} {g : Param → ℝ} {z : Obs → ℝ} (hz : z ᵥ* X = 0) : (X *ᵥ g) ⬝ᵥ z = 0 := by rw [dotProduct_comm, dotProduct_mulVec, hz, zero_dotProduct] -
dotProduct_self_nonneg'lemma — Nonnegativity of the Euclidean self dot product.Proof (Lean source)
lemma dotProduct_self_nonneg' (v : Obs → ℝ) : 0 ≤ v ⬝ᵥ v := by rw [dotProduct] exact sum_nonneg fun i _ => mul_self_nonneg _
OLS 2 core · 2 supporting This file defines the ordinary least-squares weight vector olsWeight X c for estimating a specified linear combination c'β from a finite design matrix X. ★ olsWeight_blue_spherical
Ordinary Least Squares Weights
This file defines the ordinary least-squares weight vector olsWeight X c for
estimating a specified linear combination c'β from a finite design matrix X.
The definition uses the ordinary inverse of the normal-equations matrix
Xᵀ * X; the unbiasedness theorem therefore assumes IsUnit (Xᵀ * X).det,
the finite full-column-rank condition.
The public facts are olsWeight_unbiased, which proves the constraint
olsWeight X c ᵥ* X = c, and olsWeight_blue_spherical, which applies
gauss_markov_spherical to show that this OLS weight is BLUE under spherical
errors.
OLS weight via the normal-equations inverse: wStar = X (XᵀX)⁻¹ c.
OLS is BLUE under spherical errors. For an invertible normal-equations matrix Xᵀ X — full column rank — the ordinary-least-squares weight olsWeight X c estimating the target combination c is well defined. Under spherical errors S = σ² I, among all weight vectors w satisfying the same unbiasedness constraint w ᵥ* X = c, the quadratic form at the OLS weight is no larger than at any other unbiased weight w.
Formal statement
Proof (Lean source)
2 supporting declarations (lemmas, instances)
-
olsWeight_mem_colSpanlemma — The OLS weight lies in the column span of X.Proof (Lean source)
lemma olsWeight_mem_colSpan (X : Matrix Obs Param ℝ) (c : Param → ℝ) : olsWeight X c = X *ᵥ ((Xᵀ * X)⁻¹ *ᵥ c) := rfl -
olsWeight_unbiasedlemma — The OLS weight satisfies the unbiasedness constraint wStar ᵥ* X = c, provided XᵀX is invertible (full column rank).hypothesesconclusionolsWeight X c ᵥ* X = cProof (Lean source)
lemma olsWeight_unbiased {X : Matrix Obs Param ℝ} (c : Param → ℝ) (h : IsUnit (Xᵀ * X).det) : olsWeight X c ᵥ* X = c := by have h1 : ∀ g : Param → ℝ, (X *ᵥ g) ᵥ* X = (Xᵀ * X) *ᵥ g := by intro g rw [← mulVec_transpose, mulVec_mulVec] calc olsWeight X c ᵥ* X = (Xᵀ * X) *ᵥ ((Xᵀ * X)⁻¹ *ᵥ c) := by rw [olsWeight, h1] _ = ((Xᵀ * X) * (Xᵀ * X)⁻¹) *ᵥ c := by rw [mulVec_mulVec] _ = (1 : Matrix Param Param ℝ) *ᵥ c := by rw [mul_nonsing_inv (Xᵀ * X) h] _ = c := one_mulVec c