Sub topic 7
I-MR charts: one measurement at a time
This chapter assumes you can read a basic control chart (center line, upper and lower control limits, time order). It also assumes you know the difference between common-cause and special-cause variation, and you can compute a mean, a range, and a standard deviation. The code uses Python and NumPy.
When an I-MR chart is the right tool
An individuals and moving range chart (I-MR chart) is for variables data when you have one measurement per time period. Typical cases:
- A daily lab result, such as the pH of a batch.
- A monthly figure, such as cycle time or cost.
- A slow or expensive measurement, such as a destructive test.
- A process that produces one unit per run, such as a furnace load.
If you can collect several measurements in each period under the same conditions, use an X-bar and R chart instead. The next chapter covers it. It detects small shifts more quickly, and it depends less on the shape of the data distribution.
An I-MR chart is really two charts read together:
- The I chart (individuals chart) plots each measurement in time order. It shows whether the level of the process is stable.
- The MR chart (moving range chart) plots the absolute difference between each measurement and the one before it. It shows whether the short-term variation is stable.
Why the limits use the moving range
A control chart needs an estimate of sigma, the standard deviation of the process when only common causes are acting. The tempting choice is the sample standard deviation of all your data. That choice has a flaw. If the process has shifted or drifted, those shifts are part of the data, so they inflate the standard deviation. The limits then widen to include the very signals you want to detect.
The moving range avoids this. Each moving range compares only two neighbouring points, so it measures short-term, point-to-point variation. A slow drift or a single step change adds little to it. The average moving range, written MR-bar, therefore estimates the common-cause variation.
For a moving range of span 2, the expected range of two observations is d2 times sigma, with d2 = 1.128. So:
- sigma-hat = MR-bar / 1.128
- The I chart limits are x-bar ± 3 × MR-bar / 1.128. Since 3 / 1.128 = 2.66, this becomes x-bar ± 2.66 × MR-bar.
- The MR chart's upper limit is D4 × MR-bar, with D4 = 3.267 for n = 2.
- The MR chart's lower limit is 0. For a span of 2, D3 is 0, and a range cannot be negative anyway.
| Quantity | Formula | Constant |
|---|---|---|
| I chart center line | x-bar (mean of all points) | none |
| I chart UCL | x-bar + 2.66 × MR-bar | 2.66 = 3 / d2 |
| I chart LCL | x-bar − 2.66 × MR-bar | 2.66 = 3 / d2 |
| MR chart center line | MR-bar (mean of the moving ranges) | none |
| MR chart UCL | 3.267 × MR-bar | D4 for n = 2 |
| MR chart LCL | none (0) | D3 = 0 |
With k measurements you get k − 1 moving ranges. The first point has no predecessor, so it has no moving range.
A worked example
Ten consecutive readings of a fill weight (in grams) are:
10.2, 9.8, 10.1, 10.4, 9.9, 10.0, 10.3, 9.7, 10.1, 10.2
- The mean is 100.7 / 10 = 10.07.
- The nine moving ranges are 0.4, 0.3, 0.3, 0.5, 0.1, 0.3, 0.6, 0.4, 0.1. They sum to 3.0, so MR-bar = 3.0 / 9 = 0.333.
- The I chart limits are 10.07 ± 2.66 × 0.333 = 10.07 ± 0.887. That gives LCL ≈ 9.18 and UCL ≈ 10.96.
- The MR chart UCL is 3.267 × 0.333 ≈ 1.09.
The code below does the same calculation.
import numpy as np
x = np.array([10.2, 9.8, 10.1, 10.4, 9.9, 10.0, 10.3, 9.7, 10.1, 10.2])
mr = np.abs(np.diff(x)) # moving ranges of span 2
x_bar = x.mean()
mr_bar = mr.mean()
# 2.66 = 3 / d2 with d2 = 1.128 (n = 2); 3.267 = D4 for n = 2; the MR chart has no lower limit
x_ucl = x_bar + 2.66 * mr_bar
x_lcl = x_bar - 2.66 * mr_bar
mr_ucl = 3.267 * mr_bar
print(x_lcl, x_bar, x_ucl)
print(0.0, mr_bar, mr_ucl)The output is approximately 9.183 10.07 10.957 for the I chart and 0.0 0.333 1.089 for the MR chart. Every reading lies between 9.18 and 10.96, and every moving range is below 1.09. The chart gives no signal, so the data are consistent with a process showing only common-cause variation.
Ten points is too few for real work. It keeps the arithmetic easy to follow. In practice you want at least 20 to 25 points before you trust the limits, because MR-bar is itself an estimate and is noisy with few points.
Reading the two charts together
Read the MR chart first. If the MR chart shows a signal, the short-term variation is unstable. The I chart limits are built from MR-bar, so they are not trustworthy until you understand and remove that cause.
Then read the I chart for shifts in level.
- A point beyond a limit on the I chart means a measurement is larger or smaller than common-cause variation would normally produce.
- A point beyond the MR upper limit means a sudden jump between two consecutive readings. One large jump produces one high moving range. A step change also produces one high moving range, at the moment of the step.
- Runs of eight or more points on one side of the center line suggest a sustained shift in level. The chapter on signal rules covers this in detail.
Moving ranges are not independent of each other. Reading x1, x2, x3 gives two moving ranges, and both involve x2. So one unusual point can create two large moving ranges in a row. Patterns of consecutive points on the MR chart are less informative than patterns on the I chart. For this reason, run rules are normally applied to the I chart, and the MR chart is checked mainly for points beyond the limit.
A reusable function
When you keep returning to the same calculation, wrap it in a function. This one also lists the points that fall outside the limits.
import numpy as np
D2 = 1.128
D4 = 3.267
def imr_chart(x):
"""Return I and MR chart statistics and the indices of out-of-limit points."""
x = np.asarray(x, dtype=float)
mr = np.abs(np.diff(x))
x_bar = x.mean()
mr_bar = mr.mean()
sigma_hat = mr_bar / D2
x_ucl = x_bar + 3 * sigma_hat
x_lcl = x_bar - 3 * sigma_hat
mr_ucl = D4 * mr_bar
return {
"x_bar": x_bar,
"mr_bar": mr_bar,
"sigma_hat": sigma_hat,
"x_limits": (x_lcl, x_ucl),
"mr_ucl": mr_ucl,
"x_signals": np.where((x > x_ucl) | (x < x_lcl))[0].tolist(),
# mr[i] is the change from x[i] to x[i + 1], so it belongs to point i + 1
"mr_signals": (np.where(mr > mr_ucl)[0] + 1).tolist(),
}
data = [10.2, 9.8, 10.1, 10.4, 9.9, 10.0, 10.3, 9.7, 10.1, 10.2]
result = imr_chart(data)
print(result["x_limits"], result["mr_ucl"])
print(result["x_signals"], result["mr_signals"])Because sigma_hat uses 1.128 directly, the limits match the 2.66 form to within rounding. The function reports a moving range at the index of the later point, which is the usual way to align the MR chart with the I chart.
Assumptions and edge cases
Time order matters. The moving range is only meaningful if consecutive points are consecutive in time. If you sort the data or shuffle it, the chart is meaningless.
Autocorrelation. Many individual-measurement processes have neighbouring points that are correlated, such as temperatures in a large vessel or tank levels. Positive autocorrelation makes the moving ranges smaller than the true spread, so the limits come out too narrow and you get false alarms. Check by plotting each point against the next. If the points cluster along a line, the I-MR assumptions are weak.
Non-normality. The 3-sigma limits assume a roughly symmetric, bell-shaped distribution. An I chart has no averaging to help it, so skewed data cause trouble. Skewed data, such as times, concentrations near zero, or counts of rare events, give false signals on one side and miss real shifts on the other. Options are to transform the data (a log transform is common for right-skewed positive data) or to use a chart designed for the data type.
Inflated MR-bar. A single extreme point inflates two moving ranges and therefore MR-bar. If you are building baseline limits, investigate a point that is far out. If it has an assignable cause, remove it and recalculate. If you cannot find a cause, keep it.
Measurement resolution. If the measurement is rounded coarsely, many moving ranges become 0, and MR-bar shrinks. The limits become too tight. As a rough check, the moving ranges should take at least four or five distinct values.
Rare-event warning. For a stable normal process, about 0.27% of points fall outside 3-sigma limits by chance. On a chart with 100 points, you expect an occasional false alarm. Investigate a single point, but do not redesign the process on its basis alone.
Common errors
- Using the overall standard deviation for the limits. This hides drift and lowers sensitivity.
- Building limits from fewer than about 20 points, then treating them as fixed.
- Reading the MR chart's points as independent when each point shares a reading with its neighbour.
- Using I-MR when you do have several measurements per period. Subgroup information is lost, and a chart that uses it would detect shifts sooner.
- Reacting to every point that looks high. A point inside the limits is, by the chart's rules, common-cause variation.
Exercise
Seven consecutive measurements are 50, 52, 49, 51, 53, 50, 52. Compute the I chart control limits using the moving range method (use 2.66). Is any point outside them?
Show answer
The mean is 357 / 7 = 51. The six moving ranges are 2, 3, 2, 2, 3, 2. They sum to 14, so MR-bar = 14 / 6 ≈ 2.333. The I chart limits are 51 ± 2.66 × 2.333 = 51 ± 6.207, so LCL ≈ 44.79 and UCL ≈ 57.21. All values lie between 49 and 53, so no point is outside the limits. With only seven points the limits are provisional.
Exercise
A process drifts steadily upward, for example 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20. Explain why limits computed from the overall standard deviation would hide this drift, and what the moving range method gives instead.
Show answer
The overall standard deviation (about 3.3) includes the drift, so the limits are wide (mean 15 ± about 10) and every point falls inside them. The moving ranges are all 1, so MR-bar = 1 and the I chart limits are 15 ± 2.66, which is 12.34 to 17.66. The early and late points fall outside, so the chart signals the drift. The moving range measures only point-to-point variation, and the drift barely affects it.