# An Introduction to Acceptance Sampling and SPC with R

*2020-01-07*

# Preface

This e-book was originally written for Stat 462 (Quality Control)(see Description) taught in the Statistics Department at Brigham Young University. It is free to read online here, and is licensed inder the Creative Commons Attribution-NonComercial-ShareAlike 4.0 International License (http://creativecommons.org/licenses/by-nc-sa/4.0/) One of the objectives of Stat 462 is to prepare students to pass the ASQ Certified Quality Process Analyst Exam. The book *The Certified Quality Process Analyst Handbook* by (Christensen, Betz, and Stein 2013) will prepare students for the Exam that is given by the American Society for Quality through Prometrix. That handbook shows the mechanics of using the published tables to create sampling plans and demonstrates how to use tables and hand calculations to create the limits for Shewhart style control charts and process capability indices. It shows how these and other quality tools and statistical methods are elements of system for improving and controlling quality that is used in industry today. For readers unfamiliar with how statistical and basic quality tools are part of a quality management system, it is recommended that this book be supplemented by the book by [Christensen, Betz, and Stein (2013) or (Ishikawa 1982).

In the modern, world sampling plans and the statistical calculations used in statistical quality control are done with the help of computers. To get more hands on experience in creating acceptance sampling plans and control charts necessarily involves the use of software. In industry, commercial software such as Minitab\(^{TM}\), SAS and StatGraphics\(^{TM}\) are often used. In this book we will focus on several R packages that can duplicate and in some cases exceed the functionality of these commercial programs. The R packages illustrated in this book are \(\verb!AcceptanceSampling!\)(Kiermeier 2019), \(\verb!AQLSchemes!\)(J. Lawson 2019), \(\verb!daewr!\)(Lawson 2016),\(\verb!DoE.Base!\)(Groemping 2019a), \(\verb!FrF2!\)(Groemping 2019b), \(\verb!qcc!\)(Scrucca 2017), \(\verb!qualityTools!\)(Roth 2016), \(\verb!spc!\)(Knoth 2019), and \(\verb!spcadjust!\)(Gandy and Kvaloy 2015). R is open source software and runs on Windows, Mac and Linux operating systems. In addition to demonstrating how to use R for acceptance sampling and control charts, this book will focus on how the use of these specific tools can lead to quality improvements both within a company and within their supplier companies. The prerequisites for this e-book are an introductory statistics course (Stat 121 or Stat 201 at BYU), two semesters of probability (Stat 240 and 340 at BYU at a level similar to that presented in (Carlton and Devore 2017)), and a course on the introduction to R programming (Stat 123 at BYU).

For readers 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 workbook. Additionally (Kerns 2011)’s book illustrates the use of R for probability and statistical calculations.

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.

R can be downloaded from the Comprehensive R Archive Network (CRAN) Click Here. 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. 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 http://socserv.mcmaster.ca/jfox/Courses/R/ICPSR/R-install-instructions.html. At the time of this writing, all the R packages illustrated in this book are available on from the Comprehensive R Archive Network (CRAN) except \(\verb!AQLSchemes!\) which can be installed from R forge with the command \(\verb!install.packages("AQLSchemes", repos="http://R-Forge.R-project.org")!\), The latest version (3.0) of the \(\verb!qcc!\) package is illistrated in this book. The input and output of \(\verb!qcc!\) version 2.7 (that is on CRAN) is slightly different. The latest version (3.0) of \(\verb!qcc!\) can be installed from GitHub at \(\verb!https://luca-scr.github.io/qcc/!\)

\(\verb!using devtools::install_github("luca-scr/qcc",build_vignettes = TRUE)!\).

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

**About the author** John Lawson is a Professor in the Statistics Department at Brigham Young University where he has been since 1986. 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 (lawson@stat.byu.edu).

### References

Carlton, M. A., and J. L. Devore. 2017. *Probability with Applications in Engineering, Science, and Technology*. 2nd ed. Switzerland: Springer.

Christensen, C., K.M. Betz, and M.S. Stein. 2013. *The Certified Quality Process Analyst Handbook*. 2nd ed. Milwaukee, Wisconsin: ASQ Quality Press.

Gandy, A., and J. T. Kvaloy. 2013. “Guarranteed Conditional Performance of Control Charts via Bootstrap Methods.” *Scandinavian Journal of Statistics* 40: 647–68.

*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.

Ishikawa, K. 1982. *A Guide to Quality Control*. 2nd ed. Tokyo: Asian Productivity Organization.

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. 2016. *Daewr: Design and Analysis of Experiments with R*. https://CRAN.R-project.org/package=daewr.

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

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.