Tutorials › Statistical Theory III - Theories of Inference, Multivariate Methods, and Contingency Tables › Independence of Group Means and Within-Group Residuals

Cochran's Theorem and Sums-of-Squares Decompositions · Tutorial 211 of 972

Independence of Group Means and Within-Group Residuals

See how orthogonal projections separate group-level fitted values from within-group residuals, and why Gaussianity makes those components independent.

Intermediate 10 min read

What You'll Learn

  • Express group fitted values and within-group residuals as orthogonal projections.
  • State the Gaussian, independence, and common-variance assumptions needed for independence.
  • Prove independence using zero cross-covariance and joint normality.
  • Derive the distributions and covariance structure of group means and residuals.
  • Distinguish independence of the two components from independence among residuals.
  • Identify why orthogonality alone does not generally imply independence.

Why Separate Group Means From Residuals?

In a one-way layout, each observation contributes to a group average and to a deviation from that average. These are two different aspects of the data: the average describes the group-level location, while the deviations describe variation within the group. For exact normal-theory arguments, it is useful to know more than the fact that their corresponding vectors are orthogonal: under suitable assumptions, the group means and all within-group residuals are independent random objects.

The key conditions are independent Gaussian observations with a common variance. The group means need not be equal. The result follows because averaging and residual formation are orthogonal projections, and linear transformations of a Gaussian vector are jointly Gaussian. Orthogonality then gives zero cross-covariance, which in the jointly Gaussian setting implies independence.

Projection Setup and Definitions

Suppose there are \(k\) nonempty groups, with \(n_i\) observations in group \(i\), and let \(N=\sum_{i=1}^k n_i\). Write the observation in group \(i\) as \(Y_{ij}\), where \(j=1,\ldots,n_i\). Assume

$$ Y_{ij}\ \text{are mutually independent},\qquad Y_{ij}\sim N(\mu_i,\sigma^2),\qquad \sigma^2>0. $$

