Main Content

gagerr

Gage repeatability and reproducibility study

Description

gagerr(y,{part,operator}) performs a Gage repeatability and reproducibility (R&R) study on the measurements y, collected by operator on part.

gagerr(y,group) performs an R&R study on the measurements y, where the numeric identifiers for the parts and operators are contained in the first and second columns, respectively, of the matrix group.

gagerr(y,part) performs an R&R study on the measurements y, collected on part. Use this syntax when all measurements are collected by a single operator.

gagerr(tbl,yvar,partvar) performs an R&R study on the data in the table tbl, using the measurements in the yvar variable and the parts in the partvar variable. (since R2025a)

gagerr(tbl,yvar,partvar,opvar) performs an R&R study on the data in the table tbl, using the measurements in the yvar variable, the parts in the partvar variable, and the operators in the opvar variable. (since R2025a)

example

gagerr(___,Name=Value) specifies options using one or more name-value arguments in addition to any of the input argument combinations in the previous syntaxes. For example, you can specify whether to display a bar graph of results, and set the specification limits for the precision-to-tolerance ratio (PTR) calculation.

example

gagerr(ax,___) plots into the axes specified by ax instead of the current axes (gca). (since R2024a)

results = gagerr(___) returns the study results in results. If you specify tbl or OutputFormat="table", then results is a table. Otherwise, results is a matrix.

[results,stats] = gagerr(___) additionally returns the structure stats, which contains the number of distinct categories, the percentage of Gage R&R of total variations, the PTR, and the study variance multiplier. If you do not set the specification limits (Spec), the PTR value is NaN.

Examples

collapse all

Simulate a measurement data set by randomly generating 100 measurements y of three parts. Each measurement is collected by one of four randomly assigned operators.

rng(1234,"twister"); % For reproducibility
n = 100;
y = randn(n,1);                
part = randi([1,3],1,n);       
operator = randi([1,4],1,n);   

Perform a Gage repeatability and reproducibility (R&R) study on this data set using a mixed ANOVA model without interactions.

gagerr(y,{part,operator},RandomOperator=false)
         Source          Variance     PercentVariance     Sigma     StudyVariation    PercentStudyVariation
    _________________    _________    _______________    _______    ______________    _____________________

    Gage R&R               0.95348         99.251        0.97646        5.0288               99.625        
      Repeatability        0.95348         99.251        0.97646        5.0288               99.625        
      Reproducibility            0              0              0             0                    0        
    Part                 0.0071911        0.74854         0.0848       0.43672               8.6518        
    Total                  0.96067            100        0.98014        5.0477                             

Study Variation: 5.15*Sigma
Number of distinct categories (NDC):0
% of Gage R&R of total variations (PRR): 99.63
Note: The last column of the above table does not have to sum to 100%

Figure contains an axes object. The axes object with ylabel Percent contains 2 objects of type bar. These objects represent %Variance, %StudyVar.

The software displays information and a bar graph summarizing the study results. Each row of the table contains statistics for a different source of variability in the measurement data. In this data set, the dominant source of variability is repeatability (the variation in the measurement value on the same part, obtained by the same operator). This source is responsible for 99.25% of the total measurement variance, and 99.63% of the total measurement standard deviation. The number of distinct categories is 0, indicating that the measurement system is not capable of distinguishing any groups within the measurement data.

Simulate a measurement data set by randomly generating 100 measurements y of five parts by three operators named A, B, and C. Each part is measured by one operator only.

rng(1234,"twister"); % For reproducibility
n = 100;
y = randn(n,1);
parts = randi(5,1,n)';
operatorName = ["A","B","C","A","A"];
operators = operatorName(parts)';
tbl = table(y,parts,operators, ...
    VariableNames=["y","Part","Operator"]);

Display the top rows of the data set.

head(tbl)
       y        Part    Operator
    ________    ____    ________

    -0.94725     1        "A"   
     0.54015     3        "C"   
     -0.2166     1        "A"   
       1.189     5        "A"   
       1.317     2        "B"   
    -0.40563     1        "A"   
    -0.44491     3        "C"   
      1.3284     5        "A"   

