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 σ2I\sigma^2 I 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 tt and FF statistics are ratios of those pieces from which the unknown σ2\sigma^2 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 n\mathbb{R}^n 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 ρ=0.3\rho = 0.3. Every number is computed identically, both sums of squares are still independent chi-squares, and the ratio is still called FF. Its actual null distribution, derived below, is 2.71 times an F2,9F_{2,9}, 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 μ+αi\mu + \alpha_i 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 FF 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 σ2I\sigma^2 I, 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 tt and FF from the geometry instead of quoting them, and show t2=Ft^2 = F whenever the numerator has one degree of freedom.
  • Diagnose which assumption a linear-model conclusion rests on, and compute the true size of an FF test when the error covariance is not σ2I\sigma^2 I.
  • Verify a claimed quadratic-form distribution by simulation.

Terms and notation worth fixing

Symbol What it means on this page
XX The n×pn \times p design matrix, fixed and known, of full column rank pp unless stated otherwise
V=𝒞(X)V = \mathcal{C}(X) The model subspace: the column space of XX, the mean vectors the model permits
PP The hat matrix X(XX)1XX(X^{\top}X)^{-1}X^{\top}, orthogonal projection onto VV, so ŷ=Py\hat{y} = Py
V0V_0, P0P_0 The null subspace and its projection; here V0V_0 is always a subspace of VV
rank(A)\operatorname{rank}(A) Dimension of the range of AA; for a projection it equals tr(A)\operatorname{tr}(A), and it is what “degrees of freedom” names
χr2(λ)\chi^2_r(\lambda) Chi-square on rr degrees of freedom with noncentrality λ\lambda, mean r+λr + \lambda; the central case is χr2\chi^2_r, and note that this λ\lambda is twice the noncentrality parameter Hogg, McKean, and Craig write for the same law
Fq,mF_{q,m} The law of (χq2/q)/(χm2/m)(\chi^2_q / q)/(\chi^2_m / m) with the two parts independent
σ2\sigma^2 The common error variance, estimated by σ̂2=(IP)y2/(np)\hat\sigma^2 = \lVert (I - P)y \rVert^2/(n - p)

Least squares as an orthogonal projection

Fix the model for the week. Let Y=Xβ+εY = X\beta + \varepsilon with YY an nn-vector, XX a known n×pn \times p matrix, βp\beta \in \mathbb{R}^p unknown, and εNn(0,σ2In)\varepsilon \sim N_n(0, \sigma^2 I_n). Three assumptions are bundled there, and different conclusions need different subsets of them: the mean vector lies in V=𝒞(X)V = \mathcal{C}(X); the errors are uncorrelated with common variance; the errors are normal. Least squares itself needs none of the three, since minimizing yXb2\lVert y - Xb \rVert^2 is linear algebra. Unbiasedness needs the first, the usual variance formula the first two, and the exact chi-square, tt, and FF laws all three.

The minimization has a one-line geometric reading. Among vectors in VV we want the one closest to yy, and the closest point of a subspace is the orthogonal projection onto it. Equivalently the residual must be orthogonal to every column of XX, which is the normal equations X(yXβ̂)=0X^{\top}(y - X\hat\beta) = 0. With full column rank, XXX^{\top}X is invertible, β̂=(XX)1Xy\hat\beta = (X^{\top}X)^{-1}X^{\top}y, and ŷ=Py\hat{y} = Py with P=X(XX)1XP = X(X^{\top}X)^{-1}X^{\top}.

A slanted plane labelled as the column space of X, with a data vector rising out of it, the fitted vector lying flat inside the plane, and the residual joining their tips vertically at a marked right angle.

A data vector, its projection onto the model subspace, and the residual meeting it at a right angle.

Keep that picture in view: the plane is VV, 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 PP do the work. It is symmetric, because (XX)1(X^{\top}X)^{-1} is symmetric and transposing the product returns it unchanged. It is idempotent:

P2=X(XX)1XX(XX)1X=X(XX)1X=P, P^2 = X(X^{\top}X)^{-1}X^{\top}X(X^{\top}X)^{-1}X^{\top} = X(X^{\top}X)^{-1}X^{\top} = P ,