The mean \(\mu_i\) may vary across groups, but every observation has the same variance. Stack the observations in a vector \(\mathbf Y\in\mathbb R^N\), in group order. Let \(Z\) be the \(N\times k\) group-indicator matrix: the entry in row \(r\), column \(i\) is 1 when observation \(r\) belongs to group \(i\), and 0 otherwise. Since each group is nonempty, \(Z'Z=\operatorname{diag}(n_1,\ldots,n_k)\) is invertible.

Definition: The projection onto the space of vectors that are constant within each group is \(P=Z(Z'Z)^{-1}Z'\). The fitted-value vector is \(P\mathbf Y\), whose entries in group \(i\) equal the sample mean \(\bar Y_i=n_i^{-1}\sum_{j=1}^{n_i}Y_{ij}\). The within-group residual vector is \(\mathbf R=(I-P)\mathbf Y\); its entries in group \(i\) are \(R_{ij}=Y_{ij}-\bar Y_i\).

The matrix \(P\) is symmetric and idempotent, so it is an orthogonal projection. Its complement \(Q=I-P\) is also symmetric and idempotent, and \(PQ=0\). Thus \(P\mathbf Y\) and \(Q\mathbf Y\) lie in orthogonal subspaces for every realized data vector. This geometric statement alone is not yet a statement of statistical independence.

Worked Example: Computing Group Fits and Residuals

Consider two groups with observed values \((6,4)\) and \((0,-3,-3)\). The group sizes are \(n_1=2\) and \(n_2=3\).

The sample means are \(\bar Y_1=(6+4)/2=5\) and \(\bar Y_2=(0-3-3)/3=-2\). Therefore the fitted-value vector, in the stated group order, is \((5,5,-2,-2,-2)'\).

Subtracting these fitted values from the observations gives residuals \((1,-1,2,-1,-1)'\). Within the first group, \(1+(-1)=0\); within the second, \(2+(-1)+(-1)=0\). These zero sums show directly that the residual vector is orthogonal to every vector that is constant within each group.

This calculation describes a realized data vector; by itself it does not establish independence. Independence is a property of the joint probability distribution across repeated samples. The next result supplies the distributional argument.

The Independence Result

Theorem: Under the independent Gaussian model with common variance stated above, the fitted-value vector \(P\mathbf Y\) and the within-group residual vector \(Q\mathbf Y\) are independent. Equivalently, the vector of group means \((\bar Y_1,\ldots,\bar Y_k)'\) is independent of the full collection of within-group residuals \((R_{ij})\).

To prove the theorem, let \(\boldsymbol\mu\in\mathbb R^N\) be the vector whose entries in group \(i\) all equal \(\mu_i\). Independence and the common variance give \(\mathbf Y\sim N_N(\boldsymbol\mu,\sigma^2 I)\). Since \(P\) and \(Q\) are linear maps, the pair \((P\mathbf Y,Q\mathbf Y)\) is jointly Gaussian, possibly with a singular covariance matrix. Its cross-covariance matrix is

$$ \operatorname{Cov}(P\mathbf Y,Q\mathbf Y) =P(\sigma^2 I)Q' =\sigma^2 P Q =0. $$

Here \(Q'=Q\), and \(PQ=P(I-P)=P-P^2=0\). For completeness, zero cross-covariance gives independence here because the pair is jointly Gaussian. Its joint characteristic function has exponent determined by its mean and covariance matrix. With zero cross-covariance, that covariance matrix is block diagonal, so the joint characteristic function factors into the product of the characteristic functions of \(P\mathbf Y\) and \(Q\mathbf Y\). Factorization of the joint characteristic function implies independence. This argument permits singular covariance matrices, as can occur for the residual vector. Therefore \(P\mathbf Y\) and \(Q\mathbf Y\) are independent. \(\square\)

The same result can be seen at the level of each group. The mean \(\bar Y_i\) is a linear function of the observations in group \(i\), and each residual \(R_{ij}\) is also a linear function of those observations. Their covariance is

$$ \operatorname{Cov}(\bar Y_i,R_{ij}) =\operatorname{Cov}\left(\bar Y_i,Y_{ij}-\bar Y_i\right) =\frac{\sigma^2}{n_i}-\frac{\sigma^2}{n_i} =0. $$

For \(l\ne j\) in the same group, the residual covariance is \(\operatorname{Cov}(R_{ij},R_{il})=-\sigma^2/n_i\). Thus residuals within a group are generally dependent on one another, even though they are independent of the group mean. Across different groups, the observations are independent by assumption.

Distributions and What the Theorem Does Not Say

Averaging independent normal observations gives \(\bar Y_i\sim N(\mu_i,\sigma^2/n_i)\). Different group means are independent because they are functions of disjoint sets of independent observations. Within group \(i\), the residual vector has mean zero and covariance matrix \(\sigma^2(I_{n_i}-J_{n_i}/n_i)\), where \(J_{n_i}\) is the \(n_i\times n_i\) matrix of ones. The zero row sums of this matrix reflect the constraint \(\sum_j R_{ij}=0\).

The theorem concerns independence between the group-level fitted values and the within-group residuals. It does not claim that the residual coordinates within a group are mutually independent. For instance, when a group has two observations, its residuals are negatives of each other, so they cannot be independent unless they are degenerate.

Worked Example: Mean and Residual Distribution in One Group

Let \(Y_1,Y_2,Y_3\) be independent \(N(10,4)\) observations from one group. The group mean has distribution \(\bar Y\sim N(10,4/3)\), because its mean is 10 and its variance is \(4/3\).

The residuals are \(R_j=Y_j-\bar Y\). For each \(j\), \(\operatorname{Cov}(\bar Y,R_j)=\operatorname{Cov}(\bar Y,Y_j)-\operatorname{Var}(\bar Y)=4/3-4/3=0\). The covariance matrix of \((R_1,R_2,R_3)'\) is

$$ 4\left(I_3-\frac{J_3}{3}\right) = \begin{pmatrix} 8/3&-4/3&-4/3\\ -4/3&8/3&-4/3\\ -4/3&-4/3&8/3 \end{pmatrix}. $$

For example, \(\operatorname{Cov}(R_1,R_2)=-4/3\), so \(R_1\) and \(R_2\) are not independent. But the mean and the residual vector are jointly Gaussian and have zero cross-covariances, so \(\bar Y\) is independent of the entire residual vector.

Worked Example: An Event Probability From Independence

Let \(Y_1,Y_2\) be independent \(N(0,1)\) observations in one group. Define \(U=(Y_1+Y_2)/\sqrt{2}\) and \(V=(Y_1-Y_2)/\sqrt{2}\). Then the sample mean is \(\bar Y=U/\sqrt{2}\), and the two residuals are \(V/\sqrt{2}\) and \(-V/\sqrt{2}\).

The pair \((U,V)\) is jointly Gaussian. Its means are zero, both variances are 1, and \(\operatorname{Cov}(U,V)=E[(Y_1+Y_2)(Y_1-Y_2)]/2=(1-1)/2=0\). Thus \(U\) and \(V\), and consequently the sample mean and residual vector, are independent.

The event \(\bar Y>0\) is \(U>0\), with probability \(1/2\). The event \(|Y_1-\bar Y|\le 1/\sqrt{2}\) is \(|V|/\sqrt{2}\le1/\sqrt{2}\), or \(|V|\le1\), with probability \(P(|Z|\le1)\approx0.6827\) for \(Z\sim N(0,1)\). Independence therefore gives \(P(\bar Y>0,\ |Y_1-\bar Y|\le1/\sqrt{2})=(1/2)(0.6827)\approx0.34135\).

Unequal Group Sizes and a Group-Mean Contrast

Equal group sizes are not required. For example, let group 1 have size 2 and distribution \(N(3,4)\), and group 2 have size 4 and distribution \(N(1,4)\), with all six observations independent. Then \(\bar Y_1\sim N(3,2)\) and \(\bar Y_2\sim N(1,1)\). The contrast \(D=\bar Y_1-\bar Y_2\) has mean \(3-1=2\) and variance \(2+1=3\), so \(D\sim N(2,3)\).

Since \(D\) is a function of the fitted-value vector, it is independent of the full within-group residual vector. The different group sizes change the variances of the means, but they do not affect the projection argument: group averaging and within-group centering remain orthogonal in the observation space.

Common Mistake and Practical Significance

A common mistake is to argue, “The fitted values and residuals are orthogonal, so they are independent.” Orthogonality is a geometric property and, in general, only yields zero covariance for suitable random vectors. Zero covariance does not by itself imply independence. The correction is to check the distributional condition: here both components are linear transformations of a jointly Gaussian vector, and jointly Gaussian components with zero cross-covariance are independent.

The assumptions matter. If observations have unequal variances or are correlated, their covariance matrix is not \(\sigma^2 I\), and the calculation \(P(\sigma^2 I)Q=0\) need not hold. Without Gaussianity, even zero cross-covariance does not generally establish independence. Thus the conclusion is exact for the stated normal model, not a consequence of the algebra of group averages alone.

This separation matters because it allows probability statements about group-level estimates to be considered independently of within-group noise under the model. It also clarifies which part of an argument is geometric and which part is probabilistic: the projections determine orthogonality, while Gaussianity turns that orthogonality into independence.

Check Your Understanding

Answer each question using the projection and distribution arguments developed above.

  1. Why does the group-indicator projection \(P\) produce a vector whose entries in group \(i\) all equal \(\bar Y_i\)?
  2. Show that \(\operatorname{Cov}(\bar Y_i,R_{ij})=0\) under the common-variance model.
  3. Why does zero cross-covariance imply independence in this setting, but not for arbitrary random vectors?
  4. Are two residuals from the same group necessarily independent? Explain using their covariance or the zero-sum constraint.
  5. Which step in the proof may fail if the observations have unequal variances?
Clinical Biostats