GLOBAL KNOWLEDGE ARK

Mathematics · Article

Simple and multiple regression

Derive least-squares fits and their projection geometry, then separate coefficient identification, population targets and statistical assumptions. Examine multiple features, inference, prediction, diagnostics, collinearity, validation and regularization without treating a fitted contrast as a causal effect.

Back to Mathematics

After reading, you can

  • Derive a simple least-squares line with coefficient units and connect it to correlation.
  • Use matrix projection and normal equations with explicit rank and estimability conditions.
  • Interpret multiple features, residualization and interactions on their feasible scientific scale.
  • Separate algebra, conditional unbiasedness, covariance, Gauss–Markov efficiency and exact Gaussian t/F inference.
  • Distinguish uncertainty about a mean response from prediction of an independent new observation.
  • Assess diagnostics, influence, conditioning, selection, validation and penalized risk under their actual assumptions.
01

Define what the fitted function is intended to do

A regression relates a response Y to specified predictors or features. Name the observational unit, response and feature units, target population and data collection before fitting. A descriptive line through one record, a population best linear predictor, a conditional mean, a future-response prediction and a causal intervention effect are different targets. The same numerical coefficient need not answer all of them.

Distinguish a fixed design from a random-design experiment. A fixed feature matrix can represent controlled inputs or an analysis conditional on the observed features. A random-design target instead refers to a joint population distribution of features and response. Conditional statements about a particular full-rank matrix do not automatically establish unconditional results across every possible sampled matrix.

Simple regression starts with one predictor and an intercept. Multiple regression uses several specified features, which can include indicators, transformations and interactions. Linear means linear in the unknown coefficients; it does not require the response to be a straight-line function of every original raw variable.

All data and models here are hypothetical. Begin with units and vertical residuals, then add projection, rank and multiple-feature interpretation. The optional deeper path develops conditional assumptions, sandwich covariance, exact t/F laws, prediction, diagnostics and penalized risk. The scientific target remains attached to each calculation.

02

A slope has response-per-predictor units

A fitted simple line is ŷ=b₀+b₁x. The intercept b₀ has response units and the slope b₁ has response units per predictor unit. A change of one x unit changes the fitted response by b₁ units within this model. Interpreting that as an intervention effect requires additional scientific identification assumptions.

The intercept is the fitted value at x=0, which may lie outside the observed or scientifically meaningful predictor range. Centering x at a relevant value can make the intercept a more useful fitted reference. It changes the parameterization, not the information in the original pairs or the correctness of an extrapolated response model.

Ordinary least squares minimizes squared vertical response errors yᵢ−(b₀+b₁xᵢ), treating the specified features as the predictor coordinates. Perpendicular distances in the raw x–y plot define another objective, such as a total-least-squares construction under its own measurement assumptions. Error in a predictor is not automatically handled by drawing an ordinary fitted line.

Regression is asymmetric. The slope of Y on X is not generally the reciprocal of the slope of X on Y. With an intercept and both spreads positive, their product is r². The two objectives minimize errors in different response coordinates, retaining their different units and targets.

03

Derive the least-squares line

Minimize Q(b₀,b₁)=Σᵢ[yᵢ−b₀−b₁xᵢ]² over real coefficients. Differentiating gives Σeᵢ=0 and Σxᵢeᵢ=0, where eᵢ=yᵢ−b₀−b₁xᵢ. The first equation yields b₀=ȳ−b₁x̄. Substitution centers the problem and gives b₁Sxx=Sxy.

If Sxx>0, the unique coefficients are b₁=Sxy/Sxx and b₀=ȳ−b₁x̄. This finite algebra requires a nonconstant predictor and an intercept, not a Gaussian sampling law. When Syy is also positive, b₁=r√(Syy/Sxx)=r·sY/sX using consistent moment divisors. If the response is constant, the line can still be fitted even though r is undefined.

For x=(−2,−1,0,1,2,3) and y=(−2,−2,1,3,4,8), x̄=1/2,ȳ=2,Sxx=35/2 and Sxy=35. Thus b₁=2 and b₀=1. Its fitted responses are (−3,−1,1,3,5,7), with residuals (1,−1,0,0,−1,1). Their sum and x-weighted sum are zero, as required by the normal equations.

Vertical residuals and observation-space projectionThe fitted response curve, observed pairs and vertical squared-response-error geometry use exact rational offsets before drawing conversion. Coincident records share positions; the complete text table retains every record.Vertical residuals and observation-space projection≈-3≈-1.50≈1.5≈3≈-6.1≈-2.8≈0.5≈3.8≈7.1Vertical response residuals; axes use exact rational offsets.X offset (cm); origin 1/2Y offset unit: response units; origin 2Filled: observations; blue open: fit; green: vertical residuals.
The graph encodes the stated feature fit. It supplies no causal claim or statistical error law. Coincident fitted and observed values share coordinates; every exact origin and raw record remains in the tables.

Least squares minimizes the sum of squared vertical response residuals over the declared feature space. Algebra alone supplies no Gaussian model, exogeneity or causal interpretation.

Centered R² requires positive SST; the usual residual mean square requires positive residual degrees of freedom. Its population interpretation needs an additional error model.

Exact algebra and declared model quantities
QuantityValue
Rows / columns / rank6 / 2 / 2
Coefficient convention1, 2
SSE4
Centered SST74
Centered R²35/37
Residual df n−rank4
Residual mean square1
Coefficient unitsresponse units; response units/cm
Slope unitsresponse units per cm
SSE / residual mean-square unitresponse units²
Centered Sxx / Sxy35/2 / 35
Exact mean origins1/2 cm; 2 response units
Full exact rows, matrices and diagnostic quantities
Every observed row, fit and vertical response residual
RowFeature rowResponseFittedResidual
11, -2-2-31
21, -1-2-1-1
31, 0110
41, 1330
51, 245-1
61, 3871

Exact rational inputs and expressions remain in the tables. Curves, logarithmic tails and values marked ≈ are numerical drawings or evaluations. A stipulated model is an assumption; the fitted geometry does not establish its truth, causal identification or a universal risk benefit.

The minimum can be verified globally rather than only by a derivative. For the fitted vector and residual e, every competing fitted change lies in the feature span and is orthogonal to e. Expanding a competing squared error then adds a nonnegative squared fitted-change length. The next sections make this projection argument explicit and extend it beyond one predictor.

04

A population best linear predictor is a separate target

Let Z be a feature vector, including a constant one if an intercept is intended. Assume E[Y²]<∞, every feature has a finite second moment, and Q=E[ZZᵀ] is positive definite. The unique population coefficient minimizing E[(Y−Zᵀβ)²] is β*=Q⁻¹E[ZY]. Finite second moments ensure the cross-moment vector exists by Cauchy–Schwarz.

Expand the expected loss as E[Y²]−2βᵀE[ZY]+βᵀQβ and complete the square around β*. The residual U=Y−Zᵀβ* obeys E[ZU]=0. This orthogonality identifies a best linear approximation under the chosen joint population law. It does not generally imply E[U|Z]=0 or a truly linear conditional mean.

For X uniform on [−1,1] and Y=X², the best affine predictor is the constant 1/3 because covariance with X is zero. Its residual has conditional mean x²−1/3, which varies with x. The approximation is optimal within affine functions while missing the actual conditional curve. A projection coefficient can also change when the target population’s predictor distribution changes.

A correct linear conditional mean E[Y|Z]=Zᵀβ is a stronger assumption and supplies conditional-mean-zero errors. Even a positive-definite population Q does not guarantee full rank of every finite sampled feature matrix or an integrable inverse. Preserve the population target, sample rank condition and needed expectation conditions as separate statements.

05

Multiple features use the same squared-error principle

Let X be the n×p feature matrix and y the n-vector of observed responses. Here p counts every fitted coefficient, including the intercept column when present. Least squares minimizes ‖y−Xb‖². Its normal equations are XᵀXb=Xᵀy, which characterize global minimizers of this convex quadratic.

If X has full column rank p, G=XᵀX is positive definite and b=G⁻¹Xᵀy is unique. If rank is deficient, minimizers still exist because the column space is a closed finite-dimensional subspace; the fitted projection exists even though that inverse formula is unavailable. Do not translate a singular inverse into absence of every possible fitted solution.

The displayed inverse is an algebraic expression, not a recommendation to form an inverse numerically. QR or rank-revealing/SVD methods provide appropriate computational routes under their conditions. Scaling and parameterization should preserve the physical feature meaning, while rank decisions and numerical tolerances require explicit handling.

No sampling distribution has been invoked by these equations. A program can solve them on a finite record without proving conditional unbiasedness, equal variance, independent errors, normal inference or causal identification. Those claims will be added in distinct layers.

06

Projection is orthogonal in observation space

At full column rank, H=X(XᵀX)⁻¹Xᵀ maps y to its fitted vector. It is symmetric and idempotent, Hᵀ=H and H²=H, with trace p. The residual is e=(I−H)y and satisfies Xᵀe=0. This orthogonality is in the n-dimensional observation space, rather than a claim that ordinary raw-scatter residual segments are perpendicular to the fitted x–y line.

For any least-squares solution b*, including a rank-deficient case, e=y−Xb* is orthogonal to every vector Xc. Therefore ‖y−Xb‖²=‖e‖²+‖X(b−b*)‖². This proves global minimality and uniqueness of the fitted vector. Coefficient uniqueness additionally needs full column rank.