Perform a Gage repeatability and reproducibility (R&R) study on this data set using a mixed ANOVA model where Part is nested in Operator. Display the ANOVA table in a figure, and set SigmaMultiplier=6 to perform a six-sigma study.

gagerr(tbl,"y","Part","Operator",Model="part-nested", ...
    DisplayANOVA="on",SigmaMultiplier=6)

Figure N-Way ANOVA contains objects of type uicontrol.

         Source          Variance    PercentVariance     Sigma     StudyVariation    PercentStudyVariation
    _________________    ________    _______________    _______    ______________    _____________________

    Gage R&R              0.96251        96.475         0.98108        5.8865               98.221        
      Repeatability       0.96251        96.475         0.98108        5.8865               98.221        
      Reproducibility           0             0               0             0                    0        
    Part                 0.035173        3.5255         0.18754        1.1253               18.776        
    Total                 0.99768           100         0.99884         5.993                             

Study Variation: 6.00*Sigma
Number of distinct categories (NDC):0
% of Gage R&R of total variations (PRR): 98.22
Note: The last column of the above table does not have to sum to 100%

Figure contains an axes object. The axes object with ylabel Percent contains 2 objects of type bar. These objects represent %Variance, %StudyVar.

The software displays information and a bar graph summarizing the study results. Each row of the table contains statistics for a different source of variability in the measurement data. In this data set, the dominant source of variability is repeatability (the variation in the measurement value on the same part, obtained by the same operator). This source is responsible for 96.475% of the total measurement variance, and 98.1% of the total measurement standard deviation. The number of distinct categories is 0, indicating that the measurement system is not capable of distinguishing any groups within the measurement data.

Input Arguments

collapse all

Measurements, specified as a numeric column vector.

Data Types: single | double

Parts, specified as a categorical, character, or string array, a logical or numeric column vector, or a cell array of character vectors. part must have the same size as y. Each element of part contains an identifier for the part associated with the corresponding measurement in y.

Data Types: categorical | char | string | logical | single | double | cell

Operators, specified as a categorical, character, or string array, a logical or numeric column vector, or a cell array of character vectors. operator must have the same size as y. Each element of operator contains an identifier for the operator that collects the corresponding measurement in y.

Data Types: categorical | char | string | logical | single | double | cell

Parts and operators, specified as an n-by-2 numeric matrix, where n is the length of y. The first and second columns of group contain numeric identifiers for the part and operator, respectively, corresponding to the measurements in y.

Data Types: single | double

Since R2025a

Input data, specified as a table. tbl must have a variable that contains the measurements, a variable that contains the parts, and (optionally) a variable that contains the operators.

Data Types: table

Since R2025a

Measurements variable, specified as a character or string array. yvar must be the name of the variable in tbl that contains the measurements.

Data Types: char | string

Since R2025a

Parts variable, specified as a character or string array. partvar must be the name of the variable in tbl that contains the parts.

Data Types: char | string

Since R2025a

Operators variable, specified as a character or string array. opvar must be the name of the variable in tbl that contains the operators. If you do not specify opvar, the software assumes that all measurements are obtained by a single operator.

Data Types: char | string

Axes for the plot, specified as an Axes object. If you do not specify ax, then gagerr creates the plot using the current axes. For more information on creating an Axes object, see axes.

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: results=gagerr(y,group,PrintTable="off") suppresses the command-line output.

Since R2025a

Study variance multiplier, specified as a positive scalar. gagerr uses SigmaMultiplier to calculate the study variance and the precision-to-tolerance ratio. The default value 5.15 corresponds to the number of standard deviations that span the middle 99% of a normally distributed population.

Example: SigmaMultiplier=6

Data Types: single | double

ANOVA model type, specified as one of the values in this table.

ValueDescription
"linear" (default)Main effects only
"interaction"Main effects plus two-factor interactions between operator and part
"nested"operator is nested in part. Use this model when operators are assigned to specific parts, and the operators measure only those specific parts. For more information, see Other ANOVA Models.

"part-nested" (since R2025a)

part is nested in operator. Use this model when each part is measured by a specific operator only. For more information, see Other ANOVA Models.

