Week 8 — Normal linear models, projections, and quadratic forms
Where this week starts
Weeks 5 and 6 handed you three statistics that share a limiting distribution, and Week 7 asked whether that limit had arrived at the sample size in front of you. Most of the first half’s guarantees are approximate. This week is the exception the course has been saving: for the normal linear model with independent errors of common variance, the distribution of everything the procedure reports is known exactly, at every sample size, with no appeal to a limit. Twelve observations are enough, and so are five.
The reason is geometric, and it fits in a sentence: least squares is an orthogonal projection, and the normal law with covariance is the one law that does not notice a rotation. The rest follows. Fitted values are a projection onto a subspace; sums of squares are squared lengths; degrees of freedom are ranks; independence of two sums of squares is orthogonality of two subspaces. The and statistics are ratios of those pieces from which the unknown cancels, which is what makes them pivotal.
What should feel different by the end is how you read an analysis-of-variance table: not as a bookkeeping convention, but as one vector in resolved into orthogonal components, with the rank of each in the degrees-of-freedom column and its squared length beside it. Model building and diagnostics belong to the regression course; this week stays on the theory that licenses them, and closes by asking what happens when the covariance assumption fails.
Why this matters beyond the theorem
Here is the stake. A field trial with three treatments and four plots each gives a ratio of mean squares of 9.00 on 2 and 9 degrees of freedom, tail probability 0.0071, and a report goes out claiming a treatment effect. Now suppose the four plots within a treatment shared an irrigation channel, so observations within a group are correlated with . Every number is computed identically, both sums of squares are still independent chi-squares, and the ratio is still called . Its actual null distribution, derived below, is 2.71 times an , so the test advertising level 0.05 has actual size 0.26. The output never complains, and more plots per treatment make it worse.
The second stake is quieter. Write the one-way model as and you have written four parameters for a three-dimensional subspace. Count parameters and the between-groups degrees of freedom come out as 3; take the rank of the projection and they come out as 2. Every ratio downstream depends on which you used, and only one is a property of the model rather than of the notation.
What you will be able to do
- Derive the hat matrix for a stated design and verify that it is symmetric, idempotent, and of rank equal to its trace.
- State and prove the distribution of a quadratic form in a normal vector, naming which conclusion fails when idempotence, the covariance , or the centring is dropped.
- Decompose a one-way layout into orthogonal projections, give each component’s degrees of freedom as a rank, and check Cochran’s rank condition arithmetically.
- Construct and from the geometry instead of quoting them, and show whenever the numerator has one degree of freedom.
- Diagnose which assumption a linear-model conclusion rests on, and compute the true size of an test when the error covariance is not .
- Verify a claimed quadratic-form distribution by simulation.
Terms and notation worth fixing
| Symbol | What it means on this page |
|---|---|
| The design matrix, fixed and known, of full column rank unless stated otherwise | |
| The model subspace: the column space of , the mean vectors the model permits | |
| The hat matrix , orthogonal projection onto , so | |
| , | The null subspace and its projection; here is always a subspace of |
| Dimension of the range of ; for a projection it equals , and it is what “degrees of freedom” names | |
| Chi-square on degrees of freedom with noncentrality , mean ; the central case is , and note that this is twice the noncentrality parameter Hogg, McKean, and Craig write for the same law | |
| The law of with the two parts independent | |
| The common error variance, estimated by |
Least squares as an orthogonal projection
Fix the model for the week. Let with an -vector, a known matrix, unknown, and . Three assumptions are bundled there, and different conclusions need different subsets of them: the mean vector lies in ; the errors are uncorrelated with common variance; the errors are normal. Least squares itself needs none of the three, since minimizing is linear algebra. Unbiasedness needs the first, the usual variance formula the first two, and the exact chi-square, , and laws all three.
The minimization has a one-line geometric reading. Among vectors in we want the one closest to , and the closest point of a subspace is the orthogonal projection onto it. Equivalently the residual must be orthogonal to every column of , which is the normal equations . With full column rank, is invertible, , and with .
Keep that picture in view: the plane is , the right angle at the foot of the residual is the normal equations, and the Pythagorean identity in the panel is the sum-of-squares decomposition, written down before any probability has entered the argument.
The hat matrix and what idempotence buys
Two properties of do the work. It is symmetric, because is symmetric and transposing the product returns it unchanged. It is idempotent:
which is the algebraic form of an obvious geometric fact — a vector already in is its own projection. The eigenvalues follow at once. If with , then , so is 0 or 1. A symmetric matrix is diagonalizable by an orthogonal matrix, so the number of unit eigenvalues is the rank, and since the trace is the sum of the eigenvalues, . Here that number is , because by cyclic invariance of the trace.
One consequence is the reason degrees of freedom are ranks. Replace by for an invertible matrix — what happens when you recode a factor or centre a covariate. Then
The projection, the fitted values, the residuals, the sums of squares, and their ranks are properties of alone. The coefficient vector is not; it is a set of coordinates. When is rank deficient — the one-way model with an intercept and one indicator per group — is not even unique, while and every sum of squares still are, and is smaller than the number of columns. That rank belongs in the table.
Finally is symmetric and idempotent of rank , projecting onto . The residual is , and since we get for every . The diagonal entries are the leverages, and they sum to .
Sums of squares are squared lengths
Because with orthogonal pieces, Pythagoras gives , and every finer decomposition is the same trick inside a nested pair of subspaces.
Suppose the hypothesis says the mean lies in a smaller subspace of dimension . Because sits inside , projecting onto and then onto changes nothing: , and transposing gives . Hence
so is symmetric and idempotent of rank : it projects onto the part of orthogonal to . The identity the week runs on is therefore
Apply each piece to and take squared lengths: three orthogonal components whose squared lengths add, with ranks adding to . When is the span of the vector of ones, dropping the first term is what correcting for the mean does, and the two that remain are the between and within lines of an analysis-of-variance table.
Quadratic forms in a normal vector
Every sum of squares above is for a symmetric idempotent , since . The distribution theory therefore reduces to two questions: what is the law of such a form, and when are two of them independent?
The chi-square theorem and its conditions
Theorem. Let and let be symmetric and idempotent with . Then .
Working. Symmetry gives with orthogonal and diagonal. Idempotence forces each diagonal entry to satisfy , so exactly of them equal one. Put ; then is normal with mean zero and covariance , which is where earns its place, since the standard normal is the law unchanged by an orthogonal change of basis. Finally , a sum of independent squared standard normals, which is by definition.
Both conditions are load-bearing. Drop idempotence and the eigenvalues are arbitrary, so the form is , a weighted sum of one-degree-of-freedom chi-squares, which is not a chi-square unless the nonzero weights are equal. Take with : the form has mean 5 and variance , whereas any with mean 5 has variance 10. Symmetry costs nothing to assume, since .
Two extensions reach the models we use. If then is standard, so : the theorem is about the centred form. Uncentred, the law is noncentral, with , central exactly when . Check that condition every time. The within-groups sum of squares is central whatever the treatment means are, because for every ; the between-groups sum of squares is central only under the null, and its noncentrality is where the power function comes from.
The figure checks the theorem: 20,000 simulated balanced layouts of three groups of four standard normal observations, with the within-groups sum of squares computed on each. The theorem predicts , mean 9 and variance 18. That run gave mean 8.92, variance 17.7, and 4.78 percent of replicates beyond 16.9, the 0.95 quantile of , against a predicted 5 percent; your own run will differ in the second decimal place.
Independence and Cochran’s decomposition
Proposition. Let and let and be symmetric idempotent with . Then and are independent, and so are and .
Working. The stacked vector is a linear map of , hence jointly normal, and . For jointly normal vectors, zero covariance is independence — a property of the normal family, not a general fact, and exactly the step non-normal errors destroy. Since is a function of , the forms are independent too.
The condition says the ranges of and are orthogonal subspaces, and our nested decomposition satisfies it: . The within and between sums of squares are independent because the subspaces are orthogonal, not because the formulas look separate.
The general statement is Cochran’s theorem. Let and suppose with each symmetric of rank . If , then every is idempotent, the forms are mutually independent, and . The rank condition is the whole hypothesis: symmetric matrices summing to the identity may overlap, and only when the ranks add to is no room left for it. So the first thing to do with a decomposition is add the ranks.
Read the figure as three views of one identity: the sample space split into the model subspace and its complement; the model subspace reopened into the constant direction and the two the treatments add; and what the table prints, with the constant direction removed by centring and rank 2 and rank 9 adding to the corrected total’s rank 11.
Building t and F rather than quoting them
Assemble. Under the null that , the numerator is with , because annihilates any mean in . The denominator is whether or not the null holds, and the two are independent. Therefore
Notice what became of : it divides both sums of squares and cancels, so the null distribution carries no unknown parameter — Week 4’s definition of a pivot, reached by construction. Under an alternative with mean the numerator is noncentral with , so power depends on the mean only through its distance from in units of .
The statistic uses the same ingredients for a single linear combination. Fix and test . Since is linear in , it is normal with mean and variance ; and is a function of while is a function of , so the proposition makes them independent. Standardizing both by the same ,
which is the definition of the law. Squaring gives . More is true than equality in distribution: for a one-dimensional hypothesis the numerator sum of squares equals , so and are the same number on every data set, as the second worked example checks.
Worked example — the one-way layout as two orthogonal projections
The model and the question. A field trial applies three fertilizer treatments to four plots each, with illustrative yields 9, 12, 14, 17 for treatment A; 15, 16, 18, 19 for treatment B; and 18, 20, 22, 24 for treatment C. Model them as with independent , and , so . Test at level 0.05.
Step 1, name the two subspaces. is spanned by the three group indicator vectors, which are linearly independent, so . is spanned by the vector of ones, so , and because a constant vector is a particular pattern of group means. That nesting licenses everything below.
Step 2, project. The group means are 13, 17, and 21, so repeats each group’s mean four times. The grand mean is , so is 17 in every coordinate.
Step 3, take squared lengths. The between-groups component is
and the within-groups component is the sum of squared deviations inside each group: A gives , B gives , and C gives , totalling 64. The corrected total is , and is Pythagoras in numbers.
Step 4, take ranks. and ; with the rank-1 constant direction the ranks are , which is Cochran’s condition.
Step 5, get the distributions. Under the mean lies in and is annihilated by , so is a draw from . The within component is central regardless, since for every , so is a draw from . They are independent because and the errors are normal with covariance .
Step 6, form the ratio. The mean squares are and , so on , and on 9 degrees of freedom. For two numerator degrees of freedom the tail has the closed form , so the tail probability is , and the same equation gives the 0.05 cutoff 4.26.
Step 7, what it licenses and what it does not. The table figure is the whole computation, each entry a projection. The result licenses a conditional statement: if the three means were equal and the model held, a discrepancy this large would arise about seven times in a thousand. It does not say which pair differs, since the numerator pools two dimensions into one number and discards the direction — that is Week 9’s question. And it is not evidence that the model is correct: a small tail probability is equally consistent with unequal means and with a violated covariance assumption.
y <- c(9, 12, 14, 17, 15, 16, 18, 19, 18, 20, 22, 24)
g <- factor(rep(c("A", "B", "C"), each = 4))
X <- model.matrix(~ g)
P <- X %*% solve(t(X) %*% X) %*% t(X)
c(rank_of_P = sum(diag(P)),
between = sum((P %*% y - mean(y))^2),
within = sum((y - P %*% y)^2))
anova(lm(y ~ g))The same reasoning, transferred
Change the design and keep the structure. A laboratory compares two preparation methods with unequal numbers of specimens: method one gives 4, 6, 8 and method two gives 9, 10, 12, 13, 16, so with group sizes 3 and 5. Now , , and the ranks are .
The group means are 6 and 12 and the grand mean is , so the between component is , equivalently . The within component is on 6 degrees of freedom, so the pooled variance estimate is and on 1 and 6 degrees of freedom. The two-sample on the same data is , and . The tail probability from is 0.017, and the cutoffs correspond because .
What stayed the same: three orthogonal projections, degrees of freedom read as ranks, squared lengths adding by Pythagoras, an built from independent chi-squares over their ranks. What changed: the group sizes are unequal, so the between projection weights each mean by its own , and the numerator rank has fallen to 1. Rank 1 means the alternative departs from the null in a single direction, which is exactly when is the square of a and the sign of the difference survives; with three groups the rank was 2 and the direction was genuinely discarded.
Second worked example — a regression slope, its t, and t squared as F
The model and the question. A calibration experiment reads an instrument at five coded concentrations , one reading each, giving illustrative readings . Model with independent and test . The columns of ones and of are independent because is not constant, so , , and the ranks are .
Step 1, fit by projecting. With and , the centred sums are and , so and . The fitted values are 5, 8, 11, 14, 17 and the residuals are 2, , 0, , 2.
Step 2, verify orthogonality rather than assume it. Against the column of ones, ; against , . Both hold exactly, as they must for any least squares fit; a failure here would be an arithmetic error, not a finding.
Step 3, squared lengths and ranks. The residual sum of squares is on degrees of freedom, so , and the regression sum of squares is on 1 degree of freedom. The corrected total is .
Step 4, the hat matrix in numbers. For simple regression , giving leverages 0.6, 0.3, 0.2, 0.3, 0.6. They sum to 2.0, which is , which is , which is ; and is the residual degrees of freedom. Nothing was counted from the model equation; it was read off one matrix.
Step 5, the statistic. The variance of is , so the estimated standard error is and on 3 degrees of freedom. The two-sided tail probability from is 0.026, so the test rejects at 0.05 and not at 0.01. The 0.975 quantile of is 3.182, a long way from 1.96, and that gap is what estimating from three degrees of freedom costs.
Step 6, the same conclusion as an . The ratio is , and — the same number, not merely the same law. The general identity predicts it: with , , so the numerator sum of squares is , which is what step 3 computed geometrically. The cutoffs match too: the square of the 0.975 quantile of is the 0.95 quantile of , both being 10.13 to two decimals.
Step 7, invert the test. Week 4’s duality applies unchanged: the values of the test does not reject form , that is . It excludes zero, agreeing with the test on the same data, as an inverted family of tests must.
Step 8, what it licenses and what it does not. Five observations and three residual degrees of freedom give an interval more than four units wide for a slope estimated at 3, and that width is the honest report. The law is exact conditional on the values being fixed and known, on errors independent with common variance, and on normality — not on an approximation, but not on nothing either. Nor is exactness licence about the estimand: if the true relationship is curved, this is an exact test about the slope of the best linear approximation inside the stated subspace, which is a different quantity from the one you may have meant.
x <- 0:4
y <- c(7, 6, 11, 12, 19)
X <- cbind(1, x)
hat <- X %*% solve(t(X) %*% X) %*% t(X)
round(diag(hat), 3)
sum(diag(hat))
summary(lm(y ~ x))$coefficients
anova(lm(y ~ x))The misreading to avoid
The misreading sounds like competence: “an statistic is a ratio of two independent chi-squares, so once the sums of squares are split correctly the test is fine. Normality is the only real assumption, and with enough data it stops mattering anyway.” Take the clauses in turn.
The first treats independence and the chi-square law as consequences of the split. They are not. The split is algebra: decompose a column of invented integers and the ranks still add. What turns algebra into distribution theory is the pair of probabilistic assumptions, normality and covariance . Orthogonality is necessary and not sufficient.
The second clause is where the damage happens. Keep the balanced layout of groups of with normal errors, but let observations within a group be equicorrelated, so with block diagonal of ones. For the balanced layout , and a short computation gives and . Both forms are still exactly chi-square and still exactly independent — but scaled by different multiples of , so
With and the factor is , so the nominal 0.05 test rejects when an variable exceeds , and its actual size is . Every distribution there is exactly normal, so this is not a normality failure. What failed is that the two values cancelling in the ratio were not the same number.
The third clause invites false comfort. There is an asymptotic defence of the test against non-normal errors: with the design fixed and the number of observations growing, and errors independent with common finite variance, a central limit argument restores the level approximately. That defence is asymptotic, it is the kind of promise Week 7 taught you to check by simulation, and it says nothing at . It also does not touch the correlated-error failure, where more observations per group make the inflation factor larger. Growing the sample fixes the wrong problem.
A smaller misreading travels with these. Degrees of freedom are not the number of parameters you wrote down, nor minus the number of quantities you estimated. They are ranks of projections, which is why they survive reparameterization and why a rank-deficient design has fewer of them than it has columns. Where the two recipes agree, they agree because the parameterization happened to be of full rank, and that habit fails silently on the first design that is not.
Practice on your own
These are for self-checking; work them before the calibration lab rather than after.
- Projections belong to subspaces. Prove is symmetric and idempotent with , show is unchanged when becomes for invertible , and say what does depend on the choice of columns.
- A form that is not chi-square. With and , confirm no chi-square law matches both moments of , then say when is chi-square.
- Invariance of the table. Predict, before computing, which of the three sums of squares in the first worked example change when you add 5 to every observation in treatment C, and which change when you double all twelve observations. Verify both, and explain each geometrically.
- A size study for correlated errors. Simulate the balanced layout with three groups of four at , , and by adding a shared group-level draw to independent within-group noise. Estimate the actual size of the nominal 0.05 test at each with its Monte Carlo standard error, and compare the case with the 0.26 derived above.
- The general one-dimensional identity. For a single linear hypothesis , identify the rank-one projection and prove , which is why on every data set, not merely in distribution.
set.seed(2027)
one_trial <- function(rho, n = 4, a = 3) {
shared <- rnorm(a, sd = sqrt(rho))
y <- as.vector(sapply(shared, function(s) s + rnorm(n, sd = sqrt(1 - rho))))
g <- factor(rep(seq_len(a), each = n))
anova(lm(y ~ g))[1, "Pr(>F)"]
}
sapply(c(0, 0.1, 0.3),
function(r) mean(replicate(5000, one_trial(r)) < 0.05))Where to read more
- The projection treatment of the normal linear model, at the level this week assumes, is in the lecture materials for MIT OpenCourseWare 18.655 Mathematical Statistics.
- A slower, example-first route through analysis of variance and the test is in Penn State STAT 415.
- The optional Hogg, McKean, and Craig alignment for this week is Chapter 9.1 through 9.3, together with Chapter 9.8 and 9.9. That book is optional and is never required to be purchased.
- The computations use only base R and the
statspackage: see The R Project for Statistical Computing and Quarto. - Course pages: the syllabus, the schedule, the resources overview, and the notes overview. The pivot argument in Week 4 is worth rereading beside step 7 above.
Where this goes next
This week’s test refuses to say which treatment differs from which, and the refusal is structural: the numerator pooled a two-dimensional subspace into one squared length and discarded the direction. Recovering the direction means asking several questions of one data set, and the moment you do, the level of each comparison stops being the error rate of the collection. Week 9 takes up that problem, with the family-wise error rate, the false discovery rate, and comparisons chosen after seeing the data.
The geometry carries forward. A contrast among treatment means is a one-dimensional projection inside the rank-2 between-groups subspace, and mutually orthogonal contrasts split that subspace into rank-1 pieces whose sums of squares add to 128 and whose statistics are independent — the structure next week’s corrections act on. If a step here went past you, repair the chi-square theorem first and the independence proposition second. The notes overview lists the earlier units.