An intercept, or an equivalent constant feature in the span, makes residuals sum to zero. Without it, that sum need not vanish. Residual orthogonality to fitted columns is automatic algebra, so observing it cannot validate exogeneity, independence or the scientific interpretation of a coefficient.

For X columns (1,1,1)ᵀ and (−1,0,1)ᵀ with y=(0,2,1)ᵀ, b=(1,1/2), fitted values are (1/2,1,3/2) and e=(−1/2,1,−1/2). The residual is orthogonal to both feature columns, with squared length 3/2. These concrete vectors distinguish the projection geometry from the raw measurement plot.

07

Unique fitted values do not identify every coefficient

If X is rank deficient, two least-squares solutions differ by a vector v with Xv=0. Every observed fitted value is therefore unchanged along that coefficient direction. A pseudoinverse or an explicit coefficient constraint can select one representative, but the numerical convention does not identify separate scientific coefficients from missing variation.

For rows (1,0,0),(1,1,2),(1,2,4) and responses (1,3,5), every vector (1,2−2t,t) gives the same perfect fitted response. The last two features obey z=2x, so only their combination is identified. Intercept-plus-all-group-indicator designs similarly have an exact column dependence unless a reference or constraint is declared.

A new query feature row z₀ᵀ gives a unique prediction across all minimizing coefficients precisely when z₀ᵀv=0 for every v in null(X), equivalently z₀ lies in the row space of X. In the example, query (1,3,6) predicts 7 for all t, while (1,3,5) predicts 7−t and is not identified. Unique training fits do not supply a unique off-support prediction.

Rank, projection weights and estimable queriesComputed scientific geometry with exact text equivalents.Rank, projection weights and estimable queriesGreen solid: query 1; orange dashed: query 2.H: signed projection weights115/61/3-1/6221/31/31/333-1/61/35/6Blue + / red −; neutral 0; opacity scales |Hᵢⱼ|.≈-20≈2≈-2.40≈2.4Query prediction offsetsNull-direction coordinate tPrediction offset origin = 7; exact value in table.Each query varies a witness null direction; full table tests all.A chosen coefficient convention does not identify an off-row-space query.
The signed heatmap encodes actual hat-matrix weights. Each query line varies a witness null direction over equally minimizing coefficients; a constant identified query annihilates every null direction. Full exact weights and null bases remain in the tables.

Result held: At least one new query is not identified by the original design. Its prediction is held; the diagram shows how a minimizing coefficient family changes it.

Exact algebra and declared model quantities
QuantityValue
Rows / columns / rank3 / 3 / 2
Coefficient convention1, 2, 0 ; not a unique coefficient vector
SSE0
Centered SST8
Centered R²1
Residual df n−rank1
Residual mean square0
Full exact rows, matrices and diagnostic quantities
Every observed row, fit and vertical response residual
RowFeature rowResponseFittedResidual
11, 0, 0110
21, 1, 2330
31, 2, 4550
Exact hat matrix
Row123
15/61/3-1/6
21/31/31/3
3-1/61/35/6
Prediction identification is a row-space question
Query rowIdentified?PredictionWitness null direction
1, 3, 6true7All null directions annihilated
1, 3, 5falseNot identified0, -2, 1

Exact rational inputs and expressions remain in the tables. Curves, logarithmic tails and values marked ≈ are numerical drawings or evaluations. A stipulated model is an assumption; the fitted geometry does not establish its truth, causal identification or a universal risk benefit.

More parameters than rows, duplicated features and an unsupported interaction can create rank failures. State the estimable contrast or supported prediction rather than interpreting a chosen coefficient convention as new information. Near rank deficiency is a different numerical and uncertainty problem, discussed below.

08

Residualize the features that define a fitted contrast

A multiple-regression coefficient describes change in the fitted function with the other specified features held fixed. The meaning depends on the feature basis and feasible support. Adding a feature can change the fitted contrast, especially when predictors share variation. The change alone does not show which coefficient is causal or which model has identified a scientific intervention.

For a full-rank partition X=[B A], let M_B=I−B(BᵀB)⁻¹Bᵀ. Eliminating the nuisance-feature coefficients from the normal equations gives b_A=(AᵀM_BA)⁻¹AᵀM_By. Since M_B is symmetric and idempotent, this is the through-origin least-squares regression of residualized response M_By on residualized target features M_BA. Include the intercept in the nuisance span when that is the original model.

This Frisch–Waugh–Lovell identity is sample algebra, requiring the stated ranks. It does not justify replacing every partial regression by an arbitrary residualization of only one side or by a new causal adjustment. The full residual vector agrees with the residualized regression, while its relevant degrees of freedom and inferential model remain those of the full analysis.

For x=(−2,0,0,2), z=(−1,1,−1,1), y=(−5,3,−3,9), the short x slope is 7/2 and the full coefficients on (1,x,z) are (1,2,3). Removing the fitted (1,z) parts gives x residuals (−1,−1,1,1) and y residuals (−1,−3,1,3), with slope 8/4=2. A population omitted-variable formula needs its own population projection or error-orthogonality conditions.

Partial fits, interactions and near aliasingComputed scientific geometry with exact text equivalents.Partial fits, interactions and near aliasing≈-1.2≈-0.60≈0.6≈1.2≈-3.6≈-1.80≈1.8≈3.6Residualize x and y against the same columns (1,z).x residual; the fitted residual line has no new interceptY axis: y residual. Short and full slopes use different fitted targets.
The plotted through-origin residual slope equals the full x coefficient only when the residualized x direction is nonzero and the full coefficient is identified. The original short slope belongs to another fitted specification.

These are conditional fits in a declared feature basis, not causal effects. A changed feature specification changes the fitted contrast.

The constructed multiple-feature examples use dimensionless features and one response unit. In the conditioning covariance calculation, a correct centered linear mean and covariance σ²I are stipulated; the response-perturbation path is a sensitivity calculation, not a stochastic simulation.

Exact rank uses rational algebra. A small nonzero predictor difference is not silently replaced by an exact alias.

Exact algebra and declared model quantities
QuantityValue
Rows / columns / rank4 / 3 / 3
Coefficient convention1, 2, 3
SSE4
Centered SST120
Centered R²29/30
Residual df n−rank1
Residual mean square4
Short x slope7/2
FWL residual-through-origin slope2
Full exact rows, matrices and diagnostic quantities
Every observed row, fit and vertical response residual
RowFeature rowResponseFittedResidual
11, -2, -1-5-61
21, 0, 134-1
31, 0, -1-3-2-1
41, 2, 1981

Exact rational inputs and expressions remain in the tables. Curves, logarithmic tails and values marked ≈ are numerical drawings or evaluations. A stipulated model is an assumption; the fitted geometry does not establish its truth, causal identification or a universal risk benefit.

09

Linear coefficients can describe nonlinear raw-variable changes

A linear-in-coefficients model can include 1,x,x²,group indicators or products such as ab as separate features. The coefficient vector enters linearly even though the fitted response can curve with a raw variable. Choose a basis and parameterization that match the scientific comparison and preserve its units.

In f(a,b)=β₀+βA a+βB b+βAB ab, the fitted derivative with respect to a is βA+βAB b. A raw change in a also changes its derived product ab when b is fixed. Holding ab independently fixed while changing a can describe an impossible feature combination, rather than the intended raw-variable comparison.

For four rows with a,b each ±1, responses (5,1,7,7) give additive coefficients (5,2,−1) and residuals (1,−1,−1,1). Adding the interaction ab produces f=5+2a−b+ab with zero training residual. Its a slope is 2+b. This four-row, four-parameter fit has zero residual degrees of freedom, so interpolation does not provide an error-variance estimate.

Indicator reference levels and centering choices change coefficient labels while retaining a corresponding fitted function. Interpret the whole function and valid contrasts. A coefficient for a baseline group or a main effect in an interaction model should not be presented as a universal response change across every group and input.

10

Training fit measures the fitted feature space

With an intercept, positive SST=Σ(yᵢ−ȳ)² and ordinary least squares, SST=SSR+SSE, where SSR=Σ(ŷᵢ−ȳ)². The fitted centered vector is orthogonal to the residual. Thus R²=1−SSE/SST lies in [0,1]. For simple regression with both spreads positive it equals r²; that special identity does not make every multiple-regression coefficient a correlation.

Enlarging a nested feature space cannot increase its minimum training SSE, so its ordinary training R² cannot decrease when the same response record and denominator are used. Extra flexibility receives this mechanical reward even when it follows noise or harms future prediction. A fit statistic is not a causal fraction of response variation.

When the intercept model has full column rank p<n and positive SST, adjusted R²=1−[SSE/(n−p)]/[SST/(n−1)] accounts for the fitted dimension in this convention. It can decrease or be negative. Without an intercept, centered and uncentered R² conventions can differ, and the centered value can be negative. Constant response makes SST zero and this ratio undefined.

The six-pair line has SST=74,SSR=70,SSE=4 and R²=35/37. A clear nonlinear residual pattern can coexist with a fairly large R² in another record. Retain diagnostics, target and validation rather than treating one training number as evidence of correct mean shape, future performance or scientific explanation.

11

Add statistical claims to algebra in separate layers

Write a conditional linear model y=Xβ+ε for a fixed or conditioned-on design X. The finite least-squares algebra needs no random error law. Conditional unbiasedness requires E[ε|X]=0 and the relevant integrability. A covariance statement additionally requires finite conditional second moments and a specified Ω=Cov(ε|X). These are separate assertions about the experiment.

