Why Observation Order Matters
A residual-versus-fitted plot arranges residuals according to the model’s fitted values. A residual plot against a predictor arranges them according to that predictor. Either can be useful, but neither necessarily shows when or in what sequence the observations were collected. If measurements were made over time, in production order, or in a sequence of locations, their order may contain information that those other plots conceal.
For example, a model may have residuals scattered around zero overall, yet the first group of observations may mostly lie above zero and the next group mostly below it. Such a sequence can suggest that conditions changed during collection, or that nearby observations are related. A plot in observation order is a straightforward way to look for these clues.
The Model and the Order Plot
Suppose observation \(i\) has response \(Y_i\) and predictor values \(x_{i1},\ldots,x_{ip}\). In a multiple linear regression model, the conditional mean is represented as a linear combination of the predictors, with an error term for the remaining variation. The usual model assumptions include a correctly specified conditional mean, errors with mean zero and constant variance, and errors that are independent across observations. Normality is an additional assumption used for some exact small-sample inference; it is not required simply to draw or inspect an order plot.
After fitting the model, the residual for observation \(i\) is the observed response minus its fitted response. An observation-order residual plot places those residuals vertically and the collection order, time index, or another meaningful sequence horizontally. A horizontal reference line at zero helps show whether residuals alternate around zero or remain on one side for extended stretches.
Use an ordering that reflects the data-collection process. If the records are stored alphabetically or have been sorted by response, that arrangement is not a substitute for collection order. If order is unknown, say so: a plot against an arbitrary row number cannot establish a time pattern. When time gaps vary, actual time may be more informative than a simple observation number.
Reading Runs, Cycles, and Shifts
A long run of positive residuals followed by a long run of negative residuals means the model tended to underpredict first and overpredict later, assuming residuals are defined as observed minus fitted. The reverse sequence means it tended to overpredict first and underpredict later. Either pattern is a reason to investigate whether observations close together are more alike than the model assumes, or whether the measurement process or underlying conditions changed.
A repeating sequence of high and low residuals may indicate a cyclical feature that the fitted model does not represent, or dependence associated with a recurring schedule. A gradual movement from negative to positive residuals may point to drift, such as a changing process or a predictor that changes systematically with collection order. These are interpretations of the pattern, not automatic identifications of its cause.
Worked Example: Two Long Runs
A technician records ten measurements in production order and fits an intercept-only model with fitted value \(\hat{y}_i=20\) for every observation. The observed responses, in order, are \(21.0, 20.8, 21.2, 20.9, 21.1, 19.0, 19.2, 18.8, 19.1,\) and \(18.9\). Find the residual sequence and describe its order plot.
For each observation, \(r_i=y_i-\hat{y}_i\). For example, the first residual is \(21.0-20=1.0\), and the sixth is \(19.0-20=-1.0\). Subtracting 20 from each response gives \(1.0, 0.8, 1.2, 0.9, 1.1, -1.0, -0.8, -1.2, -0.9, -1.1\). The positive residuals sum to \(5.0\) and the negative residuals sum to \(-5.0\), so the sequence is centered at zero for this intercept-only fit.
The order plot has five consecutive points above zero followed by five below zero: two long runs. The model underpredicts the first five measurements and overpredicts the last five. This is a warning to check whether the production process or conditions changed, or whether nearby measurements are dependent. The plot alone does not tell us which explanation is correct.
Why a Shift Can Appear in Residuals
A simple calculation illustrates why changes over collection order can leave a pattern. Consider an intercept-only fit, and suppose responses follow \(y_i=\beta_0+\delta_i+\varepsilon_i\), where \(\delta_i\) represents a systematic order-related change and \(\varepsilon_i\) is random variation. The fitted intercept is the sample mean of the responses. Subtracting that mean from each response gives the exact residual expression below.
Here \(\bar{\delta}\) and \(\bar{\varepsilon}\) are the averages of the respective sequences. The fit absorbs the overall average level, but an order-related change that varies across observations remains in the residuals as departures from its average, mixed with random variation. This is a justification for checking the sequence, not proof that every visible trend is a real process change.
Worked Example: A Repeating Cycle
A hypothetical sensor is read twelve times at equal time intervals. An intercept-only model gives \(\hat{y}_i=100\) each time. The observed readings are \(101,100,99,99,100,101,101,100,99,99,100,101\). Calculate the residuals and interpret the pattern.
Using \(r_i=y_i-\hat{y}_i\), the residuals are \(1,0,-1,-1,0,1,1,0,-1,-1,0,1\). For instance, the third residual is \(99-100=-1\), and the eighth is \(100-100=0\). Their sum is \(1+0-1-1+0+1+1+0-1-1+0+1=0\).
The residual sequence repeatedly moves from positive values through zero to negative values and back toward positive values. That repeated movement is a cyclical pattern worth investigating. It could reflect a recurring feature of the process or measurement schedule, but twelve observations are not enough to establish a particular cycle or its cause. The plot is a diagnostic prompt, not a standalone conclusion.
Worked Example: A Gradual Shift
In another hypothetical sequence of ten observations, an intercept-only fit gives \(\hat{y}_i=50\). The responses, in collection order, are \(48.5,48.8,49.1,49.4,49.7,50.3,50.6,50.9,51.2,51.5\). Calculate the residual sequence and state what its pattern suggests.
Subtract the fitted value from each response: \(48.5-50=-1.5\), \(48.8-50=-1.2\), and so on. The residuals are \(-1.5,-1.2,-0.9,-0.6,-0.3,0.3,0.6,0.9,1.2,1.5\). They sum to zero: the five negative values sum to \(-4.5\), and the five positive values sum to \(4.5\).
The plotted residuals move steadily from negative to positive. Thus, the model overpredicts early responses and underpredicts later ones. The pattern suggests drift or another systematic change across collection order that the fitted model does not account for. It does not establish whether the cause is a changing process, an omitted time-related feature, or some other factor.
A Practical Reading Procedure
A useful order plot should make the sequence and the zero reference clear. Read it in context, describing what the residuals do before proposing why they do it.
Use actual time, production sequence, or another documented order. Label the horizontal axis so the reader knows what one step represents.
Use residuals \(r_i=y_i-\hat{y}_i\) and mark zero. Retain the original sequence rather than rearranging points to make the pattern easier to see.
State whether the points alternate around zero, form runs, repeat in cycles, or move gradually. Mention the direction and approximate portion of the sequence.
Explain that a structured sequence may indicate dependence or changing conditions, then identify what additional information about collection or process conditions would help evaluate that possibility.
What the Plot Can and Cannot Establish
The independence assumption concerns the model errors, which are not directly observed. Residuals are calculated from the data and the fitted model, so their patterns are evidence to examine rather than a direct measurement of the errors. A clear run or cycle may be concerning even when residuals are centered near zero overall: an average close to zero does not rule out systematic order structure.
Conversely, a plot with no obvious pattern does not prove independence. A small data set may not reveal a real pattern, and an order-related effect may be difficult to see against random variation. A plot also does not identify a cause by itself. Relevant follow-up questions include whether collection conditions changed, whether measurements were taken in batches, and whether the time or sequence variable belongs in the scientific description of the problem.
Common Mistake
Check Your Understanding
Answer each question using the distinction between a visible pattern and its possible explanation.
- What belongs on the horizontal and vertical axes of an observation-order residual plot?
- A sequence begins with eight positive residuals and ends with eight negative residuals. What does this indicate about the model’s predictions in the two parts of the sequence?
- Why can residuals average to zero even when their order plot shows a gradual shift?
- What is one possible explanation for a repeating cycle in residuals, and why does the plot not establish that explanation?
- If data have been sorted by response before plotting, why is that order unsuitable for assessing collection-order patterns?