Tutorials › ANOVA › Checking Independence With Residual Order Plots

Residual Diagnostics and Influence · Tutorial 543 of 595

Checking Independence With Residual Order Plots

Use residuals in their actual collection order to look for dependence or process changes, while accounting for patterns caused by estimating group means.

Intermediate 11 min read

What You'll Learn

  • State the ANOVA error-independence assumption and distinguish errors from fitted residuals.
  • Arrange residuals by actual collection or time order, rather than by value or group.
  • Recognize drift, cycles, long runs, clustering, and abrupt changes in an order plot.
  • Derive the covariance and correlation induced among residuals within a group.
  • Explain what an order plot can suggest and why it cannot prove independence.
  • Use treatment labels and collection context to investigate a visible pattern.

Why Collection Order Matters

An ANOVA model can describe differences among treatment or group means, but its conclusions also rely on how observations vary around those means. In particular, the model ordinarily assumes that the errors for distinct observations are independent. If measurements collected close together tend to be similar, or if a process changes during collection, that assumption may be questionable even when a plot of residuals against fitted values looks unremarkable.

A residual order plot displays residuals in the order the observations were collected, measured, or otherwise placed in a meaningful sequence. It can reveal drift, cycles, long runs of positive or negative residuals, clustering, or an abrupt change. Such patterns are clues to investigate, not proof of a particular cause or a formal test of independence.

Definition: In a one-way ANOVA with \(k\) groups, write the observation in group \(i\) as \(Y_{ij}=\mu_i+\epsilon_{ij}\), where \(j=1,\ldots,n_i\). The fitted group mean is \(\bar{Y}_{i\cdot}\), and the residual is \(e_{ij}=Y_{ij}-\bar{Y}_{i\cdot}\). The independence assumption concerns the errors \(\epsilon_{ij}\): conditional on the group means, errors from distinct observations are independent. A residual order plot places the \(e_{ij}\) values against their actual collection order.

For the usual one-way ANOVA model, errors have mean zero and a common variance \(\sigma^2\), in addition to being independent. Normality is a separate condition used for the exact small-sample ANOVA \(F\) inference; it is not what a residual order plot assesses. The order plot focuses on whether residual behavior appears related to sequence. It does not check every model assumption.

Constructing and Reading an Order Plot

Keep the order that has meaning for how the data were generated: for example, run number, measurement time, or sequence of collection. Plot each residual against that order and include a horizontal reference line at zero. If treatments or groups are interleaved, retain their actual order and mark group membership with symbols, colors, or labels. Sorting observations by residual value or grouping all observations together by treatment destroys the sequence information the plot is meant to show.

Look for patterns rather than isolated departures. A gradual rise or fall can indicate drift. A repeating wave or alternating pattern can suggest a cycle. A long sequence of residuals on the same side of zero is a run; repeated clusters or a sudden level change can suggest dependence or a process change. A roughly patternless cloud around zero is consistent with independence, but does not establish it: some kinds of dependence are difficult to see, especially with few observations.

The collection plan matters when interpreting the plot. If all observations from one treatment were collected first and all observations from another treatment later, treatment and time are confounded in the sequence. A visible change could reflect a treatment difference, a time change, or both. Interleaving or randomizing treatment order, where appropriate to the study, helps separate these possibilities. Also consider whether observations from the same person, animal, batch, or machine are naturally connected; a plot alone cannot make dependent observations independent.

Residuals Can Be Correlated Even When Errors Are Independent

Residuals are calculated after estimating the group means, so they are not simply the original errors. This estimation imposes a constraint: residuals within each group sum to zero. As a result, residuals within a group are correlated even under the model in which the errors themselves are independent. This fact is important when reading apparent patterns in an order plot.