The homogeneous uncorrelated model Ω=σ²I supplies the usual covariance and Gauss–Markov efficiency result. It is stronger than arbitrary heteroskedastic covariance, but it does not require Gaussian errors or normally distributed predictors. Independence of errors is also stronger than the zero-covariance condition alone and should not be inferred from it.

Exact classical t/F calibration below assumes ε|X∼N(0,σ²I), with σ²>0, full column rank and n>p. This explicitly centers the conditional mean at Xβ. Gaussian errors with a nonzero mean would not establish that target-centering or unbiasedness merely by having a known covariance.

A correct conditional mean is stronger than population projection orthogonality, and a causal coefficient needs further design or identification. State which layer is being used for each conclusion. Neither a fitted residual plot nor a small coefficient p-value can silently supply all the other assumptions.

12

State the domain of the unbiasedness and BLUE claims

At fixed full-rank X, b=β+(XᵀX)⁻¹Xᵀε. Integrable conditional-mean-zero errors therefore give E[b|X]=β. Under a random-design law, an unconditional expectation also needs integrability of the estimator. Finite population feature/response moments do not by themselves control a nearly singular random inverse for every finite sample.

With finite conditional covariance Ω, Var(b|X)=G⁻¹XᵀΩXG⁻¹. If Ω=σ²I, this reduces to σ²G⁻¹. The covariance concerns repeated responses under the specified design; a single observed residual vector is not that covariance matrix or proof of its assumptions.

Under this homogeneous model, OLS is best linear unbiased, or BLUE: among estimators Ly that are linear in y and conditionally unbiased, its covariance is minimal in the positive-semidefinite order. Write L=G⁻¹Xᵀ+C with CX=0. Then the competitor’s covariance minus OLS covariance is σ²CCᵀ, positive semidefinite. Gaussianity is unnecessary for this argument.

The restriction to linear conditionally unbiased estimators matters. The result does not claim smallest mean squared error among all biased, nonlinear, selected or penalized estimators. Nor does it prove that the conditional mean is correct or the coefficient causal. Those scientific assumptions remain outside the covariance comparison.

13

Different variance models give different uncertainty calculations

For general Ω, retain the sandwich G⁻¹XᵀΩXG⁻¹ rather than replacing it with one common-variance expression. Fixed-design independent errors can have different variances while OLS remains conditionally unbiased under mean zero. Their usual homogeneous standard errors and exact t calibration do not follow from that unbiasedness.

For fixed x=(−1,0,1) with independent mean-zero error variances (1,1,9), slope noise weights are (−1/2,0,1/2), giving true slope variance 5/2. The expected usual s²/Sxx is instead 7/6. Correct mean specification therefore does not establish the usual variance estimator. At n=3 a heteroskedasticity-consistent estimate is not an exact universal repair.

Covariance models and pointwise uncertaintyComputed scientific geometry with exact text equivalents.Covariance models and pointwise uncertaintyΩ: stipulated error covariance1110022010330090≈0.9583≈1.917≈2.875TrueE[usual]Slope variance: same scaleBlue + / red −; exact Ω is stipulated.Response unit: response unitsPredictor unit: cmVariance units are squared response-per-predictor units.
Mean-zero errors preserve conditional unbiasedness under the stated mean model. A general Ω changes the true covariance to AΩAᵀ; it does not make the usual homogeneous formula correct or a tiny-sample robust estimate exact.

This covariance-only illustration stipulates a correct linear mean, E[ε|X]=0 and Var(ε|X)=Ω. Gaussianity and independence are not required; off-diagonal Ω allows dependence.

The F slice stipulates fixed nested full-rank specifications on the same observations, two independent restrictions under the null, and a positive full-model residual variance. Reference-only df are declared summaries, not inferred from a plot.

A mean-response target, an independent future observation and a selected analysis have different uncertainty requirements. Algebraic residual orthogonality does not establish the sampling assumptions.

Exact algebra and declared model quantities
QuantityValue
True coefficient covariance11/9, 4/3 ; 4/3, 5/2
E[SSE | X]7/3
E[usual s² | X]7/3
True slope variance5/2
E[usual slope variance estimate | X]7/6
Intercept / slope unitsresponse units ; response units/cm
Variance / cross-covariance unitsresponse units² ; response units²/cm ; (response units/cm)²
Full exact rows, matrices and diagnostic quantities
Exact coefficient-noise weights
CoefficientError 1Error 2Error 3
Intercept1/31/31/3
Slope-1/201/2

Exact rational inputs and expressions remain in the tables. Curves, logarithmic tails and values marked ≈ are numerical drawings or evaluations. A stipulated model is an assumption; the fitted geometry does not establish its truth, causal identification or a universal risk benefit.

One sufficient large-sample sandwich regime uses iid pairs (Z,Y), fixed feature dimension p, finite fourth moments of features and response, and positive-definite Q=E[ZZᵀ]. For population projection β* and U=Y−Zᵀβ*, √n(b−β*) tends to a normal law with covariance Q⁻¹E[ZZᵀU²]Q⁻¹. LLN/CLT and the normal equations give this result; a nondegenerate Wald contrast needs positive limiting contrast variance. Residual plug-in HC estimates require these kinds of conditions and are asymptotic, not exact finite-sample t laws.

Correlated or clustered observations need their corresponding covariance and asymptotic design. If the actual Ω is known and positive definite, generalized least squares uses (XᵀΩ⁻¹X)⁻¹XᵀΩ⁻¹y with covariance (XᵀΩ⁻¹X)⁻¹ under the stated mean model. Independent known unequal variances give precision weighting as a special case. Estimated weights, dependence or a changed mean target need additional justification.

14

Exact classical inference needs the centered Gaussian error model

Assume a full-rank fixed or conditioned-on X, n>p, and ε|X∼N(0,σ²I) with σ²>0. Then b|X∼N(β,σ²G⁻¹). The residual quadratic SSE/σ² has chi-square(n−p) law and is independent of b. Orthogonal Gaussian projections Hε and (I−H)ε are uncorrelated and therefore independent, with residual projection rank n−p.

The usual estimator s²=SSE/(n−p) is unbiased for σ² under this model. For a prespecified nonzero coefficient contrast c, [cᵀb−cᵀβ]/[s√(cᵀG⁻¹c)] has t_(n−p) law when the denominator is defined. This is conditional on the stated design and error model. Normal predictors are unnecessary, and a chosen observed coefficient is not automatically a prespecified contrast.

For fixed nested models with q independent restrictions and full-model dimension p, the statistic F=[(SSEreduced−SSEfull)/q]/[SSEfull/(n−p)] has F_(q,n−p) null law when the reduced restrictions hold. The model spaces must be genuinely nested and selected independently of the response for this direct classical claim. Multiple or selected tests need the appropriate whole-procedure treatment.

With n=p and full rank, interpolation leaves residual df zero, so SSE/(n−p) is undefined. A zero observed residual variance likewise cannot be inserted into an ordinary finite t denominator. The model with positive noise can produce arbitrarily small SSE, but the exact positive-df Gaussian law assigns probability zero to SSE exactly zero. Keep such finite-data boundaries explicit instead of reporting certainty.

15

A new response adds its own error variation

For a known query feature vector z₀, estimate its conditional mean by z₀ᵀb. Under the correct conditional-linear homogeneous model, the mean-estimation variance is σ²h₀, where h₀=z₀ᵀG⁻¹z₀. This measures uncertainty about the fitted population mean at that query, rather than variation of a new individual response around it.

If a new response follows Y₀=z₀ᵀβ+ε₀ with error independent of training and variance σ², its prediction error is ε₀−z₀ᵀ(b−β). The cross covariance vanishes, so prediction variance is σ²(1+h₀). Under the same centered Gaussian model, these normal numerators are independent of the training SSE and yield pointwise t intervals with n−p degrees of freedom.

Thus a mean-response confidence interval is z₀ᵀb±t_(n−p,1−α/2)s√h₀, while a new-response prediction interval is z₀ᵀb±t_(n−p,1−α/2)s√(1+h₀). For the six-pair line at x₀=x̄=1/2, the fitted mean is 2,s²=1 and h₀=1/6. The 95% intervals are approximately [0.86652103,3.13347897] for the mean and [−0.99890347,4.99890347] for one independent new response.

These are pointwise intervals at a query fixed independently of response-based selection, not simultaneous bands over every searched x. The query features are treated as known, and the model is assumed appropriate at the query. Uncertain predictor measurements, an unmodelled population shift, extrapolation or a causal intervention need additional uncertainty and scientific justification.

16

Inspect different diagnostics for different failures

Plot residuals against fitted values and relevant features to examine mean shape and changing spread. Plot them against acquisition order or groups to examine drift and dependence. Suitable Q–Q displays can assess aspects of the proposed error distribution. Each looks at a different implication of the model; no one favorable display proves every assumption.

A fairly high training R² can coexist with an obvious defect. For x=(−2,−1,0,1,2) and y=(8,8,10,14,20), the fitted line is 12+3x with R²=45/52. Its residuals (2,−1,−2,−1,2) form a U shape. Adding x² fits this constructed record exactly as 10+3x+x², but zero training SSE does not establish a noise-free population or correct extrapolation.

Even with independent homogeneous errors, residuals themselves are constrained and generally correlated: Cov(e|X)=σ²(I−H). Their variances are σ²(1−hᵢ), and their off-diagonal covariance reflects the common fitted projection. Treating them as an untouched iid error sample ignores this structure and its residual degrees of freedom.

Use diagnostics to investigate scientific measurement, model and design concerns. If the analysis is revised after inspecting patterns, report that process and evaluate the revised procedure appropriately. A plausible residual picture is evidence about selected implications, not a guarantee of correct conditional means, independent sampling or causal identification.

