Skip to content

Gage rnr model

daspi.anova.model.GageRnRModel(source, target, part, gage, u_av=None, u_gv=None, u_t=None, u_stab=None, u_obj=None, u_rest=None, fit_at_init=True)

Bases: LinearModel

A linear regression model for Gage Repeatability and Reproducibility (Gage R&R) analysis.

PARAMETER DESCRIPTION
source

Pandas DataFrame as tabular data in a long format used for the model.

TYPE: pandas DataFrame

target

Column name for source data holding the measurement values.

TYPE: str

part

Column name for the parts variable (unit under test).

TYPE: str

gage

The provided GageStudyModel instance contains the measurement system's statistics. This class corresponds to measurement system analysis type 1. To calculate the uncertainty for linearity, provide multiple reference parts in the GageStudyModel instance.

TYPE: GageStudyModel

u_av

Column name of the variable that identifies the operator for type 2 Gage R&R. If the operator has no influence (MSA Typ III) and was therefore not included in the data acquisition, set u_av to None. In this case, it is recommended to record multiple locations, multiple part holders, or other possible changes to the measuring system and specify them in u_gv. Default is None.

TYPE: str | None DEFAULT: None

u_gv

Specifies the measurement uncertainty of gage ss, which reflects the comparability of the measurement system. This uncertainty is determined based on the data. To account for this uncertainty, provide the column name containing the categorical variables for the different measurement systems, test nests, or similar. If not specified, the default value is 'None'.

TYPE: str | None DEFAULT: None

u_t

Indicates the measurement uncertainty related to temperature dependence. This uncertainty can be assessed using the data (Method A) or specified directly if known (Method B).

  • Method A: Enter the column name containing the categorical variables for different temperatures.
  • Method B: Specify a MeasurementUncertainty instance directly.

If neither method is applied, the default value is 'None'.

TYPE: MeasurementUncertainty | str | None DEFAULT: None

u_stab

Represents the measurement uncertainty related to the stability of the measurement system. This uncertainty is determined from the data. To include this uncertainty, enter the column name containing the categorical variables for the relevant conditions. If not specified, the default value is 'None'.

TYPE: str | None DEFAULT: None

u_obj

Specifies the measurement uncertainty associated with the inhomogeneity of the object. This uncertainty can be determined from the data (Method A) or directly specified if known (Method B).

  • Method A: Provide the column name containing the relevant categorical variables for calculation from the data.
  • Method B: Specify a MeasurementUncertainty instance directly.

If neither method is applied, the default value is 'None'.

TYPE: MeasurementUncertainty | str | None DEFAULT: None

u_rest

Accounts for uncertainties not covered by the parameters above. This parameter considers additional sources of uncertainty that may impact the overall measurement, such as environmental conditions, operator influences, or other unknown variables. If known, specify the uncertainty here; otherwise, the default value is 'None'.

TYPE: MeasurementUncertainty | None DEFAULT: None

fit_at_init

If True, the model is fitted at initialization. Otherwise, the model is fitted after calling the fit method. Default is True.

TYPE: bool DEFAULT: True

Examples:

If you run the following code in a Jupyter Notebook cell, all tables will be calculated and output in an HTML format:

import daspi as dsp
df = dsp.load_dataset('grnr_layer_thickness')
gage = dsp.GageStudyModel(
    source=df,
    target='result_gage',
    reference='reference',
    u_cal=df['U_cal'][0],
    tolerance=df['tolerance'][0],
    resolution=df['resolution'][0],)
rnr_model = dsp.GageRnRModel(
    source=df,
    target='result_rnr',
    part='part',
    gage=gage,
    u_av='operator')
rnr_model # or print(repr(rnr_model))
References

The calculations are done based on the following references:

[1] Dr. Bill McNeese, BPI Consulting, LLC (09.2012) https://www.spcforexcel.com/knowledge/measurement-systems-analysis-gage-rr/anova-gage-rr-part-2/

[2] Minitab, LLC (2025) https://support.minitab.com/de-de/minitab/help-and-how-to/quality-and-process-improvement/measurement-system-analysis/how-to/gage-study/crossed-gage-r-r-study/methods-and-formulas/gage-r-r-table/