Result: If the errors are independent with variance \(\sigma^2\), then for two distinct observations \(j\ne \ell\) in group \(i\), the residual covariance is \(\operatorname{Cov}(e_{ij},e_{i\ell})=-\sigma^2/n_i\). If \(n_i>1\), their residual correlation is \(-1/(n_i-1)\). The covariance magnitude decreases as \(n_i\) increases; it need not be small for small groups. When \(n_i=2\), the residuals are exact negatives and their correlation is \(-1\).

Here is the derivation. The group mean error is \(\bar{\epsilon}_{i\cdot}=(1/n_i)\sum_{r=1}^{n_i}\epsilon_{ir}\), so \(e_{ij}=\epsilon_{ij}-\bar{\epsilon}_{i\cdot}\). For distinct \(j\) and \(\ell\), independence gives \(\operatorname{Cov}(\epsilon_{ij},\epsilon_{i\ell})=0\). Each of \(\operatorname{Cov}(\epsilon_{ij},\bar{\epsilon}_{i\cdot})\) and \(\operatorname{Cov}(\epsilon_{i\ell},\bar{\epsilon}_{i\cdot})\) equals \(\sigma^2/n_i\), while \(\operatorname{Var}(\bar{\epsilon}_{i\cdot})=\sigma^2/n_i\). Therefore:

$$ \begin{aligned} \operatorname{Cov}(e_{ij},e_{i\ell}) &=\operatorname{Cov}(\epsilon_{ij}-\bar{\epsilon}_{i\cdot}, \epsilon_{i\ell}-\bar{\epsilon}_{i\cdot})\\ &=0-\frac{\sigma^2}{n_i}-\frac{\sigma^2}{n_i} +\frac{\sigma^2}{n_i}\\ &=-\frac{\sigma^2}{n_i}. \end{aligned} $$

For the correlation, each residual has variance \(\operatorname{Var}(e_{ij})=\sigma^2(1-1/n_i)\). Dividing the covariance by this variance gives \(\operatorname{Corr}(e_{ij},e_{i\ell})=[-\sigma^2/n_i]/[\sigma^2(1-1/n_i)]=-1/(n_i-1)\). For \(n_i=2\), the zero-sum constraint gives \(e_{i2}=-e_{i1}\), matching correlation \(-1\). If \(n_i=1\), the residual is always zero and its correlation is undefined. Residuals from different groups have covariance zero under this model because they are functions of disjoint sets of independent errors.

This induced correlation is not evidence that the errors are dependent; it comes from estimating a mean. It also does not make an order plot useless. Rather, it is a reason to interpret patterns with the group structure in view, particularly when groups are small or when observations from one group occur in a block.

Worked Examples

Worked Example: A Rising Pattern Across Interleaved Treatments

Suppose a hypothetical process has two treatments, A and B, with three observations per treatment. The measurements are collected in the order shown. Calculate the fitted group means and residuals, then describe what the order suggests.

Run orderTreatmentMeasurement
1A10
2B20
3A11
4B21
5A12
6B22

The treatment means are \(\bar{Y}_{A\cdot}=(10+11+12)/3=11\) and \(\bar{Y}_{B\cdot}=(20+21+22)/3=21\). Subtracting the appropriate treatment mean gives the residual sequence \(-1,-1,0,0,1,1\). In collection order, the residuals move from negative to positive rather than fluctuating without an evident pattern.

This rising pattern is a reason to investigate possible drift during collection, such as a change in equipment or ambient conditions. It does not identify a cause, and six observations are not enough to establish a trend reliably. The group-centered residuals also sum to zero within each treatment, as they must. Here \(n_i=3\), so the model-based within-treatment residual correlation is \(-1/(3-1)=-0.5\); that induced correlation should not be confused with a genuine time effect. The sequence is a diagnostic clue, not a formal independence test.

Worked Example: A Repeating Cycle

In another hypothetical process, eight observations alternate between treatments A and B. The measurements are \(52,61,48,59,52,61,48,59\), in that collection order. Treatment A has values \(52,48,52,48\), so its mean is \((52+48+52+48)/4=50\). Treatment B has values \(61,59,61,59\), so its mean is \((61+59+61+59)/4=60\).