17

Distinguish feature geometry from a changed fit

Leverage hᵢ=Hᵢᵢ satisfies 0≤hᵢ≤1 and Σhᵢ=p. It describes the observation’s location in the fitted feature geometry. A response outlier concerns an unusual response relative to a specified model; influence concerns how an observation changes a fitted result. High leverage need not imply a large residual or a mistaken measurement.

For full rank, hᵢ<1 and a delete-one design retaining full rank, the leave-one-out prediction error at that row is eᵢ/(1−hᵢ). A standard Cook distance is Dᵢ=eᵢ²hᵢ/[p s²(1−hᵢ)²] when p,s² and the denominator are defined. Its value depends on the stated fit and variance convention.

If hᵢ=1, the training residual at that row is zero and deletion lowers rank. The displayed ratio becomes 0/0, so the usual unique delete-one prediction formula is unavailable. This is an identification boundary, not a reason to replace the ratio by zero or an arbitrary large number.

For the last six-pair observation (3,8), e=1,h=11/21 and s²=1. Deleting it changes coefficients from (1,2) to (4/5,17/10), gives deleted prediction error 21/10 and Cook distance 231/200. These are sensitivity facts to investigate. No universal cutoff makes deletion scientifically justified or establishes data error or misconduct.

Leverage and the actual delete-one fitThe fitted response curve, observed pairs and vertical squared-response-error geometry use exact rational offsets before drawing conversion. Coincident records share positions; the complete text table retains every record.Leverage and the actual delete-one fit≈-3≈-1.50≈1.5≈3≈-6.1≈-2.8≈0.5≈3.8≈7.1Full fit blue; rank-retained deleted fit orange dashed; red selected.10123456Lower panel: exact leverage, on a common 0…1 scale.Observation row; full units and offsets remain in the table
A deleted curve is drawn only when deletion retains the original rank. Unit leverage makes the training residual zero and destroys that deletion rank; e/(1−h) is then undefined 0/0. Cook distance additionally needs full column rank and a positive residual-variance estimate. None is an automatic deletion rule.
Exact algebra and declared model quantities
QuantityValue
Rows / columns / rank6 / 2 / 2
Coefficient convention1, 2
SSE4
Centered SST74
Centered R²35/37
Residual df n−rank4
Residual mean square1
Selected leverage11/21
Deleted design rank2; original 2
Deleted prediction error21/10
Cook distance231/200
Predictor / response unitscm; response units
SSE / residual mean-square unitresponse units²
Exact plot origins1/2 cm; 2 response units
Full exact rows, matrices and diagnostic quantities
Every observed row, fit and vertical response residual
RowFeature rowResponseFittedResidual
11, -2-2-31
21, -1-2-1-1
31, 0110
41, 1330
51, 245-1
61, 3871

Exact rational inputs and expressions remain in the tables. Curves, logarithmic tails and values marked ≈ are numerical drawings or evaluations. A stipulated model is an assumption; the fitted geometry does not establish its truth, causal identification or a universal risk benefit.

18

Numerical stability and scientific identification are distinct

Near dependence among feature columns can inflate individual coefficient variances while leaving some fitted combinations much more stable. Pairwise predictor correlations can miss a multivariate dependency. In an intercept homogeneous full-rank model, the VIF for a predictor is 1/(1−Rⱼ²), where Rⱼ² comes from regressing that predictor on the other specified predictors.

A large VIF describes a conditional variance comparison at the same error variance and centered predictor spread. It is not a universal instruction to drop a scientifically necessary covariate, and lowering it can change the fitted target or causal adjustment. Centering original linear predictors does not in general remove their ordinary correlation, although a changed feature parameterization can improve interpretability or some numerical scaling.

At full column rank the positive singular values of XᵀX are the squares of those of X. Hence κ₂(XᵀX)=κ₂(X)². Forming normal equations numerically can magnify conditioning problems. QR/back substitution or a suitable rank-revealing/SVD method works with the actual feature geometry without explicitly forming an inverse.

Scaling, constraints and stable algorithms can improve computation, but they do not create identifying variation. A numerical tolerance for tiny singular values is a declared computational decision. Separate exact aliasing, unstable estimation of weak directions and a scientific claim that a coefficient is a distinct effect.

19

A different observation process can change the target

Regression begins with a response definition, feature measurements and a sampling process. Predictor measurement error can change the observed projection; outcome-dependent selection can change a selected sample’s conditional mean. A complete-case analysis needs assumptions connecting its observations to the intended target. More records or a robust standard error alone does not restore missing scientific identification.

Repeated measurements, related participants, spatial dependence and time series can have nonzero off-diagonal error covariance. A heteroskedasticity-only covariance estimator does not automatically address that dependence. A cluster, time-series or other covariance analysis needs conditions and independent units appropriate to that design, rather than treating copied rows as additional independent evidence.

Feature or response transformations also change interpretation. If log Y=m(X)+η with η|X∼N(0,τ²), then E[Y|X]=exp(m(X)+τ²/2), obtained from the normal exponential moment. Simply exponentiating the log-scale conditional mean gives exp(m(X)), the conditional median in this model. Original-scale mean prediction therefore needs the error-distribution correction and its assumptions.

Record measurement units, outcome timing, grouping, exclusions and transformations along with coefficients. Diagnostics, resampling, covariance estimation and validation should follow the actual observation process. A precise estimate for a changed target can still answer a different scientific question from the intended one.

20

A fitted adjustment needs an intervention argument

The preceding correlation lesson constructed different causal systems with the same observational distribution and different intervention responses. Reuse that identification result here: an observational conditional-mean slope, even estimated perfectly, does not by itself identify a response to manipulating a predictor. Better numerical fitting cannot distinguish observationally equivalent causal systems.

The condition E[ε|X]=0 makes β a correct observational conditional-mean coefficient in the specified model. A causal interpretation needs additional assumptions about the scientific system, interventions, relevant confounding, selection and stable relationships. Writing a regression error with zero conditional mean does not supply those assumptions.

Including a variable can be scientifically necessary, can change the target, or can introduce a problematic adjustment through a collider or post-intervention mediator. The decision needs a defensible causal structure and timing, rather than a general instruction to control every available column. Estimated uncertainty conditional on a chosen regression does not resolve ambiguity about that structure.

In an interaction model, even the fitted conditional slope varies with the other interacting feature. Distinguish a mathematical comparison of predictions from a feasible intervention, especially when combinations are rare or impossible in the population. Report the intended target and supporting identification assumptions before attaching an effect interpretation.

21

Evaluate the procedure on information it did not fit

Adding features to nested least-squares spaces cannot increase training SSE, because the old fitted vector remains available. This geometric fact alone says little about the error on new responses. A flexible model can fit training noise and produce larger future prediction error than a simpler one.

Use a genuine held-out assessment or appropriately nested validation to evaluate the whole selected procedure. Imputation, scaling, feature screening, basis selection and tuning must be learned within each training fold for an ordinary inductive assessment. Choosing these operations on all outcomes before splitting can let validation information influence the model it is supposed to evaluate.

Preserve independent units when splitting. Repeated records of one participant can require group splits, and forecasting can require time-respecting splits and features available at the prediction time. A random row split can otherwise answer an easier question than the intended deployment task.

Validation has sampling variability and a target distribution. A small held-out comparison is noisy, and repeated selection on its scores consumes its independence as a final assessment. Iid validation does not establish performance after a changed population or measurement process. Report prediction loss, the unit of averaging, the selection procedure and remaining uncertainty.

Training fit, validation and a declared penaltyComputed scientific geometry with exact text equivalents.Training fit, validation and a declared penalty≈-1.2≈-0.60≈0.6≈1.2≈-1.2≈-0.60≈0.6≈1.2Blue line; orange quadratic; green open dots: validation responses.Fixed predictor; response has the stipulated three-point lawTraining, observed validation loss and population risk are distinct.
Conditional future risk is Var(Ynew)+(prediction−0)² under the stated independent three-point response law. Two observed validation responses do not establish a reliable general model ranking. Reusing validation for selection holds its untouched-assessment interpretation.

Every response in this constructed validation example is independently uniform on {−1,0,1}, independent of the fixed predictor values. Future responses are independent of the training record. The untouched flag concerns assessment reuse, not the separately stipulated future-risk law.

Prediction assessment must include the whole learned pipeline within its training split; groups and time require appropriate splits.

A fixed penalty changes the estimator and its target-dependent risk. It does not supply new identifying data or justify retuned-data confidence claims.

Declared law, observed losses and conditional new-response risk
FitTraining SSEObserved validation MSEConditional future risk
Line8/31/97/9
Quadratic01/411/12

Exact rational inputs and expressions remain in the tables. Curves, logarithmic tails and values marked ≈ are numerical drawings or evaluations. A stipulated model is an assumption; the fitted geometry does not establish its truth, causal identification or a universal risk benefit.

22

A penalty changes the estimator and its uncertainty

Consider the declared objective ||y−Xb||²+λbᵀPb, with λ>0 and symmetric positive-semidefinite P. Its coefficient solution is unique exactly when null(X)∩null(P)={0}, because vᵀ(G+λP)v=||Xv||²+λvᵀPv is positive for every nonzero v under that condition. With P=I it is unique even for a rank-deficient design.