which is the algebraic form of an obvious geometric fact — a vector already in VV is its own projection. The eigenvalues follow at once. If Pv=λvPv = \lambda v with v0v \ne 0, then λv=P2v=λ2v\lambda v = P^2 v = \lambda^2 v, so λ\lambda 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, rank(P)=tr(P)\operatorname{rank}(P) = \operatorname{tr}(P). Here that number is pp, because tr{X(XX)1X}=tr{(XX)1XX}=p\operatorname{tr}\{X(X^{\top}X)^{-1}X^{\top}\} = \operatorname{tr}\{(X^{\top}X)^{-1}X^{\top}X\} = p by cyclic invariance of the trace.

One consequence is the reason degrees of freedom are ranks. Replace XX by X̃=XA\tilde{X} = XA for an invertible p×pp \times p matrix AA — what happens when you recode a factor or centre a covariate. Then

P̃=XA(AXXA)1AX=XAA1(XX)1(A)1AX=P. \tilde{P} = XA(A^{\top}X^{\top}XA)^{-1}A^{\top}X^{\top} = XAA^{-1}(X^{\top}X)^{-1}(A^{\top})^{-1}A^{\top}X^{\top} = P .

The projection, the fitted values, the residuals, the sums of squares, and their ranks are properties of VV alone. The coefficient vector β̂\hat\beta is not; it is a set of coordinates. When XX is rank deficient — the one-way model with an intercept and one indicator per group — β̂\hat\beta is not even unique, while PP and every sum of squares still are, and rank(P)=rank(X)\operatorname{rank}(P) = \operatorname{rank}(X) is smaller than the number of columns. That rank belongs in the table.

Finally IPI - P is symmetric and idempotent of rank npn - p, projecting onto VV^{\perp}. The residual is e=(IP)ye = (I - P)y, and since PX=XPX = X we get Ee=0E e = 0 for every β\beta. The diagonal entries hii=Piih_{ii} = P_{ii} are the leverages, and they sum to tr(P)=p\operatorname{tr}(P) = p.

Sums of squares are squared lengths

Because y=Py+(IP)yy = Py + (I - P)y with orthogonal pieces, Pythagoras gives y2=Py2+(IP)y2\lVert y \rVert^2 = \lVert Py \rVert^2 + \lVert (I - P)y \rVert^2, 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 V0VV_0 \subseteq V of dimension p0<pp_0 < p. Because V0V_0 sits inside VV, projecting onto V0V_0 and then onto VV changes nothing: PP0=P0P P_0 = P_0, and transposing gives P0P=P0P_0 P = P_0. Hence

(PP0)2=P2PP0P0P+P02=PP0P0+P0=PP0, (P - P_0)^2 = P^2 - PP_0 - P_0P + P_0^2 = P - P_0 - P_0 + P_0 = P - P_0 ,

so PP0P - P_0 is symmetric and idempotent of rank pp0p - p_0: it projects onto the part of VV orthogonal to V0V_0. The identity the week runs on is therefore

In=P0+(PP0)+(IP),p0+(pp0)+(np)=n. I_n = P_0 + (P - P_0) + (I - P) , \qquad p_0 + (p - p_0) + (n - p) = n .

Apply each piece to yy and take squared lengths: three orthogonal components whose squared lengths add, with ranks adding to nn. When V0V_0 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 YAYY^{\top}AY for a symmetric idempotent AA, since AY2=YAAY=YAY\lVert AY \rVert^2 = Y^{\top}A^{\top}AY = Y^{\top}AY. 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 ZNn(0,In)Z \sim N_n(0, I_n) and let AA be symmetric and idempotent with rank(A)=r\operatorname{rank}(A) = r. Then ZAZχr2Z^{\top}AZ \sim \chi^2_r.

