Can you trust the gauge?
Run a gauge R&R study to split measured variation into the parts, the instrument and the people, before you trust any chart built on it.
What runs in CodeSplash
- Gauge R&R study (crossed ANOVA method) Verified in Python and R
You will be able to
- Separate repeatability, reproducibility and part-to-part variation
- Read % study variation, % contribution and distinct categories
- Spot an operator × part interaction and say what to do about it
Read first
What you measure isn't what's there
ReadEvery chart in this unit sees the part plus the measurement error. If the gauge is noisy, it can blur a real signal, or make a good process look incapable.
A gauge R&RGauge R&RHow much of the measured variation comes from the measurement system instead of the parts. study separates three sources:
- Repeatability: one person, one part, measured repeatedly. The gauge.
- Reproducibility: differences between operators.
- Part-to-part: the real differences you want to see.
Here, 3 operators measured 10 parts, 3 times each.
Two scales
Checkpoint% contribution compares variances, and % study variation compares standard deviations. The guidelines use the second: under 10% is good, 10–30% marginal, over 30% unacceptable.
Check yourself
The gauge's share of variance is 0.0322. What is its share of the study variation, as a proportion? Give three decimals.
Show the answer
Answer: 0.179416586304014
√0.0322 = 0.179. Square roots make small variance shares look much larger, which is why a study can sound fine on one scale and only marginal on the other.
Read the study
In the appGauge R&R = 17.9% of study variation (marginal); 7 distinct categories (10 parts × 3 operators × 3 repeats).
- % study var (R&R)
- 17.942
- % contribution (R&R)
- 3.219
- Distinct categories
- 7
Plots
View data
| Measure | Source | Percent |
|---|---|---|
| contribution | Total gauge R&R | 3.219 |
| contribution | Repeatability | 1.576 |
| contribution | Reproducibility | 1.643 |
| contribution | Part-to-part | 96.781 |
| study_var | Total gauge R&R | 17.942 |
| study_var | Repeatability | 12.552 |
| study_var | Reproducibility | 12.820 |
| study_var | Part-to-part | 98.377 |
| tolerance | Total gauge R&R | 12.634 |
| tolerance | Repeatability | 8.839 |
| tolerance | Reproducibility | 9.027 |
| tolerance | Part-to-part | 69.275 |
View data
| Operator | Part | Measurement (mm) |
|---|---|---|
| Ana | P01 | 25.368 |
| Ana | P01 | 25.402 |
| Ana | P01 | 25.357 |
| Ben | P01 | 25.212 |
| Ben | P01 | 25.184 |
| Ben | P01 | 25.134 |
| Cleo | P01 | 25.129 |
| Cleo | P01 | 25.115 |
| Cleo | P01 | 25.180 |
| Ana | P02 | 24.474 |
| Ana | P02 | 24.653 |
| Ana | P02 | 24.473 |
| Ben | P02 | 24.327 |
| Ben | P02 | 24.651 |
| Ben | P02 | 24.713 |
| Cleo | P02 | 24.291 |
| Cleo | P02 | 24.325 |
| Cleo | P02 | 24.426 |
| Ana | P03 | 26.186 |
| Ana | P03 | 26.184 |
| Ana | P03 | 26.022 |
| Ben | P03 | 26.224 |
| Ben | P03 | 26.180 |
| Ben | P03 | 26.229 |
| Cleo | P03 | 26.186 |
| Cleo | P03 | 25.833 |
| Cleo | P03 | 25.850 |
| Ana | P04 | 27.057 |
| Ana | P04 | 27.307 |
| Ana | P04 | 27.071 |
| Ben | P04 | 27.431 |
| Ben | P04 | 27.292 |
| Ben | P04 | 27.328 |
| Cleo | P04 | 27.148 |
| Cleo | P04 | 27.025 |
| Cleo | P04 | 27.076 |
| Ana | P05 | 26.389 |
| Ana | P05 | 25.945 |
| Ana | P05 | 26.070 |
| Ben | P05 | 26.230 |
| Ben | P05 | 26.289 |
| Ben | P05 | 26.363 |
| Cleo | P05 | 26.306 |
| Cleo | P05 | 26.124 |
| Cleo | P05 | 26.132 |
| Ana | P06 | 26.083 |
| Ana | P06 | 26.263 |
| Ana | P06 | 26.259 |
| Ben | P06 | 26.516 |
| Ben | P06 | 26.436 |
| Ben | P06 | 26.639 |
| Cleo | P06 | 26.432 |
| Cleo | P06 | 26.368 |
| Cleo | P06 | 26.285 |
| Ana | P07 | 24.581 |
| Ana | P07 | 24.599 |
| Ana | P07 | 24.794 |
| Ben | P07 | 24.950 |
| Ben | P07 | 24.914 |
| Ben | P07 | 24.893 |
First 60 of 90 rows.
Two-way ANOVA with interaction
| Source | df | SS | MS | F | p |
|---|---|---|---|---|---|
| Part | 9 | 69.333 | 7.704 | 305.26 | < .001 |
| Operator | 2 | 0.6928 | 0.3464 | 13.725 | < .001 |
| Part × Operator | 18 | 0.4543 | 0.0252 | 1.817 | .044 |
| Repeatability | 60 | 0.8334 | 0.0139 | — | — |
| Total | 89 | 71.314 | — | — | — |
Variance components
| Source | Variance | % contribution | SD | Study var (6σ) | % study var | % tolerance |
|---|---|---|---|---|---|---|
| Total gauge R&R | 0.0284 | 3.219 | 0.1685 | 1.011 | 17.942 | 12.634 |
| Repeatability | 0.0139 | 1.576 | 0.1179 | 0.7071 | 12.552 | 8.839 |
| Reproducibility | 0.0145 | 1.643 | 0.1204 | 0.7222 | 12.820 | 9.027 |
| Operator | 0.0107 | 1.214 | 0.1035 | 0.6208 | 11.020 | 7.760 |
| Operator × Part | 0.0038 | 0.4291 | 0.0615 | 0.3690 | 6.550 | 4.613 |
| Part-to-part | 0.8532 | 96.781 | 0.9237 | 5.542 | 98.377 | 69.275 |
| Total variation | 0.8815 | 100 | 0.9389 | 5.633 | 100 | 70.418 |
- Interaction kept (p = 0.044, pooling threshold 0.25).
- ndc = ⌊√2 · σ_part / σ_R&R⌋.
The exact R script · R R version 4.5.1 (2025-06-13)
# Gauge R&R study (crossed ANOVA method)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method spc.gage_rr 1.0.1 · spec f59485008b899ddd
# Dataset: q1_gauge (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
library(codesplashr) # cs_spc_gage_rr(): twin of codesplash.quality.gage (AIAG / Minitab ANOVA method)
# Classic equivalent: SixSigma::ss.rr(var = y, part = part, appr = operator, data = df) or
# qualityTools::gageRR(); anova(lm(y ~ part * operator)) gives the same sums of squares.
# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/q1_gauge.parquet", col_select = c("Measurement (mm)", "Part", "Operator")))
n_input <- nrow(df)
df[["Part"]] <- factor(df[["Part"]], levels = c("P01", "P02", "P03", "P04", "P05", "P06", "P07", "P08", "P09", "P10")) # stored level order
df[["Operator"]] <- factor(df[["Operator"]], levels = c("Ana", "Ben", "Cleo")) # stored level order
df <- df[stats::complete.cases(df[c("Measurement (mm)", "Part", "Operator")]), , drop = FALSE] # listwise deletion
df[] <- lapply(df, function(x) if (is.factor(x)) droplevels(x) else x)
n_dropped <- n_input - nrow(df)
warnings <- list()
if (n_dropped > 0) {
warnings <- c(warnings, cs_warning("CS_W_ROWS_DROPPED", dropped = n_dropped, total = n_input))
}
if (n_input > 0 && nrow(df) == 0) cs_error("CS_E_NO_ROWS")
cs_check_finite_columns(df, c("Measurement (mm)", "Part", "Operator")) # infinite values stop the run (registry/errors.yaml)
# %% Study
y_name <- "Measurement (mm)"
y <- as.numeric(df[[y_name]])
part <- as.character(df[["Part"]])
operator <- as.character(df[["Operator"]])
# The crossed study needs two parts, two operators and two repeats (8 rows) and measurements that vary
# (registry/errors.yaml; the same checks in Python).
cs_check_rows(length(y), 8, "A gauge R&R study")
cs_check_groups(part, "Part", minimum = 2)
cs_check_groups(operator, "Operator", minimum = 2)
cs_check_not_constant(y, y_name)
res <- cs_spc_gage_rr(y, part, operator, alpha_int = 0.25, k = 6,
tolerance = 8)
comp <- setNames(res$components, vapply(res$components, `[[`, "", "source"))
has_tol <- !is.null(res$tolerance)
# %% Tables and charts
tables <- list(
list(key = "anova", title = paste0("Two-way ANOVA", if (res$pooled) " (interaction pooled into repeatability)" else " with interaction"),
columns = list(list(key = "source", label = "Source", type = "string"), list(key = "df", label = "df", type = "integer"),
list(key = "ss", label = "SS", type = "number"), list(key = "ms", label = "MS", type = "number"),
list(key = "f", label = "F", type = "number"), list(key = "p", label = "p", type = "pvalue")),
rows = res$anova),
list(key = "components", title = "Variance components",
columns = c(list(list(key = "source", label = "Source", type = "string"), list(key = "var", label = "Variance", type = "number"),
list(key = "pct_contribution", label = "% contribution", type = "number"), list(key = "sd", label = "SD", type = "number"),
list(key = "study_var", label = sprintf("Study var (%sσ)", format(res$k)), type = "number"),
list(key = "pct_study", label = "% study var", type = "number")),
if (has_tol) list(list(key = "pct_tolerance", label = "% tolerance", type = "number"))),
rows = res$components))
show <- c("Total gauge R&R", "Repeatability", "Reproducibility", "Part-to-part")
measures <- c(contribution = "pct_contribution", study_var = "pct_study")
if (has_tol) measures <- c(measures, tolerance = "pct_tolerance")
g <- do.call(rbind, lapply(names(measures), function(mn) data.frame(source = show, value = vapply(show, function(s) comp[[s]][[measures[[mn]]]], 0),
measure = mn, stringsAsFactors = FALSE)))
charts <- list(
cs_chart("components", "gage-components", "Components of variation",
list(source = cs_col("Source", g$source, "categorical"), value = cs_col("Percent", unname(g$value)),
measure = cs_col("Measure", g$measure, "categorical"))),
cs_chart("by-part", "interaction", sprintf("%s by part and operator", y_name),
list(y = cs_col(y_name, y), x = cs_col("Part", part, "categorical"), trace = cs_col("Operator", operator, "categorical"))))
# %% Result
ord <- c("Total gauge R&R", "Repeatability", "Reproducibility", "Operator", "Operator × Part", "Part-to-part", "Total variation")
grr <- comp[["Total gauge R&R"]]
values <- list(
parts = res$parts, operators = res$operators, replicates = res$replicates, pooled = res$pooled,
p_interaction = res$p_interaction, ndc = res$ndc,
var_components = I(vapply(ord, function(s) comp[[s]]$var, 0, USE.NAMES = FALSE)),
pct_contribution = I(vapply(ord, function(s) comp[[s]]$pct_contribution, 0, USE.NAMES = FALSE)),
pct_study = I(vapply(ord, function(s) comp[[s]]$pct_study, 0, USE.NAMES = FALSE)),
pct_tolerance = if (has_tol) I(vapply(ord, function(s) comp[[s]]$pct_tolerance, 0, USE.NAMES = FALSE)) else NULL,
anova_ss = I(vapply(res$anova, `[[`, 0, "ss")), anova_df = I(vapply(res$anova, `[[`, 0, "df")),
pct_study_grr = grr$pct_study, pct_study_grr_frac = grr$pct_study / 100, pct_contribution_grr_frac = grr$pct_contribution / 100
)
verdict <- if (grr$pct_study < 10) "acceptable" else if (grr$pct_study <= 30) "marginal" else "not acceptable"
summary <- sprintf("Gauge R&R = %.1f%% of study variation (%s); %d distinct categories (%d parts × %d operators × %d repeats).",
grr$pct_study, verdict, res$ndc, res$parts, res$operators, res$replicates)
if (res$ndc < 5) warnings <- c(warnings, "Fewer than 5 distinct categories: the gauge cannot separate parts well enough for process control (AIAG).")
cs_publish(list(
method = "spc.gage_rr",
methodVersion = "1.0.1",
title = "Gauge R&R study (crossed ANOVA method)",
engine = cs_engine_info("stats", "codesplashr"),
n = length(y),
summary = summary,
statistics = list(list(key = "pct_study_grr", label = "% study var (R&R)", value = grr$pct_study),
list(key = "pct_contribution_grr", label = "% contribution (R&R)", value = grr$pct_contribution),
list(key = "ndc", label = "Distinct categories", value = res$ndc, format = "integer")),
tables = tables,
charts = charts,
warnings = warnings,
notes = list(sprintf("Interaction %s (p = %s, pooling threshold %s).", if (res$pooled) "pooled" else "kept", format(signif(res$p_interaction, 3)),
format(0.25)), "ndc = ⌊√2 · σ_part / σ_R&R⌋."),
values = values
))
Gauge R&R = 17.9% of study variation (marginal); 7 distinct categories (10 parts × 3 operators × 3 repeats).
- % study var (R&R)
- 17.942
- % contribution (R&R)
- 3.219
- Distinct categories
- 7
To keep this page light, the plots are shown once, under the R tab.
Two-way ANOVA with interaction
| Source | df | SS | MS | F | p |
|---|---|---|---|---|---|
| Part | 9 | 69.333 | 7.704 | 305.26 | < .001 |
| Operator | 2 | 0.6928 | 0.3464 | 13.725 | < .001 |
| Part × Operator | 18 | 0.4543 | 0.0252 | 1.817 | .044 |
| Repeatability | 60 | 0.8334 | 0.0139 | — | — |
| Total | 89 | 71.314 | — | — | — |
Variance components
| Source | Variance | % contribution | SD | Study var (6σ) | % study var | % tolerance |
|---|---|---|---|---|---|---|
| Total gauge R&R | 0.0284 | 3.219 | 0.1685 | 1.011 | 17.942 | 12.634 |
| Repeatability | 0.0139 | 1.576 | 0.1179 | 0.7071 | 12.552 | 8.839 |
| Reproducibility | 0.0145 | 1.643 | 0.1204 | 0.7222 | 12.820 | 9.027 |
| Operator | 0.0107 | 1.214 | 0.1035 | 0.6208 | 11.020 | 7.760 |
| Operator × Part | 0.0038 | 0.4291 | 0.0615 | 0.3690 | 6.550 | 4.613 |
| Part-to-part | 0.8532 | 96.781 | 0.9237 | 5.542 | 98.377 | 69.275 |
| Total variation | 0.8815 | 100 | 0.9389 | 5.633 | 100 | 70.418 |
- Interaction kept (p = 0.044, pooling threshold 0.25).
- ndc = ⌊√2 · σ_part / σ_R&R⌋.
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Gauge R&R study (crossed ANOVA method)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method spc.gage_rr 1.0.1 · spec f59485008b899ddd
# Dataset: q1_gauge (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import numpy as np
import pandas as pd
import codesplash as cs
from codesplash.errors import check_groups, check_not_constant
from codesplash.quality import gage # twin of codesplashr::cs_spc_gage_rr (AIAG / Minitab ANOVA method)
# Classic equivalent in R: SixSigma::ss.rr(), qualityTools::gageRR(); in Python statsmodels' anova_lm on
# measurement ~ C(part) * C(operator) gives the same sums of squares.
# %% Data
df = pd.read_parquet("tests/parity/fixtures/q1_gauge.parquet", columns=["Measurement (mm)", "Part", "Operator"])
n_input = len(df)
df["Part"] = pd.Categorical(df["Part"], categories=["P01", "P02", "P03", "P04", "P05", "P06", "P07", "P08", "P09", "P10"]) # stored level order
df["Operator"] = pd.Categorical(df["Operator"], categories=["Ana", "Ben", "Cleo"]) # stored level order
df = df.dropna(subset=["Measurement (mm)", "Part", "Operator"]) # listwise deletion over the analysis columns
df["Part"] = df["Part"].cat.remove_unused_categories()
df["Operator"] = df["Operator"].cat.remove_unused_categories()
n_dropped = n_input - len(df)
warnings = []
if n_dropped:
warnings.append(cs.cs_warning("CS_W_ROWS_DROPPED", dropped=n_dropped, total=n_input))
if n_input and not len(df):
cs.cs_error("CS_E_NO_ROWS")
cs.check_finite_columns(df, ["Measurement (mm)", "Part", "Operator"]) # infinite values stop the run (registry/errors.yaml)
# %% Study
y_name = "Measurement (mm)"
y = df["Measurement (mm)"].to_numpy(dtype=float)
part = df["Part"].astype(str).tolist()
operator = df["Operator"].astype(str).tolist()
# The crossed study needs two parts, two operators and two repeats (8 rows) and measurements that vary
# (registry/errors.yaml; the same checks in R).
cs.check_rows(len(y), 8, "A gauge R&R study")
check_groups(part, "Part", minimum=2)
check_groups(operator, "Operator", minimum=2)
check_not_constant(y, y_name)
res = gage.gage_rr(y, part, operator, alpha_int=0.25, k=6, tolerance=8)
comp = {c["source"]: c for c in res["components"]}
# %% Tables and charts
tables = [{
"key": "anova", "title": "Two-way ANOVA" + (" (interaction pooled into repeatability)" if res["pooled"] else " with interaction"),
"columns": [{"key": "source", "label": "Source", "type": "string"}, {"key": "df", "label": "df", "type": "integer"},
{"key": "ss", "label": "SS", "type": "number"}, {"key": "ms", "label": "MS", "type": "number"},
{"key": "f", "label": "F", "type": "number"}, {"key": "p", "label": "p", "type": "pvalue"}],
"rows": [{"source": s, "df": d_, "ss": ss, "ms": ms, "f": f, "p": p} for s, d_, ss, ms, f, p in res["anova"]],
}, {
"key": "components", "title": "Variance components",
"columns": [{"key": "source", "label": "Source", "type": "string"}, {"key": "var", "label": "Variance", "type": "number"},
{"key": "pct_contribution", "label": "% contribution", "type": "number"}, {"key": "sd", "label": "SD", "type": "number"},
{"key": "study_var", "label": f"Study var ({res['k']:g}σ)", "type": "number"},
{"key": "pct_study", "label": "% study var", "type": "number"}]
+ ([{"key": "pct_tolerance", "label": "% tolerance", "type": "number"}] if res["tolerance"] else []),
"rows": res["components"],
}]
show = ["Total gauge R&R", "Repeatability", "Reproducibility", "Part-to-part"]
g_source, g_value, g_measure = [], [], []
for measure, key in (("contribution", "pct_contribution"), ("study_var", "pct_study")) + ((("tolerance", "pct_tolerance"),) if res["tolerance"] else ()):
for s in show:
g_source.append(s)
g_value.append(comp[s][key])
g_measure.append(measure)
charts = [cs.chart(
"components", "gage-components", "Components of variation",
{"source": cs.col("Source", g_source, "categorical"), "value": cs.col("Percent", g_value),
"measure": cs.col("Measure", g_measure, "categorical")},
), cs.chart(
"by-part", "interaction", f"{y_name} by part and operator",
{"y": cs.col(y_name, y.tolist()), "x": cs.col("Part", part, "categorical"), "trace": cs.col("Operator", operator, "categorical")},
)]
# %% Result
order = ["Total gauge R&R", "Repeatability", "Reproducibility", "Operator", "Operator × Part", "Part-to-part", "Total variation"]
grr = comp["Total gauge R&R"]
values = {
"parts": res["parts"], "operators": res["operators"], "replicates": res["replicates"], "pooled": res["pooled"],
"p_interaction": res["p_interaction"], "ndc": res["ndc"],
"var_components": [comp[s]["var"] for s in order], "pct_contribution": [comp[s]["pct_contribution"] for s in order],
"pct_study": [comp[s]["pct_study"] for s in order], "pct_tolerance": [comp[s]["pct_tolerance"] for s in order] if res["tolerance"] else None,
"anova_ss": [r[2] for r in res["anova"]], "anova_df": [r[1] for r in res["anova"]],
"pct_study_grr": grr["pct_study"], "pct_study_grr_frac": grr["pct_study"] / 100, "pct_contribution_grr_frac": grr["pct_contribution"] / 100,
}
verdict = "acceptable" if grr["pct_study"] < 10 else ("marginal" if grr["pct_study"] <= 30 else "not acceptable")
summary = (f"Gauge R&R = {grr['pct_study']:.1f}% of study variation ({verdict}); {res['ndc']} distinct categories "
f"({res['parts']} parts × {res['operators']} operators × {res['replicates']} repeats).")
warnings = list(warnings)
if res["ndc"] < 5:
warnings.append("Fewer than 5 distinct categories: the gauge cannot separate parts well enough for process control (AIAG).")
cs.publish({
"title": "Gauge R&R study (crossed ANOVA method)",
"engine": cs.engine_info("numpy", "scipy"),
"n": len(y),
"summary": summary,
"statistics": [
{"key": "pct_study_grr", "label": "% study var (R&R)", "value": grr["pct_study"]},
{"key": "pct_contribution_grr", "label": "% contribution (R&R)", "value": grr["pct_contribution"]},
{"key": "ndc", "label": "Distinct categories", "value": res["ndc"], "format": "integer"},
],
"tables": tables,
"charts": charts,
"warnings": warnings,
"notes": [f"Interaction {'pooled' if res['pooled'] else 'kept'} (p = {res['p_interaction']:.3g}, pooling threshold 0.25).",
"ndc = ⌊√2 · σ_part / σ_R&R⌋."],
"values": values,
})
By the guideline, this gauge is marginal, at 17.9% of study variation.
The number of distinct categories is 7: how many groups of parts the gauge can reliably tell apart. Common guidance asks for at least 5. Below that, the gauge can't support a variables chart.
With a tolerance, the card also shows % tolerance. That's a different question: can the gauge judge parts against the specification?
Do operators agree?
PredictPredict first
The operator × part interaction has p = .044. What does an interaction mean here?
Reveal
Operators disagree more on some parts than others. Perhaps one part is hard to seat in the fixture, or a procedure is ambiguous. A constant offset between operators is a main effect instead. Below the pooling threshold, the study keeps the interaction as part of reproducibility.
Check your understanding
CheckpointCheck yourself
Repeatability is large, and reproducibility is small. Where do you look first?
Show the answer
Answer: a
Repeatability is variation with the same person and part. If it dominates, the gauge itself needs attention. Large reproducibility points to people or procedure.
Check yourself
You choose ten parts for the study, all from one good batch, and they look almost identical. How does that affect % study variation?
Show the answer
Answer: b
Parts should cover the range the process really produces. A narrow set of parts makes any gauge look bad.
Check yourself
Put these in the order a process engineer works.
Show the answer
The order:
- Check the measurement system.
- Check that the process is stable on a control chart.
- Compute capability against the specification.
A chart built on a poor gauge can't be read, and capability needs a stable process.
Try it
In the appIn the Quality studio, choose Process monitoring and open the Gauge R&R step. It starts from your chart's dataset. Every operator should measure every part the same number of times, in random order, ideally without knowing which part it is.
Recap
Recap- A gauge study separates the instrument, the people and the parts.
- % study variation compares standard deviations, and % contribution compares variances.
- Check distinct categories, and choose parts that span the real range.
- Do this before you trust charts or capability.
Concepts in this lesson