When G+λP is invertible, bλ=(G+λP)⁻¹Xᵀy. In a correct conditional-linear model, its conditional bias is −λ(G+λP)⁻¹Pβ. Under homogeneous covariance its conditional covariance is σ²(G+λP)⁻¹G(G+λP)⁻¹. A variance reduction can be accompanied by bias that increases the mean-square error for some β.

For P=I, a positive squared singular value d² has fitted shrinkage factor d²/(d²+λ); zero singular directions do not gain identifying information from the data. The penalty selects a unique convention among aliased possibilities. If the intercept is intended to be unpenalized, declare the corresponding zero entry in P and check the null-space condition rather than silently applying the P=I formula to it.

Units and objective normalization matter. A penalty on a coefficient has to be compatible with the response-scale squared loss, and scaling a feature changes the meaning of an unchanged numerical penalty. Minimizing mean squared error rather than its unnormalized sum also changes the equivalent λ by a factor of n. Data-based tuning belongs inside the evaluated selection procedure.

Ordinary unpenalized t intervals do not retain their original justification after shrinkage or response-based tuning. A frequentist uncertainty analysis must account for the changed estimator and selection; a Bayesian interpretation additionally declares a likelihood and prior. The preceding Bayesian lesson distinguishes its posterior statements from repeated-sampling guarantees.

23

Report the target, design and evidence together

A useful report identifies the response and feature units, reference coding, transformations, interaction conventions, fitted target, sample and independent-unit counts. It states rank and residual degrees of freedom, relevant diagnostics, the chosen covariance/interval model, and the procedure used for model selection and prediction assessment.

In physical calibration, a vertical-error regression requires a defensible observation-error direction; appreciable error in both axes can require a different measurement model. In biology, repeated measurements and variation between organisms change the independent information available. In economics, a stable association or conditional projection needs an additional identification argument for a policy intervention.

For machine learning, linear regression supplies an explicit projection, an interpretable bias–variance example and a test bed for leakage, conditioning, regularization and population shift. More elaborate features retain linearity in coefficients while changing the fitted function class and the scientific assumptions attached to interpretation.

Change one declared model or boundary at a time. Each panel retains its actual scientific state and complete text equivalent.

Vertical residuals and observation-space projection

W1: six pairs, vertical residuals and units · ready

Vertical residuals and observation-space projectionThe fitted response curve, observed pairs and vertical squared-response-error geometry use exact rational offsets before drawing conversion. Coincident records share positions; the complete text table retains every record.Vertical residuals and observation-space projection≈-3≈-1.50≈1.5≈3≈-6.1≈-2.8≈0.5≈3.8≈7.1Vertical response residuals; axes use exact rational offsets.X offset (cm); origin 1/2Y offset unit: response units; origin 2Filled: observations; blue open: fit; green: vertical residuals.
The graph encodes the stated feature fit. It supplies no causal claim or statistical error law. Coincident fitted and observed values share coordinates; every exact origin and raw record remains in the tables.

Least squares minimizes the sum of squared vertical response residuals over the declared feature space. Algebra alone supplies no Gaussian model, exogeneity or causal interpretation.

Centered R² requires positive SST; the usual residual mean square requires positive residual degrees of freedom. Its population interpretation needs an additional error model.

Exact algebra and declared model quantities
QuantityValue
Rows / columns / rank6 / 2 / 2
Coefficient convention1, 2
SSE4
Centered SST74
Centered R²35/37
Residual df n−rank4
Residual mean square1
Coefficient unitsresponse units; response units/cm
Slope unitsresponse units per cm
SSE / residual mean-square unitresponse units²
Centered Sxx / Sxy35/2 / 35
Exact mean origins1/2 cm; 2 response units
Full exact rows, matrices and diagnostic quantities
Every observed row, fit and vertical response residual
RowFeature rowResponseFittedResidual
11, -2-2-31
21, -1-2-1-1
31, 0110
41, 1330
51, 245-1
61, 3871

Exact rational inputs and expressions remain in the tables. Curves, logarithmic tails and values marked ≈ are numerical drawings or evaluations. A stipulated model is an assumption; the fitted geometry does not establish its truth, causal identification or a universal risk benefit.

Rank, projection weights and estimable queries

W4: unique observed fit, two different query statuses · held: At least one new query is not identified by the original design. Its prediction is held; the diagram shows how a minimizing coefficient family changes it.

Rank, projection weights and estimable queriesComputed scientific geometry with exact text equivalents.Rank, projection weights and estimable queriesGreen solid: query 1; orange dashed: query 2.H: signed projection weights115/61/3-1/6221/31/31/333-1/61/35/6Blue + / red −; neutral 0; opacity scales |Hᵢⱼ|.≈-20≈2≈-2.40≈2.4Query prediction offsetsNull-direction coordinate tPrediction offset origin = 7; exact value in table.Each query varies a witness null direction; full table tests all.A chosen coefficient convention does not identify an off-row-space query.
The signed heatmap encodes actual hat-matrix weights. Each query line varies a witness null direction over equally minimizing coefficients; a constant identified query annihilates every null direction. Full exact weights and null bases remain in the tables.

Result held: At least one new query is not identified by the original design. Its prediction is held; the diagram shows how a minimizing coefficient family changes it.

Exact algebra and declared model quantities
QuantityValue
Rows / columns / rank3 / 3 / 2
Coefficient convention1, 2, 0 ; not a unique coefficient vector
SSE0
Centered SST8
Centered R²1
Residual df n−rank1
Residual mean square0
Full exact rows, matrices and diagnostic quantities
Every observed row, fit and vertical response residual
RowFeature rowResponseFittedResidual
11, 0, 0110
21, 1, 2330
31, 2, 4550
Exact hat matrix
Row123
15/61/3-1/6
21/31/31/3
3-1/61/35/6
Prediction identification is a row-space question
Query rowIdentified?PredictionWitness null direction
1, 3, 6true7All null directions annihilated
1, 3, 5falseNot identified0, -2, 1

Exact rational inputs and expressions remain in the tables. Curves, logarithmic tails and values marked ≈ are numerical drawings or evaluations. A stipulated model is an assumption; the fitted geometry does not establish its truth, causal identification or a universal risk benefit.

Partial fits, interactions and near aliasing

W5: short slope versus residualized full coefficient · ready

Partial fits, interactions and near aliasingComputed scientific geometry with exact text equivalents.Partial fits, interactions and near aliasing≈-1.2≈-0.60≈0.6≈1.2≈-3.6≈-1.80≈1.8≈3.6Residualize x and y against the same columns (1,z).x residual; the fitted residual line has no new interceptY axis: y residual. Short and full slopes use different fitted targets.
The plotted through-origin residual slope equals the full x coefficient only when the residualized x direction is nonzero and the full coefficient is identified. The original short slope belongs to another fitted specification.

These are conditional fits in a declared feature basis, not causal effects. A changed feature specification changes the fitted contrast.

The constructed multiple-feature examples use dimensionless features and one response unit. In the conditioning covariance calculation, a correct centered linear mean and covariance σ²I are stipulated; the response-perturbation path is a sensitivity calculation, not a stochastic simulation.

Exact rank uses rational algebra. A small nonzero predictor difference is not silently replaced by an exact alias.

Exact algebra and declared model quantities
QuantityValue
Rows / columns / rank4 / 3 / 3
Coefficient convention1, 2, 3
SSE4
Centered SST120
Centered R²29/30
Residual df n−rank1
Residual mean square4
Short x slope7/2
FWL residual-through-origin slope2
Full exact rows, matrices and diagnostic quantities
Every observed row, fit and vertical response residual
RowFeature rowResponseFittedResidual
11, -2, -1-5-61
21, 0, 134-1
31, 0, -1-3-2-1
41, 2, 1981

Exact rational inputs and expressions remain in the tables. Curves, logarithmic tails and values marked ≈ are numerical drawings or evaluations. A stipulated model is an assumption; the fitted geometry does not establish its truth, causal identification or a universal risk benefit.

Covariance models and pointwise uncertainty

W7: true covariance versus the expected usual formula · ready

Covariance models and pointwise uncertaintyComputed scientific geometry with exact text equivalents.Covariance models and pointwise uncertaintyΩ: stipulated error covariance1110022010330090≈0.9583≈1.917≈2.875TrueE[usual]Slope variance: same scaleBlue + / red −; exact Ω is stipulated.Response unit: response unitsPredictor unit: cmVariance units are squared response-per-predictor units.
Mean-zero errors preserve conditional unbiasedness under the stated mean model. A general Ω changes the true covariance to AΩAᵀ; it does not make the usual homogeneous formula correct or a tiny-sample robust estimate exact.

This covariance-only illustration stipulates a correct linear mean, E[ε|X]=0 and Var(ε|X)=Ω. Gaussianity and independence are not required; off-diagonal Ω allows dependence.

The F slice stipulates fixed nested full-rank specifications on the same observations, two independent restrictions under the null, and a positive full-model residual variance. Reference-only df are declared summaries, not inferred from a plot.

A mean-response target, an independent future observation and a selected analysis have different uncertainty requirements. Algebraic residual orthogonality does not establish the sampling assumptions.

Exact algebra and declared model quantities
QuantityValue
True coefficient covariance11/9, 4/3 ; 4/3, 5/2
E[SSE | X]7/3
E[usual s² | X]7/3
True slope variance5/2
E[usual slope variance estimate | X]7/6
Intercept / slope unitsresponse units ; response units/cm
Variance / cross-covariance unitsresponse units² ; response units²/cm ; (response units/cm)²
Full exact rows, matrices and diagnostic quantities
Exact coefficient-noise weights
CoefficientError 1Error 2Error 3
Intercept1/31/31/3
Slope-1/201/2

