# Analyzing Gage Repeatability and Reproducibility with gageRR

    library(gageRR)

## Introduction

Analyzing measurement system error is a critical component of the manufacturing process in numerous industries. While a number of methods exist to analyze measurement error they can all be broadly described as repeatability and reproducibilty studies (often referred to as Gage R&R studies). Industries can then provide guidelines or limitations on the amount of error that is acceptable for a given product feature based on the outcome of a Gage R&R study.

The gageRR package provides two methods to analyze repeatability and reproducibility: Analysis of Variance (ANOVA) method and Average and Range method. These methods require a balanced study, that is the same number of repetitions and each operator and part combination.

This vignette explains the use of the package and demonstrates typical workflows.

## References

Three references were used for the development of this package:

1. “MSA Reference Manual”, 4th Edition, Chrysler Group LLC, Ford Motor Company, General Motors Corporation.

2. “Methods and formulas for gage R&R table in Crossed Gage R&R Study”1

3. “Six Sigma Study Guide”2

## Contents

1. Input Data
2. Average and Range Method
3. ANOVA Method
4. Gage Evaluations

## 1. Input Data

All functions within the gageRR package require the data to be formatted with one measurement per row. That is, each measurement for a serial number and operator combination should represent a single record.

    head(data)
    #>                SN    Operator Measure
    #> 1 SerialNumber_01 Operator_01  0.0173
    #> 2 SerialNumber_01 Operator_01  0.0151
    #> 3 SerialNumber_01 Operator_01  0.0173
    #> 4 SerialNumber_01 Operator_02  0.0163
    #> 5 SerialNumber_01 Operator_02  0.0155
    #> 6 SerialNumber_01 Operator_02  0.0175

## 2. Average and Range Method

The Average and Range Method allows for the calculation of repeatability and reproducibility but does not account for the interaction between the part and operator. Each variance component (VARCOMP) can be defined as follows:

### Repeatability

\[(\sum_{i=1}^a \sum_{j=1}^k \frac{R_{ij}}{a*k}) * \frac{1}{d_2} \]

Where:

a - Number of parts

k - Number of operators

\(R_{ij}\) - Range of measurements by operator j for part i

\(d_2\) - See Appendix C Table C1 (Ref 1) where g = a*k and m = number of replicates.

### Reproducibility

\[\sqrt{[X_{diff}* \frac{1}{d_2}] - \frac{Repeatability^2}{a*r} }\]

Where:

\(X_{diff} = max(\overline{x}_1...,\overline{x}_k) - min(\overline{x}_1...,\overline{x}_k)\)

a - Number of parts

r - Number of trials (or repetitions)

\(d_2\) - See Appendix C Table C1 (Ref 1) where g = 1 and m = number of operators.

### Part to Part

\[R_p * \frac{1}{d_2}\]

Where:

\(R_p\) - range of part average values

\(d_2\) - See Appendix C Table C1 (Ref 1) where g = 1 and m = number of parts.

### gageRR Average and Range Functions

Using the data object inspected above we can make these calculations as follows

    xbar_repeat(data, part = 'SN', operator = 'Operator', meas = 'Measure')
    #> [1] 1.083874e-06

    xbar_reproduce(data, part = 'SN', operator = 'Operator', meas = 'Measure')
    #> [1] 0

    part_to_part(data, part = 'SN', meas = 'Measure' )
    #> [1] 3.23824e-05

### Total Gage R&R / Total Variation

We can now calculate Total Gage R&R as:

\[ \sqrt{Repeatability^2 + Reproducibility^2}\]

And Total Variation as:

\[ \sqrt{Total Gage RR^2 + PartToPart^2}\]

### gageRR Average and Range VARCOMP Function

A summary list of these Average and Range VARCOMPS can be found with the following command:

    xbar_varcomps(data, part = 'SN', operator = 'Operator', meas = 'Measure')
    #> $total_grr
    #> [1] 1.083874e-06
    #>
    #> $repeatability
    #> [1] 1.083874e-06
    #>
    #> $reproducibility
    #> [1] 0
    #>
    #> $part_to_part
    #> [1] 3.23824e-05
    #>
    #> $total_var
    #> [1] 3.346627e-05

## 3. ANOVA Method

The Analysis of Variance Method allows us to take into account the interaction between the operator and the part. The first step is to calculate the sum of squares for the operator, part, total and equipments as follows:

\[SS_{Operator} = \sum_{i=1}^t(X_i - \overline{X})^2\]

\[SS_{Part} = \sum_{j=1}^p(X_j - \overline{X})^2\]

\[SS_{Total} = \sum_{i=1}^t \sum_{j=1}^p \sum_{m=1}^r(X_{ijm} - \overline{X})^2\]

\[SS_{Equipment} = \sum_{i=1}^t \sum_{j=1}^p \sum_{m=1}^r(X_{ijm} - \overline{X}_{ij})^2\]

Where:

t - Number of Operators

p - Number of Parts

r - Number of Repetitions (or trials)

The final sum of squares (Operator * Part) is calculated as:

