Skip to content

GQuality & process · spc.gage_rr

Gauge R&R study (crossed ANOVA method)

How much of the measured variation comes from the measurement system?

Splits measurement variation into repeatability (the gauge), reproducibility (operators and the operator × part interaction) and part-to-part variation by two-way ANOVA (AIAG/Minitab method), with % contribution, % study variation, % tolerance and the number of distinct categories.

Verified in Python and R Python and R agree to 10 decimals

A real result

Example “Crossed”, recorded in both engines. In the app, “Try this example” loads it into Analyze.

Gauge R&R study (crossed ANOVA method)Recorded · Python and R agreeRecorded 2026-11-17 · 15 values compared
R

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

Plots

Components of variationHow much of the observed variation comes from the measurement system rather than the parts?
View data
MeasureSourcePercent
contributionTotal gauge R&R3.219
contributionRepeatability1.576
contributionReproducibility1.643
contributionPart-to-part96.781
study_varTotal gauge R&R17.942
study_varRepeatability12.552
study_varReproducibility12.820
study_varPart-to-part98.377
toleranceTotal gauge R&R12.634
toleranceRepeatability8.839
toleranceReproducibility9.027
tolerancePart-to-part69.275
Measurement (mm) by part and operatorDoes the effect of one factor depend on another?
View data
OperatorPartMeasurement (mm)
AnaP0125.368
AnaP0125.402
AnaP0125.357
BenP0125.212
BenP0125.184
BenP0125.134
CleoP0125.129
CleoP0125.115
CleoP0125.180
AnaP0224.474
AnaP0224.653
AnaP0224.473
BenP0224.327
BenP0224.651
BenP0224.713
CleoP0224.291
CleoP0224.325
CleoP0224.426
AnaP0326.186
AnaP0326.184
AnaP0326.022
BenP0326.224
BenP0326.180
BenP0326.229
CleoP0326.186
CleoP0325.833
CleoP0325.850
AnaP0427.057
AnaP0427.307
AnaP0427.071
BenP0427.431
BenP0427.292
BenP0427.328
CleoP0427.148
CleoP0427.025
CleoP0427.076
AnaP0526.389
AnaP0525.945
AnaP0526.070
BenP0526.230
BenP0526.289
BenP0526.363
CleoP0526.306
CleoP0526.124
CleoP0526.132
AnaP0626.083
AnaP0626.263
AnaP0626.259
BenP0626.516
BenP0626.436
BenP0626.639
CleoP0626.432
CleoP0626.368
CleoP0626.285
AnaP0724.581
AnaP0724.599
AnaP0724.794
BenP0724.950
BenP0724.914
BenP0724.893

First 60 of 90 rows.

Two-way ANOVA with interaction

SourcedfSSMSFp
Part969.3337.704305.26< .001
Operator20.69280.346413.725< .001
Part × Operator180.45430.02521.817.044
Repeatability600.83340.0139——
Total8971.314———

Variance components

SourceVariance% contributionSDStudy var (6σ)% study var% tolerance
Total gauge R&R0.02843.2190.16851.01117.94212.634
Repeatability0.01391.5760.11790.707112.5528.839
Reproducibility0.01451.6430.12040.722212.8209.027
Operator0.01071.2140.10350.620811.0207.760
Operator × Part0.00380.42910.06150.36906.5504.613
Part-to-part0.853296.7810.92375.54298.37769.275
Total variation0.88151000.93895.63310070.418
  • Interaction kept (p = 0.044, pooling threshold 0.25).
  • ndc = ⌊√2 · σ_part / σ_R&R⌋.
Python

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

SourcedfSSMSFp
Part969.3337.704305.26< .001
Operator20.69280.346413.725< .001
Part × Operator180.45430.02521.817.044
Repeatability600.83340.0139——
Total8971.314———

Variance components