If you specify "linear" or "interaction", gagerr calls the anovan function with the specified value of Model.

If you specify "nested", gagerr calls anovan with model="linear" and nested=[0 0; 1 0].

If you specify "part-nested", gagerr calls anovan with model="linear" and nested=[0 1; 0 0].

If you specify part but do not specify operator in the call to gagerr, you cannot specify "interaction", "nested", or "part-nested".

Example: Model="interaction"

Data Types: char | string

Indicator for random operators, specified as a numeric or logical 1 (true) or 0 (false). If you specify RandomOperator=false, the software uses a mixed-effects model, where part is a random effect and operator is a fixed effect.

Example: RandomOperator=false

Data Types: logical

Lower and upper specification limits, specified as a two-element numeric vector. If you specify Spec, the software computes the precision-to-tolerance ratio (PTR) using the formula PTR=kσGRR/|(S2S1)|, where k is the value of SigmaMultiplier, σGRR is the Gage R&R standard deviation, and S1 and S2 are the first and second elements of Spec, respectively. If you do not specify Spec, PTR is NaN. For more information about PTR, see Gage R&R Study.

Example: Spec=[0.1 0.9]

Data Types: single | double

Since R2025a

Flag to display the ANOVA table, specified as "on" or "off". If you specify DisplayANOVA="on", the software displays the ANOVA table as a figure.

Example: DisplayANOVA="on"

Data Types: char | string

Flag to display the results output, specified as "on" or "off". For more information about the results output, see Gage R&R Study.

Example: PrintTable="off"

Data Types: char | string

Since R2025a

Results output format, specified as "table" or "matrix". The value of OutputFormat determines whether results is a table or a matrix. If you do not specify OutputFormat, then results is a matrix if you specify y, and a table if you specify tbl.

Example: OutputFormat="matrix"

Data Types: char | string

Flag to display a bar graph of the results, specified as "on" or "off". For more information about the bar graph results, see Gage R&R Study.

Example: PrintGraph="off"

Data Types: char | string

Output Arguments

collapse all

Study results, returned as a numeric matrix or a table. If results is a matrix, the rows contain metrics for individual sources of variability in the measurement system. If you specify tbl or OutputFormat="table", then results is a table. The rows of results (or row names, if results is a table) are described below. Depending on the other options you specify, some rows are not included when results is a table.

RowTable Row NameDescription
Gage R&RGageRRTotal measurement variation due to repeatability and reproducibility sources
RepeatabilityGage_RepeatabilityVariation in the measurements of the same part, collected by the same operator
ReproducibilityGage_ReproducibilityVariation in the measurements of the same part, collected by different operators
OperatorReproducibility_OperatorVariation in the measurements collected by the same operator
Part*OperatorReproducibility_PartandOperatorVariation in the measurements due to the two-factor interactions of parts and operators. The variation is zero unless Model is "interaction".
Part-to-partPartVariation among the set of parts
TotalTotalCombined Gage R&R and part-to-part variability. This row is not included when results is a matrix.

The columns or variables in results are described below. The variable Source is not included when results is a table.

Column or VariableDescription
SourceVariability source
VarianceVariance
PercentVariancePercentage of the total variance
SigmaStandard deviation (square root of the variance)
StudyVariationStudy variance, equal to SigmaMultiplier times the standard deviation
PercentStudyVariationPercentage of the total study variance

Summary statistics, returned as a structure with these fields:

  • ndc — Number of distinct categories

  • prr — Percentage of Gage R&R of total variations

  • ptr — Precision-to-tolerance ratio

  • SigmaMultiplier — Study variance multiplier

If you do not specify Spec, then ptr is NaN. For more information on the summary statistics, see Gage R&R Study.

More About

collapse all

References

[1] Burdick, Richard K., Connie M. Borror, and Douglas C. Montgomery. Design and Analysis of Gauge R&R Studies: Making Decisions with Confidence Intervals in Random and Mixed ANOVA Models. ASA-SIAM Series on Statistics and Applied Probability. Philadelphia, Pa. : Alexandria, Va: Society for Industrial Applied Mathematics ; American Statistical Association, 2005.

Version History

Introduced in R2006b

expand all