Sub topic 8
The ANOVA Method and Variance Components
Prerequisites and purpose
This chapter assumes you know means, variance, standard deviation, basic normal distributions, and the difference between process variation and measurement error. It also assumes a crossed gage R&R design: every operator measures every part, usually more than once.
The analysis of variance (ANOVA) method separates observed variation into sources. It estimates how much variation comes from:
- Part-to-part differences.
- Operator differences.
- Part-by-operator interaction.
- Repeatability, which is variation between repeated measurements under the same conditions.
ANOVA is useful because it estimates variance components directly. It also tests whether operator effects or interaction effects are large enough to matter.
The crossed model
Let \(Y_{ijk}\) be the measurement for part \(i\), operator \(j\), and replicate \(k\). A balanced crossed model is:
\[ Y{ijk} = \mu + Pi + Oj + (PO){ij} + \epsilon_{ijk} \]
Here:
- \(\mu\) is the overall mean.
- \(P_i\) is the effect of part \(i\).
- \(O_j\) is the effect of operator \(j\).
- \((PO)_{ij}\) is the interaction between part and operator.
- \(\epsilon_{ijk}\) is repeatability error.
An interaction exists when operators measure the same parts differently. For example, one operator may measure large parts consistently higher than another, while the difference is small for small parts.
ANOVA calculations
For a study with \(p\) parts, \(o\) operators, and \(r\) replicates, calculate sums of squares for each source. Divide each sum of squares by its degrees of freedom to obtain a mean square.
| Source | Degrees of freedom | Mean square |
|---|---|---|
| Part | \(p-1\) | \(MS_P=SS_P/(p-1)\) |
| Operator | \(o-1\) | \(MS_O=SS_O/(o-1)\) |
| Interaction | \((p-1)(o-1)\) | \(MS_{PO}=SS_{PO}/[(p-1)(o-1)]\) |
| Repeatability | \(po(r-1)\) | \(MS_E=SS_E/[po(r-1)]\) |
For a balanced design, estimate the variance components as follows:
\[ \hat{\sigma}^2E = MSE \]
\[ \hat{\sigma}^2{PO} = \max\left(0,\frac{MS{PO}-MS_E}{r}\right) \]
\[ \hat{\sigma}^2O = \max\left(0,\frac{MSO-MS_{PO}}{pr}\right) \]
\[ \hat{\sigma}^2P = \max\left(0,\frac{MSP-MS_{PO}}{or}\right) \]
Repeatability is \(\hat{\sigma}^2_E\). Reproducibility is operator variance plus interaction variance. Gage R&R variance is repeatability plus reproducibility. Total variance is gage R&R variance plus part variance.
The maximum with zero prevents a negative estimate. A negative estimate means sampling noise made one mean square smaller than another. It does not represent negative physical variation.
> callout note > Do not interpret a large part mean square as measurement error. Parts should differ in a useful study. The question is how large the measurement-system components are compared with the part component.
A compact implementation
This function applies the balanced ANOVA formulas to an array shaped as parts, operators, and replicates.
import numpy as np
def gage_rr_anova(x):
p, o, r = x.shape
grand = x.mean()
part = x.mean(axis=(1, 2))
oper = x.mean(axis=(0, 2))
cell = x.mean(axis=2)
ss_p = o * r * np.sum((part - grand) ** 2)
ss_o = p * r * np.sum((oper - grand) ** 2)
ss_po = r * np.sum(
(cell - part[:, None] - oper[None, :] + grand) ** 2
)
ss_e = np.sum((x - cell[:, :, None]) ** 2)
ms_p = ss_p / (p - 1)
ms_o = ss_o / (o - 1)
ms_po = ss_po / ((p - 1) * (o - 1))
ms_e = ss_e / (p * o * (r - 1))
var_p = max(0, (ms_p - ms_po) / (o * r))
var_o = max(0, (ms_o - ms_po) / (p * r))
var_po = max(0, (ms_po - ms_e) / r)
return {
"part_variance": var_p,
"operator_variance": var_o,
"interaction_variance": var_po,
"repeatability_variance": ms_e,
"grr_variance": var_o + var_po + ms_e,
}
rng = np.random.default_rng(1)
x = rng.normal(10, 1, size=(10, 3, 2))
print(gage_rr_anova(x))The formulas assume a balanced, crossed study. Missing cells, unequal replication, or nested sampling require a model fitted with appropriate statistical software rather than these direct formulas.
Exercise
Why is the interaction variance estimated from \(MS{PO}-MSE\), rather than from \(MS_{PO}\) alone?
Show answer
The interaction mean square contains both interaction variation and repeatability variation. Subtracting \(MS_E\) removes the repeatability contribution before scaling by the number of replicates.