# An Introduction to Acceptance Sampling and SPC with R

*2020-06-26*

# Preface

This book is an introduction to statistical methods used in monitoring, controlling and improving quality. Topics covered are: acceptance sampling; Shewhart control charts for Phase I studies; graphical and statistical tools for discovering and eliminating the cause of out-of-control-conditions; Cusum and EWMA control charts for Phase II process monitoring; design and analysis of experiments for process troubleshooting and discovering ways to improve process output; and multivariate control charts for Phase I and Phase II studies with multiple Quality characteristics. Origins of statistical quality control is presented in Chapter 1, and the technical topics presented in the remainder of the book are those recommended in the ANSI/ASQ/ISO guidelines and standards for industry. The final chapter ties everything together by discussing modern management philosophies that encourage the use of the technical methods presented earlier.

This would be a suitable book for a one-semester undergraduate course emphasizing statistical quality control for engineering majors (such as manufacturing engineering, or industrial engineering), or a supplemental text for a graduate engineering course that included quality control topics.

A unique feature of this quality control book, is that it can be read free online at https://bookdown.org/home/authors/ by scrolling to the author’s name (John Lawson). A physical copy of the book will also available from CRC Press.

Prerequisites for students would be an introductory course in basic statistics with a calculus prerequisite and some experience with personal computers and basic programming. For students wanting a review of basic statistics and probability, the book *Introduction to Probability and Statistics Using R* by (Kerns 2011) is available free online at (https://archive.org/details/IPSUR). A review of Chapters 3 (Data Description), 4 (Probability), 5 (Discrete Distributions), 6 (Continuous Distributions), 8 (Sampling Distributions), 9 (Estimation), 10 (Hypothesis Testing), and 11 (Simple Linear Regression) will provide adequate preparation for this book.

In this book, emphasis is placed on using computer software for calculations. However, unlike most other quality control textbooks that illustrate the use of hand calculations and commercial software, this book illustrates the use of the open source R software (like books by Cano et. al.(E. L. Cano, Mogguerza, and Redchuck 2012) and Cano et. al.(Cano, Mogguerza, and Corcoba 2015)). Kerns’s book (Kerns 2011), mentioned above, also illustrates the use of R for probability and statistical calculations. Data sets from standard quality control textbooks are used as examples throughout this book so that the interested reader can compare the output from R to the hand calculations or output of commercial software shown in the other books.

As an open source high-level programming language with flexible graphical output options, R runs on Windows, Mac and Linux operating systems, and has add-on packages that equal or exceed the capabilities of commercial software for statistical methods used in quality control. It can be downloaded free from the Comprehensive R Archive Network (CRAN) https://cran.r-project.org/. The RStudio Integrated Development Environment (IDE) provides a command interface and GUI. A basic tutorial on RStudio is available at http://web.cs.ucla.edu/~gulzar/rstudio/basic-tutorial.html. Additionally Chester Ismay’s book *Getting used to R, RStudio, and R* provides more details for new users of R and RStudio. It can also be read online free by scrolling down to the author’s name (Chester Ismay) on https://bookdown.org/home/authors/, and a pdf version is also available. RStudio can be downloaded from https://www.rstudio.com/products/rstudio/download/. Instructions for installing R and RStudio on Windows, Mac and Linux operating systems can be found at https://socserv.mcmaster.ca/jfox/Courses/R/ICPSR/R-install-instructions.html.

The R packages illustrated in this book are (Kiermeier 2019), (Lawson 2020a), (Lawson 2020b),(Groemping 2019a), (Groemping 2019b), , (Scrucca 2017), (Roth 2016), (Knoth 2019), \(\verb!spcadjust!\)(Gandy and Kvaloy 2015), \(\verb!SixSigma!\)(E. Cano et al. 2012), and \(\verb!qicharts!\)(Anhoej 2017). At the time of this writing, all the R packages illustrated in this book are available on the Comprehensive R Archive Network. The latest version (3.0) of the is illustrated in this book. The input and output of qcc version 2.7 (that is on CRAN) is slightly different. The latest version (3.0) of can be installed from GitHub at https://luca-scr.github.io/qcc/ using devtools::install_github(“luca-scr/qcc”,build_vignettes = TRUE)

For students with no experience with R, an article giving a basic introduction to R can be found at https://www.red-gate.com/simple-talk/dotnet/software-tools/r-basics/. Chapter 2 of *Introduction to Probability and Statistics using R* by (Kerns 2011) is also an introduction to R, as well as the pdf book *R for Beginners* by Emmanuel Paradis can be downloaded from https://cran.r-project.org/doc/contrib/Paradis-rdebuts_en.pdf.

**Acknowledgements**
Many thanks to suggestions for improvements given by authors of R packages illustrated in this book, namely Andreas Kiemeier author the package, Luca Scrucca autor of the package, Ulrike Groemping author of the and packages. Also thanks to suggestions from students in my Quality Control class and editing help from my wife Dr. Francesca Lawson.

**About the author** John Lawson is a Professor Emeritus from the Statistics Department at Brigham Young University where he taught from 1986-2019. He is an ASQ-CQE and he has a Masters Degree in Statistics from Rutgers University and a PhD in Applied Statistics from the Polytechnic Institute of N.Y. He worked as a statistician for Johnson & Johnson Corporation from 1971 to 1976, and he worked at FMC Corporation Chemical Division from 1976 to 1986 where he was the Manager of Statistical Services. He is the author of *Design and Analysis of Experiments with R*, CRC Press, and the co-author (with John Erjavec) of *Basic Experimental Strategies and Data Analysis for Science and Engineering*, CRC Press.

If you notice errors or have suggestions for improvement to this e-book please contact John Lawson (lawsonjsl7net@gmail.com).

### References

Anhoej, J. 2017. *Qicharts: Quality Improvement Charts*. https://CRAN.R-project.org/package=qicharts.

Cano, E. L., J. M. Mogguerza, and M. P. Corcoba. 2015. *Quality Control with R - an Iso Standards Approach*. New York, N.Y: Springer.

Cano, E. L., J. M. Mogguerza, and A. Redchuck. 2012. *Six Sigma with R - Statistical Engineering for Process Improvement*. New York, N.Y: Springer.

Cano, E., J. Moguerza, M. Prieto, and A. Redchuk. 2012. *SixSigma:Six Sigma Tools for Quality Control and Improvement*. https://CRAN.R-project.org/package=SixSigma.

Gandy, A., and J. T. Kvaloy. 2015. *Spcadjust: Functions for Calibrating Control Charts*. https://CRAN.R-project.org/package=spcadjust.

Groemping, U. 2019a. *DoE.base: Full Factorials, Orthogonal Arrays and Base Utilities for Doe*. https://CRAN.R-project.org/package=DoE.base.

Groemping, U. 2019b. *FrF2: Fractional Factorial Designs with 2-Level Factors*. https://CRAN.R-project.org/package=FrF2.

Kerns, G. J. 2011. *Introduction to Probability and Statistics Using R*. G. J. Kerns.

Kiermeier, A. 2019. *AcceptanceSampling: Creation and Evaluation of Acceptance Sampling Plans*. https://CRAN.R-project.org/package=AcceptanceSampling.

Knoth, S. 2019. *Spc: Statistical Process Control – Calculation of Arl and Other Control Chart Performance Measures*. https://CRAN.R-project.org/package=spc.

Lawson, J. 2020a. *AQLSchemes: AQL Based Acceptance Sampling Schemes*. https://CRAN.R-project.org/package=AQLSchemes.

Lawson, J. 2020b. *Daewr: Design and Analysis of Experiments with R*. https://CRAN.R-project.org/package=daewr.

Roth, T. 2016. *Qcc: Statistical Methods for Quality Science*. https://CRAN.R-project.org/package=qualityTools.

Scrucca, L. 2017. *Qcc: Quality Control Charts*. https://CRAN.R-project.org/package=qcc.