Exact rational inputs and expressions remain in the tables. Curves, logarithmic tails and values marked ≈ are numerical drawings or evaluations. A stipulated model is an assumption; the fitted geometry does not establish its truth, causal identification or a universal risk benefit.

Leverage and the actual delete-one fit

W9: leverage, deleted fit and Cook distance · ready

Leverage and the actual delete-one fitThe fitted response curve, observed pairs and vertical squared-response-error geometry use exact rational offsets before drawing conversion. Coincident records share positions; the complete text table retains every record.Leverage and the actual delete-one fit≈-3≈-1.50≈1.5≈3≈-6.1≈-2.8≈0.5≈3.8≈7.1Full fit blue; rank-retained deleted fit orange dashed; red selected.10123456Lower panel: exact leverage, on a common 0…1 scale.Observation row; full units and offsets remain in the table
A deleted curve is drawn only when deletion retains the original rank. Unit leverage makes the training residual zero and destroys that deletion rank; e/(1−h) is then undefined 0/0. Cook distance additionally needs full column rank and a positive residual-variance estimate. None is an automatic deletion rule.
Exact algebra and declared model quantities
QuantityValue
Rows / columns / rank6 / 2 / 2
Coefficient convention1, 2
SSE4
Centered SST74
Centered R²35/37
Residual df n−rank4
Residual mean square1
Selected leverage11/21
Deleted design rank2; original 2
Deleted prediction error21/10
Cook distance231/200
Predictor / response unitscm; response units
SSE / residual mean-square unitresponse units²
Exact plot origins1/2 cm; 2 response units
Full exact rows, matrices and diagnostic quantities
Every observed row, fit and vertical response residual
RowFeature rowResponseFittedResidual
11, -2-2-31
21, -1-2-1-1
31, 0110
41, 1330
51, 245-1
61, 3871

Exact rational inputs and expressions remain in the tables. Curves, logarithmic tails and values marked ≈ are numerical drawings or evaluations. A stipulated model is an assumption; the fitted geometry does not establish its truth, causal identification or a universal risk benefit.

Training fit, validation and a declared penalty

W11: training fit, two held-out losses and stipulated risk · ready

Training fit, validation and a declared penaltyComputed scientific geometry with exact text equivalents.Training fit, validation and a declared penalty≈-1.2≈-0.60≈0.6≈1.2≈-1.2≈-0.60≈0.6≈1.2Blue line; orange quadratic; green open dots: validation responses.Fixed predictor; response has the stipulated three-point lawTraining, observed validation loss and population risk are distinct.
Conditional future risk is Var(Ynew)+(prediction−0)² under the stated independent three-point response law. Two observed validation responses do not establish a reliable general model ranking. Reusing validation for selection holds its untouched-assessment interpretation.

Every response in this constructed validation example is independently uniform on {−1,0,1}, independent of the fixed predictor values. Future responses are independent of the training record. The untouched flag concerns assessment reuse, not the separately stipulated future-risk law.

Prediction assessment must include the whole learned pipeline within its training split; groups and time require appropriate splits.

A fixed penalty changes the estimator and its target-dependent risk. It does not supply new identifying data or justify retuned-data confidence claims.

Declared law, observed losses and conditional new-response risk
FitTraining SSEObserved validation MSEConditional future risk
Line8/31/97/9
Quadratic01/411/12

Exact rational inputs and expressions remain in the tables. Curves, logarithmic tails and values marked ≈ are numerical drawings or evaluations. A stipulated model is an assumption; the fitted geometry does not establish its truth, causal identification or a universal risk benefit.

Retain enough information to reproduce the fitted design and assess the claims: exact feature definitions, preprocessing and fitting procedure, coefficients with units, uncertainty conditions and validation evidence. Give undefined rank, variance and degrees-of-freedom boundaries explicitly. A transparent limitation helps readers decide which conclusions the analysis actually supports.

Worked examples

Fit a line and audit the residual identities

For x=(−2,−1,0,1,2,3), y=(−2,−2,1,3,4,8), fit an intercept and slope. Compute residuals, SSE, R², adjusted R² and the usual residual mean-square formula.

  1. The means are x̄=1/2,ȳ=2 and centered sums Sxx=35/2,Sxy=35. Hence b₁=2,b₀=1.
  2. Fitted values are (−3,−1,1,3,5,7), giving residuals (1,−1,0,0,−1,1). Both Σeᵢ and Σxᵢeᵢ are zero; SSE=4.
  3. SST=74 and fitted centered sum SSR=70, so R²=1−4/74=35/37. With n=6,p=2, adjusted R²=1−(4/4)/(74/5)=69/74.
  4. Residual degrees of freedom are 4 and the formula s²=SSE/(n−p) gives 1. These are algebraic quantities; interpreting s² as an unbiased common error-variance estimator and using t inference require the later stated error model.

b=(1,2), SSE=4,R²=35/37, adjusted R²=69/74 and residual mean square 1.

Check the observation-space projection directly

Take X rows (1,−1),(1,0),(1,1) and y=(0,2,1)ᵀ. Find the fit, residual and hat matrix, and verify the global minimum identity.

  1. The intercept is ȳ=1 and the slope is 1/2, giving fitted vector (1/2,1,3/2) and residual (−1/2,1,−1/2). SSE=3/2.
  2. H=(1/6)[[5,2,−1],[2,2,2],[−1,2,5]]. Direct multiplication gives Hᵀ=H,H²=H and Hy equal to the fitted vector.
  3. Xᵀe=0. For every coefficient vector c, expanding the squared error gives ‖y−Xc‖²=3/2+‖X(c−b)‖².
  4. The added term is nonnegative and vanishes only at this full-rank coefficient vector. The projection plane is a subspace of R³ observations; it does not change the ordinary scatterplot objective into perpendicular point-to-line fitting.

b=(1,1/2),e=(−1/2,1,−1/2),SSE=3/2 and the stated symmetric idempotent H.

Add a feature without inventing residual information

Rows (1,a,b) are (1,−1,−1),(1,−1,1),(1,1,−1),(1,1,1), with responses (5,1,7,7). Fit the additive model, then add feature ab.

  1. The three additive columns are orthogonal, with XᵀX=4I and Xᵀy=(20,8,−4). Hence b=(5,2,−1).
  2. Fitted responses are (4,2,8,6), with residuals (1,−1,−1,1) and SSE=4. The residual signs follow the product feature ab.
  3. Adding ab gives f=5+2a−b+ab, interpolating all four observations. The model has p=n=4 and zero residual degrees of freedom.
  4. The fitted raw a slope is 2+b, equal to one at b=−1 and three at b=1. A coefficient of a alone is not a universal a effect when the derived interaction changes with it. Zero training SSE does not provide a residual noise estimate.

Additive b=(5,2,−1),SSE=4; interaction coefficients (5,2,−1,1), with zero residual df.

Identify the estimable prediction

Take rows (1,0,0),(1,1,2),(1,2,4) with response (1,3,5). Describe all perfect-fit coefficient vectors and predictions at (1,3,6) and (1,3,5).

  1. The third feature is twice the second. Vectors (1,2−2t,t) all give intercept one and combined observed slope (2−2t)+2t=2.
  2. At query (1,3,6), prediction is 1+3(2−2t)+6t=7 for every t. Its row annihilates the design null direction.
  3. At query (1,3,5), prediction is 1+3(2−2t)+5t=7−t and varies over minimizing coefficients.
  4. A pseudoinverse or penalty can select a coefficient convention, but the separate coefficients and off-support prediction are not identified by the original data. Unique observed fits and unique coefficients are different properties.

Coefficient family (1,2−2t,t); on-row-space prediction 7, off-row-space prediction 7−t.

Compare the short and full fitted contrasts

For x=(−2,0,0,2),z=(−1,1,−1,1),y=(−5,3,−3,9), compare regression on (1,x) with regression on (1,x,z), then verify FWL.

  1. The short x slope is Sxy/Sxx=28/8=7/2 and intercept one. Solving the full normal equations gives coefficients (1,2,3).
  2. Regressing x on (1,z) and taking residuals gives (−1,−1,1,1). Regressing y on (1,z) gives residuals (−1,−3,1,3).
  3. The residual-through-origin slope is their dot product 8 divided by squared x-residual length 4, giving 2, the full x coefficient.
  4. The short/full difference is 3(Sxz/Sxx)=3(4/8)=3/2 in this sample algebra. It is not by itself proof of a causal adjustment or a population finite-sample bias claim.

Short slope 7/2, full x coefficient 2 and FWL residual slope 2.

A small response perturbation can move separate coefficients

Let a=(−1,−1,1,1),z=(−1,1,−1,1),x₁=a,x₂=a+z/10 and y=2a+3z. Fit an intercept and both predictors; compare y+z/100 and calculate the homoskedastic slope covariance at error variance one.

  1. The centered Gram matrix is [[4,4],[4,101/25]], with determinant 4/25. Since z=10(x₂−x₁), the first response gives coefficients (0,−28,30).
  2. The perturbed response is 2a+(301/100)z, giving coefficients (0,−281/10,301/10). The feature span is unchanged.
  3. Predictor correlation is 1/√(1.01). Its squared value is 100/101, so the corresponding VIF is 101.
  4. The inverse centered Gram matrix, hence the conditional two-slope covariance at σ²=1, is [[101/4,−25],[−25,25]]. Exact aliasing would occur at the zero perturbation scale of x₂−x₁; centering alone does not remove the near dependence.