Working. Symmetry gives A=QΛQA = Q \Lambda Q^{\top} with QQ orthogonal and Λ\Lambda diagonal. Idempotence forces each diagonal entry to satisfy λ2=λ\lambda^2 = \lambda, so exactly rr of them equal one. Put W=QZW = Q^{\top}Z; then WW is normal with mean zero and covariance QQ=IQ^{\top}Q = I, which is where Cov(Z)=I\operatorname{Cov}(Z) = I earns its place, since the standard normal is the law unchanged by an orthogonal change of basis. Finally ZAZ=WΛW=i=1rWi2Z^{\top}AZ = W^{\top}\Lambda W = \sum_{i=1}^{r} W_i^2, a sum of rr independent squared standard normals, which is χr2\chi^2_r by definition.

Both conditions are load-bearing. Drop idempotence and the eigenvalues are arbitrary, so the form is iλiWi2\sum_i \lambda_i W_i^2, a weighted sum of one-degree-of-freedom chi-squares, which is not a chi-square unless the nonzero weights are equal. Take A=diag(1,4)A = \operatorname{diag}(1, 4) with n=2n = 2: the form Z12+4Z22Z_1^2 + 4Z_2^2 has mean 5 and variance 2(1)2+2(4)2=342(1)^2 + 2(4)^2 = 34, whereas any χr2\chi^2_r with mean 5 has variance 10. Symmetry costs nothing to assume, since ZAZ=Z{(A+A)/2}ZZ^{\top}AZ = Z^{\top}\{(A + A^{\top})/2\}Z.

Two extensions reach the models we use. If YNn(μ,σ2In)Y \sim N_n(\mu, \sigma^2 I_n) then Z=(Yμ)/σZ = (Y - \mu)/\sigma is standard, so (Yμ)A(Yμ)/σ2χr2(Y - \mu)^{\top}A(Y - \mu)/\sigma^2 \sim \chi^2_r: the theorem is about the centred form. Uncentred, the law is noncentral, YAY/σ2χr2(λ)Y^{\top}AY/\sigma^2 \sim \chi^2_r(\lambda) with λ=μAμ/σ2\lambda = \mu^{\top}A\mu/\sigma^2, central exactly when Aμ=0A\mu = 0. Check that condition every time. The within-groups sum of squares is central whatever the treatment means are, because (IP)Xβ=0(I - P)X\beta = 0 for every β\beta; the between-groups sum of squares is central only under the null, and its noncentrality λ=(PP0)μ2/σ2\lambda = \lVert (P - P_0)\mu \rVert^2/\sigma^2 is where the power function comes from.

A histogram of simulated within-group sums of squares closely tracking the chi-square density on nine degrees of freedom, with the upper tail beyond 16.9 shaded and the simulated mean 8.92 reported against the theoretical 9.

Twenty thousand simulated within-group sums of squares against the chi-square density on nine degrees of freedom.

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 χ92\chi^2_9, 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 χ92\chi^2_9, against a predicted 5 percent; your own run will differ in the second decimal place.

Independence and Cochran’s decomposition

Proposition. Let YNn(μ,σ2In)Y \sim N_n(\mu, \sigma^2 I_n) and let AA and BB be symmetric idempotent with AB=0AB = 0. Then AYAY and BYBY are independent, and so are YAYY^{\top}AY and YBYY^{\top}BY.

Working. The stacked vector (AY,BY)(AY, BY) is a linear map of YY, hence jointly normal, and Cov(AY,BY)=A(σ2I)B=σ2AB=0\operatorname{Cov}(AY, BY) = A(\sigma^2 I)B^{\top} = \sigma^2 AB = 0. 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 YAY=AY2Y^{\top}AY = \lVert AY \rVert^2 is a function of AYAY, the forms are independent too.

The condition AB=0AB = 0 says the ranges of AA and BB are orthogonal subspaces, and our nested decomposition satisfies it: (IP)(PP0)=PP0P2+PP0=0(I - P)(P - P_0) = P - P_0 - P^2 + PP_0 = 0. 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 ZNn(0,In)Z \sim N_n(0, I_n) and suppose In=A1++AkI_n = A_1 + \dots + A_k with each AjA_j symmetric of rank rjr_j. If r1++rk=nr_1 + \dots + r_k = n, then every AjA_j is idempotent, the forms ZAjZZ^{\top}A_jZ are mutually independent, and ZAjZχrj2Z^{\top}A_jZ \sim \chi^2_{r_j}. The rank condition is the whole hypothesis: symmetric matrices summing to the identity may overlap, and only when the ranks add to nn is no room left for it. So the first thing to do with a decomposition is add the ranks.