[3] Curt Ronniger, Software für Statistik, Schulungen und Consulting (2025) https://www.versuchsmethoden.de/Mess-System-Analyse.pdf

[4] VDA Band 5, Mess- und Prüfprozesse. Eignung, Planung und Management (Juli 2021) 3. überarbeitete Auflage

part = part instance-attribute

Column name of the part (unit under test) variable.

has_operator = bool(u_av) instance-attribute

Indicates whether the model has an operator variable.

u_map = {old: new for old, new in (zip(u_old, u_new)) if isinstance(old, str)} instance-attribute

Dictionary for mapping original names of uncertainties in the source data to the uncertainty abbreviations used in the model.

n_levels = source[features].nunique().rename(self.u_map) instance-attribute

Series with the number of levels for each variable. The amount of replications are stored under equipment variation 'EV'.

n_samples property

The number of samples used in the Gage R&R study (read-only).

gage property

The provided GageModel instances contains the measurement system's statistics. This classes corresponds to measurement system analysis type 1 (read-only).

df_u property

Get the data frame with the whole uncertainty budget as the combination of the data frames of MS and MP (df_ums and df_ump). If the uncertainties are not calculated yet, the method uncertainties() is called (read-only).

df_ums property

Get the data frame with the measurement uncertainty of the measurement system as gage study type 1. If the uncertainties are not calculated yet, the method uncertainties() is called (read-only).

df_ump property

Get the data frame with the measurement uncertainty of the measurement process as gage study type 2 or 3. If the uncertainties are not calculated yet, the method uncertainties() is called (read-only).

k property writable

The coverage factor for the expanded measurement uncertainty.

interactions property

Get the interaction parameter names if interaction is present in the fitted model (read-only).

tolerance property

The tolerance of the specification (read-only).

u_evo property

Get the measurement uncertainty of the equipment variation (repeatability) on the object (read-only).

u_av property

Get the measurement uncertainty of the appraiser ss (comparability of operators) (read-only).

u_gv property

Get the measurement uncertainty of the gage ss (compareability of measurement system) (read-only).

u_ia property

Get the measurement uncertainty of the interaction (read-only).

u_t property

Get the measurement uncertainty of the temperature (read-only).

u_stab property

Get the measurement uncertainty of the stability over time (read-only).

u_obj property

Get the measurement uncertainty of the inhomogeneity of the object (read-only).

u_rest property

Get the measurement uncertainty of the remaining (read-only).

u_ms property

Get the measurement uncertainty of the measurement system (read-only).

u_mp property

Get the measurement uncertainty of the measurement process (read-only).

rnr(evaluate_ia='auto')

Get the Gage R&R analysis results as table.

The table contains the following rows:

  • R&R: The sum of repeatability and reproducibility.
  • EV: The repeatability component (Equipement Variation).
  • AV or GV: The reproducibility component (Appriser or Gage Variation).
  • Part: The part-to-part component.
  • Total: The sum of the repeatability, reproducibility, and part-to-part.

The table contains the following columns:

  • MS: The variance estimation.
  • MS/Total: The estimated variance divided by the total variance.
  • s: The standard deviation as square root of the variance.
  • 6s: The 6 times the standard deviation.
  • 6s/Total: The 6 times the standard deviation divided by the total 6 times the standard deviation.
  • 6s/Tolerance: The 6 times the standard deviation divided by the tolerance.
PARAMETER DESCRIPTION
evaluate_ia

Whether to include the interaction term in the analysis. If 'auto', the interaction term is included if it is significant. Otherwise, the interaction term is excluded and the model is refit without the interaction term.

TYPE: bool | Literal['auto'] DEFAULT: 'auto'

RETURNS DESCRIPTION
DataFrame

The Gage R&R analysis results as table.

Examples:

import daspi as dsp
df = dsp.load_dataset('grnr_layer_thickness')
gage = dsp.GageStudyModel(
    source=df,
    target='result_gage',
    reference='reference',
    u_cal=df['U_cal'][0],
    tolerance=df['tolerance'][0],
    resolution=df['resolution'][0],)
rnr_model = dsp.GageRnRModel(
    source=df,
    target='result_rnr',
    part='part',
    gage=gage,
    u_av='operator')