Coefficients (0,−28,30), then (0,−28.1,30.1); VIF 101 with the stated wide negatively coupled slope covariance.

Unbiased slopes can have the wrong usual SE formula

At fixed x=(−1,0,1), fit an intercept and slope with independent mean-zero errors of variances (1,1,9). Find the true coefficient covariance and expectation of the usual slope-variance estimate.

  1. Slope noise weights are (−1/2,0,1/2), while intercept noise weights are (1/3,1/3,1/3). Their variances are 5/2 and 11/9, with cross covariance 4/3.
  2. Thus the true coefficient covariance is [[11/9,4/3],[4/3,5/2]]. Mean-zero errors preserve conditional unbiasedness despite unequal variances.
  3. The residual-maker diagonal is (1/6,2/3,1/6). Therefore E[SSE|X]=trace[(I−H)Ω]=1/6+2/3+9/6=7/3.
  4. There is one residual df and Sxx=2, so E[s²/Sxx]=7/6, different from 5/2. The homogeneous covariance formula is unjustified here, and a robust asymptotic option does not make an arbitrary three-row variance estimate exact.

True slope variance 5/2; expected usual estimate 7/6, with the full stated coefficient covariance.

Use the actual residual degrees of freedom

Under the correct full-rank conditional model with independent N(0,σ²) errors, unknown σ²>0, continue the six-pair line. At known query x₀=1/2, construct pointwise 95% mean-response and independent-new-response intervals.

  1. The fitted mean is 1+2(1/2)=2. With n=6,p=2, residual df is 4 and s²=4/4=1. At the predictor mean, h₀=1/6.
  2. The mean SE is √(1/6), and the new-response prediction SE is √(7/6), because a new independent error adds variance one in the estimated homogeneous formula.
  3. The t₄ 0.975 multiplier is approximately 2.7764451052. It can be checked by inverting F₄(t)=1/2+(3/4)u−u³/4, u=t/√(t²+4).
  4. The resulting intervals are 2±t₄√(1/6)≈[0.86652103,3.13347897] and 2±t₄√(7/6)≈[−0.99890347,4.99890347]. They are pointwise and treat the query and observation model as specified, rather than adding unknown predictor measurement error or simultaneous search coverage.

Mean CI approximately [0.86652103,3.13347897]; new-response PI approximately [−0.99890347,4.99890347].

Measure the fit change without an automatic deletion rule

For the six-pair line, calculate leverage, deleted prediction error and Cook distance of the last point (3,8), and compare the coefficients after deletion.

  1. At x=3, h=1/6+(3−1/2)²/(35/2)=11/21. Its full-model fitted response is 7 and residual is 1.
  2. Deleting the point leaves a full-rank five-pair line with coefficients (4/5,17/10). Its prediction at 3 is 59/10, so the deleted error is 8−59/10=21/10.
  3. The identity e/(1−h)=1/(10/21)=21/10 gives the same result. With p=2,s²=1, Cook D=(11/21)/[2(10/21)²]=231/200.
  4. Leverage, residual and influence are different quantities. This sensitivity warrants scientific inspection; a numerical threshold alone does not justify removing the record or establish that it is erroneous.

h=11/21, deleted error 21/10, Cook D=231/200, deleted coefficients (4/5,17/10).

A training summary can leave a visible model defect

For x=(−2,−1,0,1,2), y=(8,8,10,14,20), fit an intercept line, inspect its residuals and compare a quadratic fit.

  1. The line is 12+3x. Its residuals are (2,−1,−2,−1,2), with SSE=14 and SSR=90, giving R²=90/104=45/52.
  2. The residual signs and magnitudes form a symmetric U-shaped pattern against x, exposing curvature despite a substantial training R².
  3. Adding x² gives the exact fitted function 10+3x+x² with zero training SSE on this constructed table.
  4. Neither the substantial linear R² nor the exact quadratic fit proves a population error model, causal effect or valid extrapolation. The changed feature space needs a scientific rationale and prediction assessment.

Linear b=(12,3),R²=45/52 with curved residuals; the constructed quadratic fit has SSE zero.

A more flexible fit can predict worse

Train on x=(−1,0,1), y=(−1,1,−1). Compare an intercept line and a quadratic at held-out x=(−1/2,1/2) with observed y=(0,0), then compute conditional new-response risks if every response is independently uniform on {−1,0,1}.

  1. The least-squares line is the constant −1/3, with training SSE=8/3. The quadratic 1−2x² interpolates all three training responses, so its training SSE is zero.
  2. At both held-out queries, the line predicts −1/3 and the quadratic predicts 1/2. On the two observed zero responses their mean squared errors are 1/9 and 1/4 respectively.
  3. The stated response model has mean zero and variance 2/3 at every x, and assigns positive probability to the displayed training and validation records. Conditional on the fitted models, new-response risks at these queries are 2/3+(1/3)²=7/9 and 2/3+(1/2)²=11/12.
  4. This constructed example proves that a better training fit need not give better prediction. Two held-out responses alone do not give a generally reliable model ranking; evaluate the entire selection procedure with appropriate independent data and uncertainty.

Training SSE favors the quadratic; observed validation MSE and stated conditional risks favor the line: 1/9 versus 1/4, and 7/9 versus 11/12.

Compute a variance decrease and a bias cost

For the six-pair data, minimize SSE(b₀,b₁)+λb₁² with λ=35/2 and unpenalized intercept. Compare the fit and conditional slope risk with ordinary least squares when the correctly specified homogeneous error variance is one.

  1. Centering gives b₁λ=Sxy/(Sxx+λ)=35/35=1 and b₀λ=ȳ−b₁λx̄=3/2. The training SSE is 43/2, and the penalized objective is 43/2+35/2=39. At the ordinary least-squares coefficients, that objective is 4+(35/2)·4=74.
  2. For fixed design and this fixed penalty, Var(b₁λ|X)=Sxx/(Sxx+λ)²=1/70, compared with ordinary slope variance 1/Sxx=2/35. The slope variance is reduced to one quarter.
  3. The slope expectation is β₁/2. If the true slope is 2, its bias is −1 and its MSE is 1+1/70=71/70, larger than the unbiased ordinary slope MSE 2/35. If the true slope is zero, the ridge slope is unbiased and its MSE is 1/70.
  4. The comparison concerns the stated slope loss, fixed design, model and penalty. It demonstrates a bias–variance tradeoff rather than a universal risk improvement or newly identified information in aliased features. A response-tuned penalty would require its own evaluation.

Ridge coefficients (3/2,1), objective39, slope variance1/70; slope MSE71/70 at β₁=2 versus ordinary2/35.