Three stacked bars: a twelve-dimensional sample space split into a rank-three model subspace and a rank-nine residual space, the model subspace split into rank one and rank two, and a corrected total of rank eleven.

The one-way layout as a chain of orthogonal subspaces whose ranks add to twelve.

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 EYV0E Y \in V_0, the numerator (PP0)Y2/σ2\lVert (P - P_0)Y \rVert^2/\sigma^2 is χq2\chi^2_q with q=pp0q = p - p_0, because PP0P - P_0 annihilates any mean in V0V_0. The denominator (IP)Y2/σ2\lVert (I - P)Y \rVert^2/\sigma^2 is χnp2\chi^2_{n-p} whether or not the null holds, and the two are independent. Therefore

F=(PP0)Y2/q(IP)Y2/(np)Fq,np. F = \frac{\lVert (P - P_0)Y \rVert^2 / q}{\lVert (I - P)Y \rVert^2 / (n - p)} \sim F_{q,\, n-p} .

Notice what became of σ2\sigma^2: 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 μV\mu \in V the numerator is noncentral with λ=(PP0)μ2/σ2\lambda = \lVert (P - P_0)\mu \rVert^2/\sigma^2, so power depends on the mean only through its distance from V0V_0 in units of σ\sigma.

The tt statistic uses the same ingredients for a single linear combination. Fix c0c \ne 0 and test cβ=γ0c^{\top}\beta = \gamma_0. Since cβ̂c^{\top}\hat\beta is linear in YY, it is normal with mean cβc^{\top}\beta and variance σ2c(XX)1c\sigma^2 c^{\top}(X^{\top}X)^{-1}c; and β̂\hat\beta is a function of PYPY while σ̂2\hat\sigma^2 is a function of (IP)Y(I - P)Y, so the proposition makes them independent. Standardizing both by the same σ\sigma,

t=cβ̂γ0σ̂c(XX)1c=N(0,1)χnp2/(np)tnp, t = \frac{c^{\top}\hat\beta - \gamma_0}{\hat\sigma \sqrt{c^{\top}(X^{\top}X)^{-1}c}} = \frac{N(0,1)}{\sqrt{\chi^2_{n-p}/(n-p)}} \sim t_{n-p} ,

which is the definition of the tt law. Squaring gives t2F1,npt^2 \sim F_{1, n-p}. More is true than equality in distribution: for a one-dimensional hypothesis the numerator sum of squares equals (cβ̂γ0)2/{c(XX)1c}(c^{\top}\hat\beta - \gamma_0)^2 / \{c^{\top}(X^{\top}X)^{-1}c\}, so t2t^2 and FF 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 Yij=μi+εijY_{ij} = \mu_i + \varepsilon_{ij} with εij\varepsilon_{ij} independent N(0,σ2)N(0, \sigma^2), i=1,2,3i = 1, 2, 3 and j=1,,4j = 1, \dots, 4, so n=12n = 12. Test H0:μ1=μ2=μ3H_0 : \mu_1 = \mu_2 = \mu_3 at level 0.05.

Step 1, name the two subspaces. VV is spanned by the three group indicator vectors, which are linearly independent, so dimV=3\dim V = 3. V0V_0 is spanned by the vector of ones, so dimV0=1\dim V_0 = 1, and V0VV_0 \subseteq V 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 PyPy repeats each group’s mean four times. The grand mean is 204/12=17204/12 = 17, so P0yP_0 y is 17 in every coordinate.

Step 3, take squared lengths. The between-groups component is