Subtracting the relevant group mean gives the residuals in order: \(2,1,-2,-1,2,1,-2,-1\). The same four-value pattern repeats twice. A plot would show a repeating up-and-down cycle rather than an unstructured cloud around zero. Possible explanations to investigate include a periodic operating condition or a repeating measurement sequence. The plot alone cannot determine which explanation is correct.

Each group has four residuals that sum to zero. Under independent, equal-variance errors, the within-group residual correlation is \(-1/(4-1)=-1/3\). The repeated sequence across the full collection order is a distinct diagnostic feature to investigate; the within-group residual constraint remains part of interpreting the plot. Treatment alternation does not remove the need to check whether some other process also varies periodically.

Worked Example: A Sudden Process Change

Imagine that a hypothetical instrument experiences a level change after run 4. Treatments A and B are interleaved, so each occurs both before and after the change. The measurements are \(10,20,10,20,14,24,14,24\), with treatments A, B, A, B, A, B, A, B in order.

For A, the mean is \((10+10+14+14)/4=12\); for B, it is \((20+20+24+24)/4=22\). The residuals in collection order are therefore \(-2,-2,-2,-2,2,2,2,2\). The first four residuals are negative and the last four are positive, with a clear step between runs 4 and 5.

The fitted treatment means absorb the average level of each treatment, but they do not account for the common change during collection. The order pattern suggests a process shift that affects both treatments. An investigator might check instrument settings, operator changes, or other events near run 5. The pattern does not prove that the instrument caused the change, and it does not by itself show whether an ANOVA treatment conclusion is valid; it indicates that the fitted model may omit an important feature of the data-generating process.

How to Use the Diagnostic Responsibly

1
Recover the meaningful order.
Use actual run number, time, or collection sequence. Do not rearrange observations to make the plot look clearer.
2
Plot residuals around zero.
Use the fitted group mean for each observation, and mark treatment membership when it helps distinguish group patterns from sequence patterns.
3
Describe visible structure.
State whether there is drift, cycling, a long run, clustering, or an abrupt change. Avoid calling a pattern proof of dependence.
4
Check the data-collection context.
Ask whether timing, equipment, batches, repeated measurements, or treatment order could explain the pattern, and whether observations are genuinely independent units.

A common mistake is to say, “The residuals are scattered around zero, so the observations are independent.” The correction is that a patternless-looking plot offers only limited evidence against visible sequence structure; it cannot prove independence, and dependence may not be apparent in a small sample. The opposite mistake is to treat every run of signs as proof of dependence. Residuals are constrained by group-mean estimation, and chance patterns occur. Describe what the plot shows, account for the design and residual constraints, and investigate plausible causes before drawing a conclusion.

Order plots matter because independence is about the way observations relate to one another, not simply about the shape of a single group’s residual distribution. A plot can expose a missing time or process feature that is invisible when observations are summarized only by treatment. It should be read alongside the study design and the other residual diagnostics, not as a stand-alone pass-or-fail rule.

Key takeaway: Plot ANOVA residuals in their true collection order and look for systematic sequence patterns. Treat those patterns as prompts to investigate the process, remembering that fitted residuals within a group have covariance \(-\sigma^2/n_i\) and correlation \(-1/(n_i-1)\) under the independent-error model.

Check Your Understanding

Try these questions before reviewing the examples.

  1. Why should residuals be plotted in actual collection order rather than sorted by residual size?
  2. In a group of size \(n_i=4\), what is the model-based correlation between two distinct residuals in that group? What does the result describe?
  3. A sequence of residuals gradually rises from negative to positive. Give two possible process features to investigate, and explain why the plot does not establish a cause.
  4. Why can residuals from two observations in a group of size 2 have correlation \(-1\) even when the model errors are independent?
  5. What does a patternless order plot suggest, and what can it not prove?
Clinical Biostats