core27 min studyLesson 254 in Mathematics

Gaussian regression and exact inference

Use independent orthogonal Gaussian components to derive exact coefficient t statistics and distinguish mean from future-response uncertainty.

On this page

What you’ll understand

  • Derive the residual variance estimator and its degrees of freedom.
  • Construct an exact t pivot under spherical Gaussian errors.
  • Explain the extra uncertainty in a future observation.

The geometry of least squares gives a fitted component and a perpendicular residual component. Gaussian errors turn that perpendicularity into independence, which makes exact finite-sample inference possible. This lesson adds a full probability model to the earlier moment assumptions. Keep that addition visible: a t reference distribution does not arise solely because a regression program printed a coefficient and a standard error. Its exactness depends on a correct mean model, full rank, and a spherical Gaussian error vector.

A distributional assumption adds more than unbiasedness

Suppose the fixed design has rank p with n>pn>p, and ε\varepsilon is multivariate normal with mean zero and covariance σ2I\sigma^2 I, where σ² is positive. The errors are then independent Gaussian coordinates with common variance. Linear transformations preserve Gaussianity, so the least-squares coefficient vector is multivariate normal with its familiar mean and covariance. The residual vector is also Gaussian, but its coordinates generally are correlated and have unequal marginal variances because fitting removes model directions.

The fitted-error component is HεH\varepsilon and the residual is (I−H)ε(I-H)\varepsilon. Their covariance is zero because the projection matrices multiply to zero. Joint Gaussianity upgrades this zero covariance to independence. Choose an orthonormal basis for the residual subspace: there are n−p independent Gaussian coordinates of variance σ². The residual sum of squares divided by σ² is therefore a chi-squared variable with n−p degrees of freedom. This argument identifies both the distribution and its dimensional origin.

β^∼Np ⁣(β,σ2(XTX)−1),∥Y−Xβ^∥2σ2∼χn−p2\widehat\beta\sim N_p\!\left(\beta,\sigma^2(X^{\mathsf T}X)^{-1}\right),\qquad \frac{\|Y-X\widehat\beta\|^2}{\sigma^2}\sim\chi^2_{n-p}
These exact distributions assume fixed full-rank X, n>p, and spherical multivariate Gaussian errors. The coefficient estimator and residual sum of squares are independent.↔ Scroll wide equations horizontally.

Studentization removes the unknown scale

Define s2s^2 as residual sum of squares divided by n−p. It is unbiased for σ² under the correct spherical mean model, even without Gaussianity. Under the Gaussian model it is also independent of the coefficient estimator. For a nonzero coefficient contrast c, standardizing its estimation error by the true standard deviation gives a standard normal variable. Replacing σ with s divides that normal variable by the square root of an independent scaled chi-squared variable, producing a t distribution.

A confidence interval follows by retaining coefficient values whose t statistic lies between the chosen quantiles. Its confidence level refers to repeated intervals under the assumed model, not a posterior probability attached to a fixed coefficient. With very few residual degrees of freedom, estimating the noise scale is uncertain and t quantiles become large. Multiplying a normal critical value by a standard error can therefore substantially understate uncertainty in a small regression, even if the coefficient estimate itself looks stable.

s2=∥Y−Xβ^∥2n−p,cTβ^−cTβscT(XTX)−1c∼tn−ps^2=\frac{\|Y-X\widehat\beta\|^2}{n-p},\qquad \frac{c^{\mathsf T}\widehat\beta-c^{\mathsf T}\beta}{s\sqrt{c^{\mathsf T}(X^{\mathsf T}X)^{-1}c}}\sim t_{n-p}
The denominator is positive almost surely under the stated Gaussian model. Exact Student inference uses the contrast variance factor and the residual degrees of freedom.↔ Scroll wide equations horizontally.

Predicting a mean is different from predicting a new response

At a fixed new row x∗Tx_*^{\mathsf T}, the fitted conditional mean has variance σ2x∗T(XTX)−1x∗\sigma^2 x_*^{\mathsf T}(X^{\mathsf T}X)^{-1}x_*. A new response also includes fresh observation noise. If that error is independent of the training errors and follows the same Gaussian variance model, prediction-error variance adds another σ². The resulting interval is wider than a confidence interval for the mean. Merely reusing the mean standard error would omit irreducible uncertainty in the new measurement.

Exactness also presumes that the design, target contrast, and model were specified independently of response-driven selection. Choosing predictors after inspecting many fits and then quoting an ordinary single-model t interval ignores selection. Residual checks can reveal contradictions with assumptions, but a quiet plot cannot prove them. For heteroskedasticity, dependence, non-Gaussian small samples, or a changing deployment population, alternative variance estimates or inferential arguments must be justified rather than retaining the exact label automatically.

