Statistical Quality Control Chart

Without doubt Quality Control (QC) and Quality Assurance (QA) are important aspects of almost every manufacturing or software product development. These functions would help businesses to produce quality products as it would be most practical and cost beneficial to plan, design and build quality into products at early stage of development process. To achive this seven basic tools for quality control are introduced, which Control Chart is one of them.

The basic function of control chart is to determine whether or not a process is stable. Upper and lower control limits (i.e. UCL and LCL) reflect the maximum and minimum acceptable values. The control limits are defined using standard statistical calculations and principals to eventually set up accetable means for a robust process. Basically, control limits help to identify the points at which corrective action need to be taken to avoid odd and unusual performance. A process is classified as out of control when a data point exceeds a control limit, or alternatively seven consecutive plot points are either above or below the mean.

Read Data

A small set of data consist of twenty observations is used to plot a basic x-bar chart when n=1 as single column in a table for the purpose of this exercise. The function ‘read.table’ is used to input the data.

chartdata <- read.table(header = FALSE, text ="
0.521
0.524
0.522
0.525
0.521
0.527
0.524
0.504
0.526
0.523
0.522
0.525
0.524
0.523
0.525
0.526
0.538
0.522
0.521
0.525")

Create x-bar chart when n=1

To plot the data using qcc package is an easy task. I noticed qcc package does not exist in RStudio version 3.4.4 and had to be installed first. The command “install packages(”qcc“)” was typed into the R console but it did not work. The other option is go to “Tools” menue, select “install packages…”, then type “qcc” and click install.

library(qcc)
## Package 'qcc' version 2.7
## Type 'citation("qcc")' for citing this R package in publications.
qcc(data = chartdata,
type = "xbar.one",
plot = TRUE) 

## List of 11
##  $ call      : language qcc(data = chartdata, type = "xbar.one", plot = TRUE)
##  $ type      : chr "xbar.one"
##  $ data.name : chr "chartdata"
##  $ data      : num [1:20, 1] 0.521 0.524 0.522 0.525 0.521 0.527 0.524 0.504 0.526 0.523 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ statistics: Named num [1:20] 0.521 0.524 0.522 0.525 0.521 0.527 0.524 0.504 0.526 0.523 ...
##   ..- attr(*, "names")= chr [1:20] "1" "2" "3" "4" ...
##  $ sizes     : int [1:20] 1 1 1 1 1 1 1 1 1 1 ...
##  $ center    : num 0.523
##  $ std.dev   : num 0.00504
##  $ nsigmas   : num 3
##  $ limits    : num [1, 1:2] 0.508 0.539
##   ..- attr(*, "dimnames")=List of 2
##  $ violations:List of 2
##  - attr(*, "class")= chr "qcc"

As demonstrated qcc produced a chart including other information such as control limits, mean and standard deviation. The unacceptable value is colour coded and shown as red.

Create x-bar chart when n>1

Similar approach is used to input the data but this time for 5 different samples (when n=5), and readings for each is represented in different column.

chartdata2 <- read.table(header = FALSE, text = "
0.05805     0.056040001 0.056949997 0.055489997 0.056920003
0.058160003 0.057119998 0.056250002 0.056690002 0.056470002
0.057459998 0.059109999 0.057830002 0.05711     0.058670003
0.0566      0.058039995 0.056240003 0.057660003 0.055900004
0.057919997 0.054440002 0.058419998 0.057370004 0.054500001
0.057299997 0.056370001 0.055539999 0.056800003 0.058280001
0.055460002 0.056229996 0.057959999 0.05491     0.058620002
0.05931     0.057420005 0.05519     0.05784     0.05649
0.057289999 0.058170002 0.057260002 0.056849997 0.05512000
0.056849997 0.056140003 0.057370003 0.055790003 0.05705
0.056370001 0.056700004 0.055620003 0.057399999 0.056559995
0.056180004 0.058189997 0.05626     0.056580003 0.057459997
0.056059997 0.055350001 0.057310003 0.05553     0.057990003
0.05762     0.058919998 0.058730002 0.056849997 0.057660002
0.058299999 0.055479997 0.056619998 0.058780003 0.05728")

When the data set is too large it would be easier to save all the data in a .csv file and thgen import into RStudio.

xbar_chart2 <- qcc(data = chartdata2,
type = "xbar",
sizes = 5,
title = "Sample X-bar Chart Title",
digits = 2,
plot = TRUE)

It is also possible to customise the charts visuality and set the backgropund and margins to different colours.

qcc.options(bg.margin = "white", bg.figure = "yellow")

And then the chart will look like as follow

xbar_chart2 <- qcc(data = chartdata2,
type = "xbar",
sizes = 5,
title = "Sample X-bar Chart Title",
digits = 2,
plot = TRUE)

Summary

The qcc is a great package, which helps users to get access to some useful statistical process control charts and quality tools. It can be used widely for monitoring and controlling manufacturing and business processes, as well as data gathering processes.

References

https://www.r-bloggers.com/producing-a-control-chart-in-r-an-application-in-analytical-chemistry/

http://blog.yhat.com/posts/quality-control-in-r.html

J. Marriott, How to make Schewhart control charts in R, Jan 2017 ```