SourceVariance% contributionSDStudy var (6σ)% study var% tolerance
Total gauge R&R0.02843.2190.16851.01117.94212.634
Repeatability0.01391.5760.11790.707112.5528.839
Reproducibility0.01451.6430.12040.722212.8209.027
Operator0.01071.2140.10350.620811.0207.760
Operator × Part0.00380.42910.06150.36906.5504.613
Part-to-part0.853296.7810.92375.54298.37769.275
Total variation0.88151000.93895.63310070.418
  • Interaction kept (p = 0.044, pooling threshold 0.25).
  • ndc = ⌊√2 · σ_part / σ_R&R⌋.

Do it in CodeSplash Run it on your own data, in Python or R, with the code to prove it.

Worked examples in the app

  • Crossedq1_gauge · measurement: Measurement (mm) · operator: Operator · part: Part
  • Pooledq1_gauge · measurement: Measurement (mm) · operator: Operator · part: Part
  • Keep interactionq1_gauge · measurement: Measurement (mm) · operator: Operator · part: Part
  • Degenerate constantq1_gauge · measurement: Measurement (mm) · operator: Operator · part: Part
  • Degenerate n3q1_gauge · measurement: Measurement (mm) · operator: Operator · part: Part
  • Degenerate single levelq1_gauge · measurement: Measurement (mm) · operator: Operator · part: Part
  • Degenerate huge cardinalityq1_gauge · measurement: Measurement (mm) · operator: Operator · part: Part

In the guides

Where it sits in the decision guides

  • Statistical optimization (regression, response surface) · DS & ML Decision Guide · Optimize / decide

What you need

Measurementnumeric · 1 column
Each repeated measurement of a part.
Partcategorical · 1 column
Identifies the part measured.
Operatorcategorical · 1 column
Identifies who (or which gauge) made the measurement.

Choices you make

hypothesis

Tolerance (USL − LSL)default —

Gives % tolerance.

options

Pool the interaction when p >default 0.25

Minitab's default 0.25; 0 always pools the interaction, 1 always keeps it.

Study variation multiplierdefault 6

6σ (Minitab) or 5.15σ (AIAG, 99%).

Checks and remedies

CodeSplash checks each testable assumption on every run and shows the result on the card; premises the data can’t test are marked. If a check fails, these are the ways forward.

  • Balanced crossed study

    Every operator measures every part the same number of times.

What it reports

parts
How much of the measured variation comes from the measurement system instead of the parts.
operators
How much of the measured variation comes from the measurement system instead of the parts.
replicates
How many times each operator measured each part. The repeats are what estimate repeatability.
pooled
How much of the measured variation comes from the measurement system instead of the parts.
p_interaction
How surprising your data would be if the null hypothesis were true, as a probability.
var_components
How much of the measured variation comes from the measurement system instead of the parts.
pct_contribution
How much of the measured variation comes from the measurement system instead of the parts.
pct_study
How much of the measured variation comes from the measurement system instead of the parts.
pct_tolerance
How much of the measured variation comes from the measurement system instead of the parts.
ndc
How much of the measured variation comes from the measurement system instead of the parts.
anova_ss
How much of the measured variation comes from the measurement system instead of the parts.
anova_df
How much independent information is left to estimate variability after fitting the model.
pct_contribution_grr_frac
% study variation and % contribution of gage R&R written as fractions (0.18 = 18%) for the summary.
pct_study_grr
Gage R&R spread as a percent of total study spread; under 10% is good, over 30% unacceptable (AIAG).
pct_study_grr_frac
% study variation and % contribution of gage R&R written as fractions (0.18 = 18%) for the summary.

Python and R

Python and R agree to 10 decimals (relative tolerance 1e-10). Python uses numpy, scipy, codesplash; R uses stats, nanoparquet, codesplashr.

Default traps between the two languages

  • Sums of squares from cell and marginal means in both engines; F p-values from scipy ↔ R pf.
Python

The exact script CodeSplash ran for example “Crossed” · 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,
})
R

The exact script CodeSplash ran for example “Crossed” · 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
))

Sources

  • Automotive Industry Action Group (2010). Measurement Systems Analysis (MSA) reference manual (4th ed.).
  • Montgomery, D. C., & Runger, G. C. (1993). Gauge capability and designed experiments. Part I: Basic methods. Quality Engineering, 6, 115–135.

From the CodeSplash method registry · spc.gage_rr v1.0.1.