(PP0)y2=i=134(yiy)2=4{(4)2+02+42}=128, \lVert (P - P_0)y \rVert^2 = \sum_{i=1}^{3} 4(\bar{y}_i - \bar{y})^2 = 4\{(-4)^2 + 0^2 + 4^2\} = 128 ,

and the within-groups component is the sum of squared deviations inside each group: A gives 16+1+1+16=3416 + 1 + 1 + 16 = 34, B gives 4+1+1+4=104 + 1 + 1 + 4 = 10, and C gives 9+1+1+9=209 + 1 + 1 + 9 = 20, totalling 64. The corrected total is ij(yij17)2=98+10+84=192\sum_{ij}(y_{ij} - 17)^2 = 98 + 10 + 84 = 192, and 128+64=192128 + 64 = 192 is Pythagoras in numbers.

Step 4, take ranks. rank(PP0)=31=2\operatorname{rank}(P - P_0) = 3 - 1 = 2 and rank(IP)=123=9\operatorname{rank}(I - P) = 12 - 3 = 9; with the rank-1 constant direction the ranks are 1+2+9=121 + 2 + 9 = 12, which is Cochran’s condition.

Step 5, get the distributions. Under H0H_0 the mean lies in V0V_0 and is annihilated by PP0P - P_0, so 128/σ2128/\sigma^2 is a draw from χ22\chi^2_2. The within component is central regardless, since (IP)μ=0(I - P)\mu = 0 for every μV\mu \in V, so 64/σ264/\sigma^2 is a draw from χ92\chi^2_9. They are independent because (IP)(PP0)=0(I - P)(P - P_0) = 0 and the errors are normal with covariance σ2I\sigma^2 I.

Step 6, form the ratio. The mean squares are 128/2=64128/2 = 64 and 64/9=7.1164/9 = 7.11, so F=64÷(64/9)=9.00F = 64 \div (64/9) = 9.00 on F2,9F_{2,9}, and σ̂=64/9=8/3=2.67\hat\sigma = \sqrt{64/9} = 8/3 = 2.67 on 9 degrees of freedom. For two numerator degrees of freedom the tail has the closed form P(F2,m>f)=(1+2f/m)m/2P(F_{2,m} > f) = (1 + 2f/m)^{-m/2}, so the tail probability is (1+18/9)4.5=34.5=0.0071(1 + 18/9)^{-4.5} = 3^{-4.5} = 0.0071, and the same equation gives the 0.05 cutoff 4.26.

The F density on two and nine degrees of freedom falling from one at the origin, with a dashed line at the cutoff 4.26 and the tail beyond the observed ratio 9.00 shaded and labelled with tail area 0.0071.

The null density of the F ratio on two and nine degrees of freedom, with the observed value and its tail.

A four-row analysis-of-variance table giving for each line its projection, rank, squared length and mean square: between 2 and 128, within 9 and 64, corrected total 11 and 192, with ratio 9.00.

Every row of an analysis-of-variance table is one projection of the same data vector.

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 n=8n = 8 with group sizes 3 and 5. Now dimV=2\dim V = 2, dimV0=1\dim V_0 = 1, and the ranks are 1+1+6=81 + 1 + 6 = 8.

The group means are 6 and 12 and the grand mean is 78/8=9.7578/8 = 9.75, so the between component is 3(69.75)2+5(129.75)2=42.19+25.31=67.53(6 - 9.75)^2 + 5(12 - 9.75)^2 = 42.19 + 25.31 = 67.5, equivalently (n1n2/n)(y1y2)2=(15/8)(36)(n_1 n_2/n)(\bar{y}_1 - \bar{y}_2)^2 = (15/8)(36). The within component is 8+30=388 + 30 = 38 on 6 degrees of freedom, so the pooled variance estimate is 38/6=6.3338/6 = 6.33 and F=67.5/6.33=10.66F = 67.5/6.33 = 10.66 on 1 and 6 degrees of freedom. The two-sample tt on the same data is (612)/6.33(1/3+1/5)=6/1.838=3.265(6 - 12)/\sqrt{6.33(1/3 + 1/5)} = -6/1.838 = -3.265, and (3.265)2=10.66(-3.265)^2 = 10.66. The tail probability from t6t_6 is 0.017, and the cutoffs correspond because 2.4472=5.992.447^2 = 5.99.