Keep track of one residual degree of freedom

For an intercept-and-slope model with x=(−1,0,1)x=(-1,0,1) and y=(1,0,3)y=(1,0,3), test the slope value zero by calculating the exact-model t statistic. Assume spherical Gaussian errors and a fixed design.

  1. The fitted intercept is 4/34/3, the slope is 11, and the residual vector is (2/3,−4/3,2/3)(2/3,-4/3,2/3). Its squared length is 8/38/3. There are n−p=3−2=1n-p=3-2=1 residual degrees of freedom.

  2. Thus s2=8/3s^2=8/3. The slope diagonal of (XTX)−1(X^{\mathsf T}X)^{-1} is 1/21/2, giving estimated slope variance 4/34/3 and standard error 2/32/\sqrt3.

  3. Subtract the null slope zero and divide by that standard error: t=1/(2/3)=3/2≈0.8660t=1/(2/\sqrt3)=\sqrt3/2\approx0.8660. The reference distribution under the null is t1t_1, not a standard normal distribution.

The result

The calculation is exact only under the stated Gaussian model. The single residual degree of freedom warns that the noise scale is very uncertain; the small training set does not justify narrow normal-based intervals.

Explore the model

Interactive lab

Interactive lab · sampling

Separate an exact distribution from an approximation

Pause and Reset; set p=0.2 and n=5. Predict an asymmetric sample-mean distribution, then inspect the exact bars against the normal interval masses. Repeat from Reset with p=0.2 and n=80 to compare concentration and shape. Both settings must be entered again because controls retain elapsed time when edited. This is a Bernoulli sampling instrument, not a regression t-distribution simulator.

Separate an exact distribution from an approximationExact binomial masses for the mean of n independent Bernoulli trials, compared with normal mass between adjacent half-count boundaries; normal tails outside the finite support remain outside the bars. Playback highlights outcomes, not random samples. The Berry–Esseen bound applies to standardized CDFs, not individual bars or continuity-corrected errors. At p = 0 or 1, normal comparison and that bound are disabled. Normal-CDF evaluation uses a numerical approximation with absolute error below 7.5×10⁻⁸ (at most 1.5×10⁻⁷ per interval, before rounding). Current readings: Mean sample proportion: 0.5; Sample-mean variance: 0.0125; Uniform CDF error bound: ≤ 0.1062. All parameters are adjustable with the labeled controls below.Exact distribution of the mean of 20 independent Bernoulli variables with success probability 0.5; playback highlights outcome 0.00.250.50.75100.0580.1150.1730.23Sample mean · k / nProbability massNormal bin masses are an approximationk = 0 · exact probability = 9.54e-7
Exact binomial massNormal interval massHighlighted outcome / mean
Mean sample proportion
0.5
Sample-mean variance
0.0125
Uniform CDF error bound
≤ 0.1062
t = 0 s

Exact binomial masses for the mean of n independent Bernoulli trials, compared with normal mass between adjacent half-count boundaries; normal tails outside the finite support remain outside the bars. Playback highlights outcomes, not random samples. The Berry–Esseen bound applies to standardized CDFs, not individual bars or continuity-corrected errors. At p = 0 or 1, normal comparison and that bound are disabled. Normal-CDF evaluation uses a numerical approximation with absolute error below 7.5×10⁻⁸ (at most 1.5×10⁻⁷ per interval, before rounding). Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forA reference distribution comes from a probability model; a convenient approximation is a separate claim.

Check your understanding

Why is a prediction interval for a fresh response wider than a confidence interval for its conditional mean?

Try it yourself

In an intercept-only Gaussian model, observe (1,3,3,5)(1,3,3,5). Find the fitted mean, residual degrees of freedom, s², and the standard error of the fitted mean. State the reference distribution for testing μ=3.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

The intercept-only design has one column. First square the deviations from the sample mean; do not divide their sum by n when estimating σ².

Compare with the solution

The mean is 33 and residuals are (−2,0,0,2)(-2,0,0,2), giving SSE=8. There are 4−1=34-1=3 residual degrees of freedom, so s2=8/3s^2=8/3. The fitted mean's estimated variance is s2/4=2/3s^2/4=2/3 and its standard error is 2/3\sqrt{2/3}. The null statistic is zero, with exact reference distribution t3t_3 under the assumed independent equal-variance Gaussian model.

Take it with you

  • Orthogonal Gaussian error components are independent.
  • Residual rank determines the chi-squared and t degrees of freedom.
  • Future-response intervals include fresh noise in addition to mean-estimation uncertainty.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.