Sub topic 6
Choosing a chart: a decision path
This chapter assumes you already know three things:
- The difference between common-cause and special-cause variation.
- The parts of a control chart: center line, limits, and time order.
- The difference between variables data and attribute data, and what a rational subgroup is.
Here you will use those ideas to pick one of four charts: I-MR, X-bar and R, p, or u. Choosing the wrong chart is a common error. The limits can look reasonable and still give false alarms or miss real signals.
Three questions that pick the chart
Work through the questions in order. Each one removes some of the options.
- Are you measuring or counting? Measurements on a continuous scale (length, time, weight, temperature) are variables data. Counts of nonconforming items or defects are attribute data.
- For variables data, can you take several measurements under the same conditions at about the same time? If yes, those measurements form a rational subgroup, and you use X-bar and R. If you get one value per time point, you use I-MR.
- For attribute data, what exactly are you counting? If each item is classed as good or bad, you are counting defective items and you use a p chart. If one item can have several defects, you are counting defects per unit and you use a u chart.
What each chart plots
| Chart | Data | What is plotted | Sample size | Spread estimate |
|---|---|---|---|---|
| I-MR | Variables | Each value, and the moving range of consecutive values | 1 | Average moving range |
| X-bar and R | Variables | Subgroup mean, and subgroup range | Constant, 2 to 10 | Average range |
| p | Attribute, defective items | Proportion defective | Can vary | From the binomial model |
| u | Attribute, defects | Defects per unit | Can vary | From the Poisson model |
The two variables charts estimate the spread from the data. The two attribute charts get it from a probability model, as long as the process follows that model. That difference matters in the pitfalls chapter, where extra variation breaks the model.
Question 1: variables or attribute data
Choose variables data when you can. A measurement carries more information than a pass/fail label.
Suppose a shaft must be 20.00 mm, plus or minus 0.05 mm. If you record only "in tolerance" or "out of tolerance", a shaft at 20.04 mm and one at 20.00 mm look the same. A variables chart would show the mean drifting toward the edge long before any shaft fails. A p chart shows nothing until shafts start failing.
Attribute charts are still the right tool in these cases:
- The characteristic is judged only as pass or fail, such as a label present or absent.
- You track an overall outcome, such as the share of invoices with an error.
- Counts are the natural unit, such as scratches on a panel or typos on a page.
Do not turn a measurement into pass/fail only to use a p chart. You lose information and need much larger samples to see the same shift.
Question 2: subgroups or individuals
The choice between I-MR and X-bar and R depends on the process, not on your preference. Ask whether you can take several measurements close together in time, from the same source and under the same conditions. If you can, use X-bar and R. If the process gives you one value per time point, use I-MR.
Use X-bar and R when:
- Several parts come off the line within a few minutes, and you can measure five consecutive parts every hour.
- Variation within a subgroup reflects only common causes, so it works as a yardstick for variation between subgroups.
Use I-MR when:
- Each value is a single batch result, such as the daily pH of a tank.
- Measurements are slow or costly, such as a destructive test or a monthly financial figure.
- Output is so uniform that several readings would only repeat each other, such as a continuous process with one reading per hour.
- You want to chart derived quantities such as cycle time per order.
Four edge cases come up often:
- Subgroups that are not rational. Suppose you measure five parts from five different machines and treat them as one subgroup. The range then includes machine-to-machine differences. The limits become too wide, and real shifts hide inside them. If the sources differ, chart each source separately, or use I-MR on each.
- Subgroup size. Sizes from 3 to 5 are typical. With n = 2 you could use X-bar and R, but I-MR gives similar information. For n above about 10, the range wastes information, and practitioners use an X-bar and S chart (standard deviation instead of range). That chart is outside this tutorial.
- Averaging individuals. Do not group unrelated individual readings (for example, every five consecutive days) only to get an X-bar chart. The averaging hides signals, and the days are not a rational subgroup.
- Non-constant subgroup size. The classic constants A2, D3, and D4 assume the same n in every subgroup. If n changes a lot, use limits calculated per subgroup, or switch to a chart designed for variable n.
Question 3: defective items or defects
This choice depends on what you count.
A defective item is a unit that fails as a whole. Each unit is good or bad, so the count of defectives out of n units follows a binomial model. The p chart plots d/n, the proportion defective.
A defect is one flaw. A single unit can have zero, one, or many, so there is no upper bound at the unit level. Counts of defects over a stated "area of opportunity" follow a Poisson model. The u chart plots c/n_u, defects per unit.
The area of opportunity decides whether a count can be compared across samples. Suppose you inspect 20 circuit boards one day and 25 the next. Raw counts of 12 and 15 defects say little. The rates (0.60 and 0.60 per board) can be compared. The u chart uses the rate so that samples of different size sit on one chart.
| Situation | Counted | Chart |
|---|---|---|
| Orders shipped late, out of orders shipped each day | Defective items | p |
| Scratches on each painted panel, over a day's panels | Defects | u |
| Patients readmitted within 30 days, out of discharges per month | Defective items | p |
| Data-entry errors per form, over the forms processed each week | Defects | u |
| Weld inspection with pass or fail per weld | Defective items | p |
| Pinholes found per meter of cable, over cable inspected per shift | Defects | u |
A quick test: can the same unit be counted twice? If one form can have three errors, the count is a defect count. If the unit is either good or bad, the count is a defective count.
If the sample size is the same every period, the np chart (count of defectives) and the c chart (count of defects) are alternatives. They carry the same information as p and u. The p and u charts work for both constant and varying sample sizes, which is why this tutorial covers them.
Sample size for attribute charts
Attribute charts need a large enough sample. The reason is that limits use a normal approximation, and the lower limit is floored at zero.
If the lower limit is zero, a drop in the defect rate can never produce a point below it. You then cannot detect an improvement with the limit alone. For a p chart the lower limit is positive only when
n > 9(1 - p̄) / p̄
For p̄ = 0.01 the sample size must exceed 9 × 0.99 / 0.01 = 891. A common rule of thumb for the approximation itself is that n·p̄ and n·(1 − p̄) should both be at least 5. For a u chart the same idea applies: the expected count per sample, n·ū, should be at least about 5.
The decision path as code
This function mirrors the diagram. It is useful for documenting a rule in a data pipeline. It does not replace judgment about whether subgroups are rational.
def choose_chart(kind, subgroup_size=1, counts=None):
"""Return the chart name for a data kind.
kind: "variable" or "attribute"
subgroup_size: number of measurements per time point (variables data)
counts: "defectives" or "defects" (attribute data)
"""
if kind == "variable":
if subgroup_size == 1:
return "I-MR"
if 2 <= subgroup_size <= 10:
return "X-bar and R"
if subgroup_size > 10:
return "X-bar and S (not covered here)"
raise ValueError("subgroup_size must be at least 1")
if kind == "attribute":
if counts == "defectives":
return "p"
if counts == "defects":
return "u"
raise ValueError("counts must be 'defectives' or 'defects'")
raise ValueError("kind must be 'variable' or 'attribute'")
print(choose_chart("variable", 1)) # I-MR
print(choose_chart("variable", 5)) # X-bar and R
print(choose_chart("attribute", counts="defectives")) # p
print(choose_chart("attribute", counts="defects")) # uimport numpy as np
def min_n_for_positive_lcl(p_bar):
"""Smallest n for which a p chart's lower control limit is above zero."""
return int(np.floor(9 * (1 - p_bar) / p_bar)) + 1
for p_bar in (0.01, 0.05, 0.10):
print(p_bar, min_n_for_positive_lcl(p_bar))For p̄ = 0.01, 0.05, and 0.10 this prints 892, 172, and 82. A defect rate of 1% needs more than 800 items per sample before the chart can signal an improvement.
Common selection mistakes
- Using a p chart for defects. If one unit can have several defects, "proportion" is not meaningful, and a ratio above 1 is possible. Use a u chart.
- Using X-bar and R with a mixed subgroup. Parts from different machines, shifts, or suppliers in one subgroup inflate the range and hide shifts between them.
- Using I-MR for everything. I-MR works on almost any variables data, but it is less sensitive to small shifts than X-bar and R with rational subgroups, and it is more affected by non-normal data. Use subgroups when you can form them.
- Charting too few points. With fewer than about 20 to 25 points, the limits are unstable. This is the topic of the baseline chapter.
- Charting a ratio of two measurements as an attribute. A percentage such as "yield" computed from weights is a variable and belongs on an I-MR chart, not a p chart. A p chart needs counts of items.
Exercise
For each situation, name the chart (I-MR, X-bar and R, p, or u) and give a one-sentence reason. (a) Every hour, a technician measures the fill volume of 4 consecutive bottles from one filler head. (b) Each day, a call center records how many of the day's calls were escalated, out of the day's total calls, which varies. (c) Each week, an editor counts the typographical errors in the pages published, and the number of pages varies. (d) Once a day, a lab records the viscosity of one batch.
Show answer
(a) X-bar and R. The values are measurements, and 4 consecutive bottles from one filler head form a rational subgroup. (b) p chart. Each call is escalated or not (a defective item), and the number of calls varies, which a p chart handles with per-period limits. (c) u chart. Each page can have several errors (defects), and the number of pages (the area of opportunity) varies. (d) I-MR. There is a single measurement per time point, so no subgroup can be formed.
Exercise
A p chart will monitor a process whose long-run defective rate is about 2%. The team plans to inspect 200 items per period. Will the chart be able to signal an improvement (a drop in the defect rate)? Show your calculation and say what you would change.
Show answer
The lower control limit is positive only if n > 9(1 - p̄) / p̄. Here that is 9 × 0.98 / 0.02 = 441. With n = 200 the calculated lower limit is p̄ - 3·sqrt(p̄(1 - p̄)/n) = 0.02 - 3 × sqrt(0.02 × 0.98 / 200) = 0.02 - 0.0297, which is negative, so the limit is set to 0. No point can fall below it, and an improvement cannot be signaled by the limit alone. To fix this, inspect more than 441 items per period (for example, 450 or more), or combine periods so each point covers a larger sample.