print(rnr_model.rnr())
                 MS  MS/Total         s        6s  6s/Total  6s/Tolerance
R&R    6.736111e-07   0.02248  0.000821  0.004924  0.149932      0.164148
EV     6.736111e-07   0.02248  0.000821  0.004924  0.149932      0.164148
AV     0.000000e+00   0.00000  0.000000  0.000000  0.000000      0.000000
Part   2.929174e-05   0.97752  0.005412  0.032473  0.988696      1.082437
Total  2.996535e-05   1.00000  0.005474  0.032844  1.000000      1.094812
Notes

The mean squarse used for the calculation of the variances are computed using the anova method. The variance components are then calculated as follows:

With interaction term:

\[ s^2_{EV} = MS_{EV} = MS_{residual} \]
\[ s^2_{operator} = \frac{MS_{operator} - MS_{IA}}{n_{parts} n_{replication}} \]
\[ s^2_{IA} = \frac{MS_{IA} - MS_{EV}}{n_{replication}} \]
\[ s^2_{Part} = \frac{MS_{Part} - MS_{IA}}{n_{operator} n_{replication}} \]
\[ s^2_{AV} = s^2_{operator} + s^2_{IA} \]

Without interaction term:

\[ s^2_{EV} = MS_{EV} = MS_{residual} \]
\[ s^2_{operator} = \frac{MS_{operator} - MS_{EV}}{n_{parts} n_{replication}} \]
\[ s^2_{part} = \frac{MS_{part} - MS_{EV}}{n_{operator} n_{replication}} \]

Variance summary:

\[ s^2_{RnR} = s^2_{EV} + s^2_{AV} \]
\[ s^2_{total} = s^2_{RnR} + s^2_{part} \]

uncertainties()

The uncertainties of the measurement system.

The table contains the following rows:

  • RE: Resolution uncertainty
  • BI: Bias uncertainty
  • EVR: Equipment variation on the Reference (repeatability)
  • MS: Measurement System uncertainty
  • EVO: Equipement Variation on the Object(repeatability)
  • AV: Appraiser Variation uncertainty
  • IA: Interaction uncertainty
  • MP: Measurement Process (or Precision) uncertainty

The table contains the following columns:

  • u: The measurement uncertainty for the respective components
  • U: The expanded uncertainty as k * u
  • Q: The Quality Indicator serves as a quality indicator for the measurement process, reflecting how well the measurement system performs in relation to the specified requirements and tolerances.
  • rank: The rank of the uncertainty component, where a lower rank indicates a more significant contribution to the overall uncertainty.
RETURNS DESCRIPTION
u

The uncertainties of the measurement system.

TYPE: DataFrame

Examples:

import daspi as dsp
df = dsp.load_dataset('grnr_layer_thickness')
gage = dsp.GageStudyModel(
    source=df,
    target='result_gage',
    reference='reference',
    u_cal=df['U_cal'][0],
    tolerance=df['tolerance'][0],
    resolution=df['resolution'][0],)
rnr_model = dsp.GageRnRModel(
    source=df,
    target='result_rnr',
    part='part',
    gage=gage,
    u_av='operator')
model.uncertainties()
print(model.df_u)
                u         U         Q  rank
CAL      0.000100  0.000200  0.013333   5.0
RE       0.000289  0.000577  0.038490   3.0
BI       0.000196  0.000393  0.026173   4.0
LIN      0.000000  0.000000  0.000000   NaN
EVR      0.000688  0.001377  0.091785   2.0
MS_REST  0.000000  0.000000  0.000000   NaN
MS       0.000723  0.001446  0.096371   NaN
EVO      0.000821  0.001641  0.109432   1.0
AV       0.000000  0.000000  0.000000   NaN
GV       0.000000  0.000000  0.000000   NaN
IA       0.000000  0.000000  0.000000   NaN
T        0.000000  0.000000  0.000000   NaN
STAB     0.000000  0.000000  0.000000   NaN
OBJ      0.000000  0.000000  0.000000   NaN
MP_REST  0.000000  0.000000  0.000000   NaN
MP       0.000850  0.001700  0.113305   NaN