What stayed the same: three orthogonal projections, degrees of freedom read as ranks, squared lengths adding by Pythagoras, an FF 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 nin_i, 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 FF is the square of a tt 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 x=0,1,2,3,4x = 0, 1, 2, 3, 4, one reading each, giving illustrative readings y=7,6,11,12,19y = 7, 6, 11, 12, 19. Model Yi=β0+β1xi+εiY_i = \beta_0 + \beta_1 x_i + \varepsilon_i with εi\varepsilon_i independent N(0,σ2)N(0, \sigma^2) and test H0:β1=0H_0 : \beta_1 = 0. The columns of ones and of xx are independent because xx is not constant, so p=2p = 2, dimV0=1\dim V_0 = 1, and the ranks are 1+1+3=51 + 1 + 3 = 5.

Step 1, fit by projecting. With x=2\bar{x} = 2 and y=11\bar{y} = 11, the centred sums are Sxx=4+1+0+1+4=10S_{xx} = 4 + 1 + 0 + 1 + 4 = 10 and Sxy=(2)(4)+(1)(5)+0+(1)(1)+(2)(8)=30S_{xy} = (-2)(-4) + (-1)(-5) + 0 + (1)(1) + (2)(8) = 30, so β̂1=3\hat\beta_1 = 3 and β̂0=113(2)=5\hat\beta_0 = 11 - 3(2) = 5. The fitted values are 5, 8, 11, 14, 17 and the residuals are 2, 2-2, 0, 2-2, 2.

Step 2, verify orthogonality rather than assume it. Against the column of ones, 22+02+2=02 - 2 + 0 - 2 + 2 = 0; against xx, 0(2)+1(2)+2(0)+3(2)+4(2)=00(2) + 1(-2) + 2(0) + 3(-2) + 4(2) = 0. 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 4+4+0+4+4=164 + 4 + 0 + 4 + 4 = 16 on 52=35 - 2 = 3 degrees of freedom, so σ̂2=16/3=5.333\hat\sigma^2 = 16/3 = 5.333, and the regression sum of squares is (PP0)y2=β̂12Sxx=9(10)=90\lVert (P - P_0)y \rVert^2 = \hat\beta_1^2 S_{xx} = 9(10) = 90 on 1 degree of freedom. The corrected total is 16+25+0+1+64=106=90+1616 + 25 + 0 + 1 + 64 = 106 = 90 + 16.

Step 4, the hat matrix in numbers. For simple regression hii=1/n+(xix)2/Sxxh_{ii} = 1/n + (x_i - \bar{x})^2/S_{xx}, giving leverages 0.6, 0.3, 0.2, 0.3, 0.6. They sum to 2.0, which is tr(P)\operatorname{tr}(P), which is rank(P)\operatorname{rank}(P), which is pp; and tr(IP)=3\operatorname{tr}(I - P) = 3 is the residual degrees of freedom. Nothing was counted from the model equation; it was read off one matrix.

Step 5, the tt statistic. The variance of β̂1\hat\beta_1 is σ2/Sxx\sigma^2/S_{xx}, so the estimated standard error is (16/3)/10=8/15=0.7303\sqrt{(16/3)/10} = \sqrt{8/15} = 0.7303 and t=3/0.7303=4.108t = 3/0.7303 = 4.108 on 3 degrees of freedom. The two-sided tail probability from t3t_3 is 0.026, so the test rejects at 0.05 and not at 0.01. The 0.975 quantile of t3t_3 is 3.182, a long way from 1.96, and that gap is what estimating σ\sigma from three degrees of freedom costs.

