Nested Designs
A factor is nested when each of its levels belongs to exactly one level of another factor. Batches belong to suppliers; spindles belong to machines; repeated measurements belong to particular subjects. The grouping determines which comparisons and replications are meaningful.
At a Glance¶
Each lower-level unit belongs to only one higher-level unit; labels are local to that unit.
The levels of one factor occur with the levels of the other, allowing shared factor effects across combinations.
Nested Versus Crossed¶
In a crossed design, the same B levels occur at each A level: for example, the same temperatures are tested with every material. In a nested design, “batch 1” from supplier A is a different batch from “batch 1” from supplier B. Their shared label does not create a common factor level.
A separate batch main effect and supplier-by-batch interaction have no useful crossed interpretation in that setting. Model batch within supplier, written .
Model & Notation¶
For A levels, B levels within each A, and observations per nested unit,
Here identifies the outer group, identifies an inner unit belonging to that group, and identifies a replicate within that unit. In a fully fixed model, use and separately for every .
A bar means an average; a dot marks an averaged index. Thus is the nested-unit mean, is the outer-group mean, and is the overall mean.
Balanced ANOVA Decomposition¶
| Source | df | Mean square |
|---|---|---|
| A | ||
| B within A | ||
| Error | ||
| Total | , |
The three sums of squares add to .
Why the decomposition works
Split each centered observation into three pieces:
Within-unit residuals sum to zero, and within-A deviations of unit means sum to zero. The cross-products therefore cancel when squared and summed, leaving the three ANOVA components.
If arbitrary within-group labels are used to calculate a balanced crossed ANOVA, then algebraically
Only their combined nested quantity has the intended interpretation. Relabeling inner units within an outer group cannot change the nested sum of squares, although it can change the artificial B and AB pieces.
Choose Tests from the Sampling Model¶
If both factors are fixed, test A and against , under the usual independent normal equal-variance error assumptions.
If inner units are random, use independent . Then
In either of these random-inner-unit models, test A using , with df. Test the inner variance component using , with df.
The reason is concrete: repeated readings from one batch do not provide new independent batches. Comparing suppliers must account for batch-to-batch variation, not just reading error. Do not apply the random-inner-unit rule solely because some factor is described as random; specify which factor is random and derive its expected mean squares.
Worked Nested Calculation¶
The following small illustrative dataset has three machines, two distinct spindles within each machine, and four readings per spindle. It is constructed for practicing the decomposition.
The outer-group mean square is 202.6667, the nested-unit mean square is 32, and the residual mean square is . For random spindles, the machine test uses , rather than the much larger . The appropriate denominator reflects which population the comparison is meant to cover.
Combining an Existing Table¶
If a balanced table instead reports on 1 df and on 2 df, the combined nested row is
The error row stays unchanged. A reported ratio near 9.9 with df corresponds to an upper-tail p-value near 0.0004. Use the actual error mean square for an exact calculation rather than inferring it from a rounded F statistic.
Variance Components & Replication¶
When both levels are random, moment estimates are
For the illustrative data these are , , and , respectively. Negative moment estimates can arise in other datasets and need the same care as other variance-component estimates.
Two readings from the same inner unit share both random components; two readings from different inner units in the same outer group share only the A component. Distinct outer groups are independent under this model. Extra readings chiefly improve estimation of residual error; more independent inner and outer units are needed to learn their respective population variation.
Deeper Nesting & Common Mistakes¶
For supplier, batch, sub-batch, and reading, a three-level model is
Each additional random grouping contributes its own variance component. Preserve unique unit identities in the data: “supplier A / batch 1” and “supplier B / batch 1” must not become the same batch.
These balanced formulas assume the same number of units and readings at each branch. Unequal branch sizes or missing observations call for a model-based analysis. Repeated instrument readings are not independent experimental replicates if they share an unmodeled source of variation. Define the unit of treatment assignment and the sampling hierarchy before fitting the model.