\[SS_{Operator * Part} = SS _{Total} - (SS_{Operator} + SS_{Part} + SS_{Equipment})\]

### gageRR Sum of Squares Function

With the gageRR package we can calculate the sum of squares with the following command:

    ss_calcs(data, part = 'SN', operator = 'Operator', meas = 'Measure')
    #> $reps
    #> [1] 3
    #>
    #> $num_parts
    #> [1] 3
    #>
    #> $num_opers
    #> [1] 3
    #>
    #> $SS_oper_error
    #> [1] 1.488889e-07
    #>
    #> $SS_part_error
    #> [1] 0.0005494689
    #>
    #> $SS_equip_error
    #> [1] 2.081333e-05
    #>
    #> $SS_op_part_error
    #> [1] 2.508889e-06
    #>
    #> $SS_no_interaction
    #> [1] 2.332222e-05
    #>
    #> $SS_total_error
    #> [1] 0.00057294

Mean square values can now be found as:

\[MS_{Operator} = \frac{SS_{Operator}}{t-1}\]

\[MS_{Part} = \frac{SS_{Part}}{p-1}\]

\[MS_{Operator * Part} = \frac{SS_{Operator*Part}}{(t-1)(p-1)}\]

\[MS_{Equipment} = \frac{SS_{Equipment}}{t*p(r-1)}\]

Note that we can now calculate the F-Statistic for the Operator and Part interaction as:

\[\frac{MS_{Operator * Part}}{MS_{Equipment}}\]

If the p-value for this F-Statistic is less than 0.05 the interaction will be included as a VARCOMP, otherwise it’s assumed to be 0.

Our final ANOVA VARCOMPs are:

### Repeatability

\[\sigma^2_{Repeatability} = MS_{Equipment}\]

### Reproducibility

\[\sigma^2_{Reproducibility} = \frac{MS_{Operator} - MS_{Operator * Part}}{(r)(p)}\]

### Part to Part

\[\sigma^2_{Part-to-Part} = \frac{MS_{Part} - MS_{Operator * Part}}{(r)(t)}\]

### Total Gage R&R

\[\sigma^2_{Total-gageRR} = \sigma^2_{Repeatability} + \sigma^2_{Reproducibility}\]

### Total Variation

\[\sigma^2_{Total-VAR} =\sigma^2_{Total-gageRR} + \sigma^2_{Part-to-Part}\]

### gageRR ANOVA VARCOMP Functions

With the gageRR package we can calculate the ANOVA VARCOMPs with the following command:

    anova_var_calcs(data, part = 'SN', operator = 'Operator', meas = 'Measure')
    #> $total_grr
    #> [1] 1.060101e-06
    #>
    #> $repeatability
    #> [1] 1.060101e-06
    #>
    #> $reproducibility
    #> [1] 0
    #>
    #> $part_to_part
    #> [1] 3.045636e-05
    #>
    #> $total_var
    #> [1] 3.151646e-05

## Gage Evaluation

Regardless of the method used above (Average and Range of ANOVA), we can now calculate the following gage statistics:

Percent Contribution - Percentage of variation from each VARCOMP with respect to the total variation.

Standard Deviation - The square root of the VARCOMP.

Study Variation - Standard deviation for each source multiplied by 6 (where 6s represents the process standard deviation).

Percent Tolerance - Percentage of the tolerance band (if provided) that is taken up by the study variation for each component.

### gageRR Gage Evaluation Function

With the gageRR package we can produce a list of the gage evaluation tables as two dataframes with the following command:

    grr_calc(data, part = 'SN', operator = 'Operator', meas = 'Measure', LSL = NULL, USL = .04, method = 'anova')
    #> $VarianceComponents
    #>                      VarComp PercentContribution
    #> total_grr       1.060101e-06          0.03363642
    #> repeatability   1.060101e-06          0.03363642
    #> reproducibility 0.000000e+00          0.00000000
    #> part_to_part    3.045636e-05          0.96636358
    #> total_var       3.151646e-05          1.00000000
    #>
    #> $GageEval
    #>                      StdDev    StudyVar PercentStudyVar PercentTolerance
    #> total_grr       0.001029612 0.006177672       0.1834024        0.1544418
    #> repeatability   0.001029612 0.006177672       0.1834024        0.1544418
    #> reproducibility 0.000000000 0.000000000       0.0000000        0.0000000
    #> part_to_part    0.005518728 0.033112368       0.9830379        0.8278092
    #> total_var       0.005613952 0.033683713       1.0000000        0.8420928
    #>
    #> $NumDistinctCats
    #> [1] 7
    #>
    #> $AnovaTable
    #>             Df    Sum Sq   Mean Sq F value   Pr(>F)
    #> Operator     2 0.0000001 7.000e-08   0.064    0.938
    #> SN           2 0.0005495 2.747e-04 237.599 1.15e-13 ***
    #> Operator:SN  4 0.0000025 6.300e-07   0.542    0.707
    #> Residuals   18 0.0000208 1.160e-06
    #> ---
    #> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

1. moved to https://support.minitab.com/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/↩︎

2. moved to https://support.minitab.com/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/↩︎