Step 6, the same conclusion as an FF. The ratio is F=(90/1)/(16/3)=270/16=16.875F = (90/1)/(16/3) = 270/16 = 16.875, and t2=4.1082=16.875t^2 = 4.108^2 = 16.875 — the same number, not merely the same law. The general identity predicts it: with c=(0,1)c = (0, 1)^{\top}, c(XX)1c=1/Sxx=0.1c^{\top}(X^{\top}X)^{-1}c = 1/S_{xx} = 0.1, so the numerator sum of squares is 32/0.1=903^2/0.1 = 90, which is what step 3 computed geometrically. The cutoffs match too: the square of the 0.975 quantile of t3t_3 is the 0.95 quantile of F1,3F_{1,3}, both being 10.13 to two decimals.

Step 7, invert the test. Week 4’s duality applies unchanged: the values of γ0\gamma_0 the tt test does not reject form 3±3.182(0.7303)3 \pm 3.182(0.7303), that is (0.68,5.32)(0.68, 5.32). 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 tt law is exact conditional on the xx 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 FF 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 σ2I\sigma^2 I. Orthogonality is necessary and not sufficient.

The second clause is where the damage happens. Keep the balanced layout of aa groups of nn with normal errors, but let observations within a group be equicorrelated, so Cov(Y)=σ2{(1ρ)I+ρB}\operatorname{Cov}(Y) = \sigma^2\{(1 - \rho)I + \rho B\} with BB block diagonal of ones. For the balanced layout B=nPB = nP, and a short computation gives (IP)Cov(Y)(IP)=σ2(1ρ)(IP)(I - P)\operatorname{Cov}(Y)(I - P) = \sigma^2(1 - \rho)(I - P) and (PP0)Cov(Y)(PP0)=σ2(1ρ+nρ)(PP0)(P - P_0)\operatorname{Cov}(Y)(P - P_0) = \sigma^2(1 - \rho + n\rho)(P - P_0). Both forms are still exactly chi-square and still exactly independent — but scaled by different multiples of σ2\sigma^2, so

F1ρ+nρ1ρFa1,naa. F \sim \frac{1 - \rho + n\rho}{1 - \rho} \, F_{a-1,\, na - a} .

With n=4n = 4 and ρ=0.3\rho = 0.3 the factor is 1.9/0.7=2.711.9/0.7 = 2.71, so the nominal 0.05 test rejects when an F2,9F_{2,9} variable exceeds 4.26/2.71=1.574.26/2.71 = 1.57, and its actual size is (1+2(1.57)/9)4.5=0.26(1 + 2(1.57)/9)^{-4.5} = 0.26. Every distribution there is exactly normal, so this is not a normality failure. What failed is that the two σ2\sigma^2 values cancelling in the ratio were not the same number.

The third clause invites false comfort. There is an asymptotic defence of the FF 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 n=12n = 12. 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 nn 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.

  1. Projections belong to subspaces. Prove P=X(XX)1XP = X(X^{\top}X)^{-1}X^{\top} is symmetric and idempotent with tr(P)=p\operatorname{tr}(P) = p, show PP is unchanged when XX becomes XAXA for invertible AA, and say what does depend on the choice of columns.
  2. A form that is not chi-square. With ZN2(0,I2)Z \sim N_2(0, I_2) and A=diag(1,4)A = \operatorname{diag}(1, 4), confirm no chi-square law matches both moments of ZAZZ^{\top}AZ, then say when iλiWi2\sum_i \lambda_i W_i^2 is chi-square.
  3. 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.
  4. A size study for correlated errors. Simulate the balanced layout with three groups of four at ρ=0\rho = 0, 0.10.1, and 0.30.3 by adding a shared group-level draw to independent within-group noise. Estimate the actual size of the nominal 0.05 FF test at each ρ\rho with its Monte Carlo standard error, and compare the ρ=0.3\rho = 0.3 case with the 0.26 derived above.
  5. The general one-dimensional identity. For a single linear hypothesis cβ=0c^{\top}\beta = 0, identify the rank-one projection PP0P - P_0 and prove (PP0)Y2=(cβ̂)2/{c(XX)1c}\lVert (P - P_0)Y \rVert^2 = (c^{\top}\hat\beta)^2/\{c^{\top}(X^{\top}X)^{-1}c\}, which is why t2=Ft^2 = F 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

Where this goes next

This week’s FF 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.