Try it yourself

  1. An intercept fit has x̄=2,ȳ=5,Sxx=8 and Sxy=12. Find its coefficients and state the condition needed for this slope formula.

    Show the answer and reasoning

    b₁=3/2,b₀=2; Sxx must be positive.

    The normal equations give b₁=Sxy/Sxx=12/8=3/2, then b₀=ȳ−b₁x̄=5−3=2. The positive spread makes the intercept and slope uniquely identifiable.

  2. For three distinct design values x=(0,1,2), a proposed intercept-line residual vector is (1,−2,1). Check its normal-equation orthogonality, SSE, residual df and usual residual-variance estimate.

    Show the answer and reasoning

    Σe=0,Σxe=0,SSE=6,df=1,s²=6.

    The sums are 1−2+1=0 and 0−2+2=0, so the residual is orthogonal to both columns of the full-rank intercept design. Squared residuals sum to six and n−p=3−2=1. This computes the usual estimate; an unbiased population-variance interpretation still needs the appropriate error assumptions.

  3. An intercept-line design has xᵢ=4 for every row. Which coefficient combination is identified, and what are the fitted responses?

    Show the answer and reasoning

    Only b₀+4b₁ is identified; every fitted response equals ȳ.

    The predictor column is four times the intercept, so changing b₁ by t and b₀ by −4t preserves every fitted value. The least-squares projection onto constant vectors is the sample mean. Separate intercept and slope cannot be learned from these rows.

  4. All three groups are observed. A design includes an intercept and all three exhaustive group indicators. Explain the alias and one way to parameterize the same fitted group means uniquely.

    Show the answer and reasoning

    The intercept equals the sum of the indicators; omit one indicator as a reference or impose a suitable identifying constraint.

    There are three independent group-mean columns, not four independent coefficient directions. A reference-group parameterization gives its mean as the intercept and other group differences as two coefficients. Coding changes representation without supplying additional observations.

  5. A response-on-length slope is 3 response units per centimetre. Rewrite the predictor in metres and give the corresponding slope.

    Show the answer and reasoning

    300 response units per metre.

    Since x_cm=100x_m, the linear term 3x_cm becomes 300x_m. The response and fitted function remain the same after the coordinate change, and the intercept is unchanged. Numerical coefficient size cannot be compared without units.

  6. A full-rank intercept model has n=10,p=4,SSE=18 and centered SST=45. Find R² and adjusted R².

    Show the answer and reasoning

    R²=3/5; adjusted R²=2/5.

    Ordinary R² is 1−18/45=3/5. Adjusted R² is 1−[18/(10−4)]/[45/(10−1)]=1−3/5=2/5. It is a stated training-fit summary with a degrees-of-freedom adjustment, rather than a new-data performance guarantee.

  7. A square n=p design is full rank and interpolates y. Can SSE=0 be used to report a zero usual residual-variance estimate and exact coefficient certainty?

    Show the answer and reasoning

    No. SSE/(n−p) is 0/0 and undefined.

    The residual projection has rank zero. This data fit supplies no residual degrees of freedom for estimating an unknown noise variance by the ordinary formula. Interpolation alone does not establish that population errors have zero variance.

  8. Let X be uniform on [−1,1] and Y=X². Find its best affine population projection and show why the projection error does not have zero conditional mean.

    Show the answer and reasoning

    The projection is 1/3; E[U|X]=X²−1/3 is generally nonzero.

    E[X]=E[X³]=0,Var(X)=1/3 and E[Y]=1/3, so the projection slope is zero. For U=X²−1/3, both E[U] and E[XU] vanish. Because U is determined by X and is not identically zero, this orthogonality does not imply a correct affine conditional-mean model.

  9. Suppose Y=α+2X+3Z+ε has finite second moments,Var(X)>0,Cov(X,ε)=0 and Cov(X,Z)/Var(X)=−1/2. What is the population intercept-regression slope using X alone?

    Show the answer and reasoning

    1/2.

    The short slope is Cov(X,Y)/Var(X)=2+3Cov(X,Z)/Var(X)=2−3/2=1/2. The coefficient combines the specified direct linear term and association with Z. A causal interpretation needs additional identification assumptions.

  10. Two independent responses with the same unknown mean have known variances 1 and 9, and observed values 2 and 10. Compute the inverse-variance weighted estimate and its variance, then compare equal weighting.

    Show the answer and reasoning

    Precision estimate14/5 with variance9/10; equal-weight estimate6 with variance5/2.

    Normalized precision weights are 9/10 and 1/10. Their estimate is 18/10+10/10=14/5, and variance is (9/10)²·1+(1/10)²·9=9/10. Equal weights give six and variance(1+9)/4=5/2. Independence and the common mean justify this fixed-weight unbiased comparison without requiring normality.

  11. A correct full-rank homogeneous intercept regression has known error SD σ=3 and n=9. At the vector of feature sample means, find the mean-estimation SD and new-response prediction SD, assuming the new error is independent.

    Show the answer and reasoning

    Mean SD1; new-response SD√10.

    At the feature means the query leverage is h₀=1/n=1/9. Mean-estimation variance is 9/9=1; a new independent error adds variance9, giving prediction variance10. These are standard deviations under the stated covariance model, with no estimated-variance t multiplier involved.

  12. Under a full-rank conditional Gaussian homogeneous model with positive variance and 12 residual degrees of freedom, a prespecified coefficient estimate is 0.8 with usual SE0.2. For its null coefficient zero, compute the t statistic and null reference law.

    Show the answer and reasoning

    t=4 with t₁₂ null law.

    The standardized statistic is(0.8−0)/0.2=4. The exact t reference uses the centered Gaussian error model, estimated positive residual variance and the stated residual df. Response-based selection of this coefficient is not included in that prespecified-test claim.

  13. Two fixed nested full-rank models use the same 20 rows under a centered Gaussian homogeneous error model with σ²>0. The full model has p=4,SSEfull=32; the reduced model imposes q=2 independent restrictions and has SSEreduced=56. Compute F, its null df and its upper-tail p-value.

    Show the answer and reasoning

    F=6 with df(2,16); upper-tail p=(4/7)^8=65536/5764801≈0.0113683022.

    The numerator is(56−32)/2=12 and the denominator is32/(20−4)=2. Under the reduced null, F has F₂,₁₆ law. Its survival at six is[16/(16+2·6)]⁸=(4/7)⁸. The calculation relies on fixed nested specifications, rather than an unaccounted search over many models.

  14. For a predictor in a full-rank homogeneous intercept model, its auxiliary regression on the other predictors has Rⱼ²=24/25. Find VIF and its SE inflation relative to the same centered spread and error variance without that linear predictability. Must the predictor be deleted?

    Show the answer and reasoning

    VIF25 and SE factor5; deletion does not follow automatically.

    VIF=1/(1−24/25)=25 and standard error scales by its square root. This concerns a conditional variance comparison at fixed predictor spread and error variance. Removing a scientifically needed variable can change the target or adjustment, so the numerical inflation is evidence to interpret.

  15. A full-rank fit has p=2,s²=1, residual eᵢ=0.2 and leverage hᵢ=0.9. Compute Cook distance and the delete-one prediction error when the deleted design retains rank.

    Show the answer and reasoning

    Cook D=9/5 and deleted prediction error2.

    D=(0.2²·0.9)/[2·1·(1−0.9)²]=0.036/0.02=1.8. The deleted error is0.2/0.1=2. These summarize sensitivity of this specified fit; they do not automatically establish an erroneous record or justify deleting it.

  16. Fit y=bx without an intercept to x=(1,2),y=(2,1). Find b,residual sum,SSE and both centered-SST and uncentered-sum-of-squares R² conventions.

    Show the answer and reasoning

    b=4/5,Σe=3/5,SSE=9/5; centered R²=−13/5 and uncentered R²=16/25.

    The slope is Xᵀy/XᵀX=4/5 and residuals are(6/5,−3/5). They are orthogonal to x but need not sum to zero. Centered SST is1/2, giving1−(9/5)/(1/2)=−13/5; Σy²=5 gives1−(9/5)/5=16/25. The two conventions answer different training-summary questions and must be declared.

  17. For a full-column-rank design, an observation has exact leverage hᵢ=1. What are its training residual and the status of eᵢ/(1−hᵢ) as a usual unique delete-one prediction error?

    Show the answer and reasoning

    Its training residual is zero; the ratio is undefined0/0 and deletion loses rank.

    The residual-maker row has zero squared length when1−hᵢ=0, so eᵢ=0 for every response vector. The determinant identity det(XᵀX−zᵢzᵢᵀ)=det(XᵀX)(1−hᵢ) shows singularity after deletion. The omitted row then requires a coefficient direction the remaining observations do not identify.

  18. A team imputes, scales, selects outcome-associated features and tunes a penalty, then reports cross-validation. Where must those learned operations occur for an ordinary inductive assessment, and how should repeated-participant or forecasting rows be split?

    Show the answer and reasoning

    Learn the entire pipeline within each training fold; use appropriate group/time splits and an untouched final or nested assessment.

    Applying outcome screening or tuning before folds lets evaluation information influence the fitted rule. Repeated participants and time-dependent prediction need splits reflecting independent units and information availability. A final score repeatedly used for selection no longer serves as an independent final assessment, and iid validation does not establish performance under population shift.

What to carry forward

  • An intercept least-squares line minimizes vertical response errors and has slope Sxy/Sxx only with positive predictor spread; units and fitting direction matter.
  • Population linear projection supplies unconditional feature orthogonality, while a correct conditional-mean model requires the stronger centered-error condition.
  • A fitted projection is unique even under coefficient aliasing; only appropriate row-space queries and coefficient combinations are identified.
  • Multiple-regression coefficients, reference coding, interaction effects and FWL residualization refer to the specified feature space and comparison.
  • Conditional unbiasedness, Gauss–Markov variance optimality, exact Gaussian t/F inference and asymptotic covariance estimation have distinct assumptions.
  • A new-response prediction interval includes new error variation beyond mean-estimation uncertainty, with query, independence and pointwise-coverage conditions.
  • Inspect residual shape, spread, dependence, leverage, influence and design rank; a training R² or a convenient deletion threshold does not settle the scientific question.
  • Stable QR/SVD computation addresses numerical conditioning; it does not create missing identifying variation or establish a causal intervention.
  • Evaluate preprocessing, selection and tuning as one procedure using independent units and relevant prediction information.
  • A declared quadratic penalty changes bias, covariance, units and inference; reduced variance alone does not ensure lower prediction or coefficient risk.

References

Sources for the concepts and teaching approaches in this article.

  1. National Institute of Standards and Technology (NIST)2 sources
    1. e-Handbook of Statistical MethodsNIST/SEMATECHOfficial handbookLinear Least Squares RegressionHow can I tell if a model fits my data?itl.nist.gov
    2. PredictionNIST/SEMATECHOfficial handbookitl.nist.govRead source
  2. Projection matrices and least squaresGilbert Strang; MIT OpenCourseWareOfficial university lecture notes · PDFocw.mit.eduRead source
  3. Econometrics: Regression and Projection; Least-Squares InferenceBruce E. Hansen; University of Wisconsin; January10,2010 author manuscriptAuthor university textbook · PDFusers.ssc.wisc.eduRead source
  4. Iain Pardoe, Laura Simon, Derek Young; Penn State Statistics2 sources
    1. Influential PointsIain Pardoe, Laura Simon, Derek Young; Penn State StatisticsUniversity open courseonline.stat.psu.eduRead source
    2. Multicollinearity and Other Regression PitfallsIain Pardoe, Laura Simon, Derek Young; Penn State StatisticsUniversity open courseonline.stat.psu.eduRead source
  5. The Effects of InterventionsJudea Pearl, Madelyn Glymour, Nicholas P. Jewell; UCLA author-hosted previewAuthor book preview · PDFbayes.cs.ucla.eduRead source
  6. Stephen Boyd and Lieven Vandenberghe; Stanford/UCLA authors2 sources
    1. Convex Optimization: Regularized ApproximationStephen Boyd and Lieven Vandenberghe; Stanford/UCLA authorsAuthor open textbook · PDFstanford.eduRead source
    2. Introduction to Applied Linear Algebra: Vectors,Matrices,and Least SquaresStephen Boyd and Lieven Vandenberghe; Stanford/UCLA authorsAuthor open textbook · PDFstanford.eduRead source