Stat.LinearModel.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 layer for finite covariance quadratic-form comparisons. ★ quadVar_spherical
Quadratic Variance Form
This file provides the deterministic layer for finite covariance quadratic-form
comparisons. 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
quadratic-form ordering theorems are in GaussMarkov/LeastNorm.lean.
For a finite observation index set, a real covariance matrix indexed by that set, and a real weight assigned to each observation, the quadratic variance form is .
Definition (Lean source)
For an observation index set in which equality can be decided, a real square matrix indexed by those observations, and a real scale parameter, the spherical-errors condition holds exactly when the matrix equals times the identity matrix.
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_deflemma — The quadratic variance form unfolds to the weight-covariance-weight product.hypothesesconclusionquadVar S w = w ⬝ᵥ S *ᵥ w -
quadVar_nonneglemma — A positive-semidefinite covariance matrix gives a nonnegative variance for every linear weight.hypothesesconclusion0 ≤ quadVar S w
Variance 3 core · 1 supporting This file connects the deterministic covariance quadratic form to the probability theory of finite random families. ★ variance_linearCombination
Variance Bridge
This file connects the deterministic covariance 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 quadratic-form ordering theorems.
For a sample space equipped with a σ-algebra, a finite observation index set, a real-valued random variable for each observation, and a measure on the sample space, the covariance matrix has entry equal to the covariance of the th and th random variables under that measure.
Definition (Lean source)
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)
For a sample space equipped with a σ-algebra, a finite observation index set, a real-valued random variable for each observation, a measure on the sample space, and a real scale parameter, the spherical-family condition holds exactly when every random variable has variance and every two indexed by distinct observations have covariance zero.
Definition (Lean source)
1 supporting declaration (lemmas, instances)
-
sphericalFamily_covMatrixlemma — A spherical random family has a spherical (scalar-identity) covariance matrix.hypothesesΩ :sharedType u_1Obs :sharedType u_2DecidableEq ObsY :Obs → Ω → ℝσ :ℝhY :∀ i, AEMeasurable (Y i) μh :SphericalFamily Y μ σconclusionSphericalErrors (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 combines the covariance-matrix bridge with algebraic quadratic-form orderings to compare variances of finite random linear combinations. ★ linearCombination_variance_spherical_le_of_colSpan★ linearCombination_variance_le_of_covMul_mem_colSpan
Variance Orderings for Linear Combinations
This file combines the covariance-matrix bridge with algebraic quadratic-form orderings to compare variances of finite random linear combinations. The weights satisfy common design-balance identities, but the statements do not assume a linear mean model and therefore do not by themselves prove estimator unbiasedness.
Variance ordering under a spherical random family. 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 design-balance identity w ᵥ* X = c, if wStar lies in the column span of X, wStar = X *ᵥ g, then the linear combination built from wStar has variance no larger than the one built from w.
Formal statement
Proof (Lean source)
Variance ordering under a known covariance matrix. 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 design-balance identity w ᵥ* X = c. If 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 the one built from w.
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 algebraic quadratic-form orderings for weights satisfying the same design-balance identity w ᵥ* X = c. ★ quadVar_spherical_le_of_colSpan★ quadVar_le_of_mulVec_mem_colSpan
Least-Norm Covariance Ordering
This file proves algebraic quadratic-form orderings for weights satisfying the
same design-balance identity w ᵥ* X = c. A column-span weight has no larger
quadratic form under a spherical matrix, and a weight whose image under a
positive-semidefinite matrix lies in the column span has no larger quadratic
form under that matrix. The statements do not include a mean model and therefore
do not themselves establish estimator unbiasedness.
The main public results are quadVar_spherical_le_of_colSpan and
quadVar_le_of_mulVec_mem_colSpan. The supporting lemma
colSpan_dotProduct_leftNull records the orthogonality between the column span
of X and the left null space that drives the Pythagorean comparison.
Spherical quadratic-form ordering. Fix a design matrix X, a target combination c, and suppose the matrix S is spherical: S = σ² I for some scale σ. Among all weight vectors w satisfying the same design-balance identity 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)
Positive-semidefinite quadratic-form ordering. Fix a design matrix X, a target combination c, and a positive-semidefinite matrix S. Among all weight vectors w satisfying the same design-balance identity w ᵥ* X = c, if the image S *ᵥ wStar lies in the column span of X, then the quadratic form wStarᵀ S wStar is no larger than wᵀ S w.
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.hypothesesObs :sharedType u_1z :Obs → ℝhz :z ᵥ* X = 0conclusion(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.hypothesesObs :sharedType u_1v :Obs → ℝconclusion0 ≤ v ⬝ᵥ vProof (Lean source)
lemma dotProduct_self_nonneg' (v : Obs → ℝ) : 0 ≤ v ⬝ᵥ v := by rw [dotProduct] exact Finset.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_quadVar_spherical_le
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 design-balance identity therefore assumes
IsUnit (Xᵀ * X).det, the finite full-column-rank condition.
The public facts are olsWeight_vecMul_eq, which proves
olsWeight X c ᵥ* X = c, and olsWeight_quadVar_spherical_le, which applies
quadVar_spherical_le_of_colSpan to compare the OLS weight's quadratic form
with every weight satisfying the same identity. These facts alone do not prove
unbiasedness because they do not include a mean model.
For finite observation and parameter index sets, with parameter indices that can be distinguished, a real design matrix, and a real vector specifying a linear combination of the parameters, the ordinary-least-squares weight vector is .
Definition (Lean source)
OLS-weight quadratic-form ordering under a spherical matrix. For an invertible normal-equations matrix Xᵀ X and a spherical matrix S = σ² I, among all weight vectors w satisfying the same design-balance identity w ᵥ* X = c, the quadratic form at olsWeight X c is no larger than at w.
Formal statement
Proof (Lean source)
2 supporting declarations (lemmas, instances)
-
olsWeight_vecMul_eqlemma — For an invertible normal-equations matrix XᵀX, the OLS weight satisfies the design-balance identity olsWeight X c ᵥ* X = c.hypothesesconclusionolsWeight X c ᵥ* X = cProof (Lean source)
lemma olsWeight_vecMul_eq {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