Quality Control Charts Part 1

Shewhart quality control charts for continuous, attribute and count data. Cusum and EWMA charts. Operating characteristic curves. Process capability analysis. Pareto chart and cause-and-effect chart. Multivariate control charts.

Temperature readings from the eight configured burners on a boiler.

library(qcc)
## Package 'qcc' version 2.7
## Type 'citation("qcc")' for citing this R package in publications.
data(boiler)
summary(boiler)
##        t1            t2              t3              t4       
##  Min.   :507   Min.   :509.0   Min.   :527.0   Min.   :512.0  
##  1st Qu.:520   1st Qu.:512.0   1st Qu.:537.0   1st Qu.:518.0  
##  Median :527   Median :514.0   Median :540.0   Median :523.0  
##  Mean   :525   Mean   :513.6   Mean   :538.9   Mean   :521.7  
##  3rd Qu.:530   3rd Qu.:515.0   3rd Qu.:542.0   3rd Qu.:525.0  
##  Max.   :536   Max.   :518.0   Max.   :546.0   Max.   :530.0  
##        t5              t6              t7              t8       
##  Min.   :497.0   Min.   :508.0   Min.   :471.0   Min.   :472.0  
##  1st Qu.:502.0   1st Qu.:511.0   1st Qu.:476.0   1st Qu.:476.0  
##  Median :504.0   Median :512.0   Median :480.0   Median :477.0  
##  Mean   :503.8   Mean   :512.4   Mean   :478.7   Mean   :477.2  
##  3rd Qu.:507.0   3rd Qu.:514.0   3rd Qu.:482.0   3rd Qu.:478.0  
##  Max.   :509.0   Max.   :517.0   Max.   :483.0   Max.   :481.0
boxplot(boiler)

cause.and.effect

cause.and.effect(cause=list(Measurements=c("Micrometers", "Microscopes", "Inspectors"),
                            Materials=c("Alloys", "Lubricants", "Suppliers"),
                            Personnel=c("Shifts", "Supervisors", "Training", "Operators"),
                            Environment=c("Condensation", "Moisture"),
                            Methods=c("Brake", "Engager", "Angle"),
                            Machines=c("Speed", "Lathes", "Bits", "Sockets")),
                 effect="Surface Flaws")

Circuit boards data

Number of nonconformities observed in 26 successive samples of 100 printed circuit boards. Sample 6 and 20 are outside the control limits. Sample 6 was examined by a new inspector and he did not recognize several type of nonconformities that could have been present. Furthermore, the unusually large number of nonconformities in sample 20 resulted from a temperature control problem in the wave soldering machine, which was subsequently repaired. The last 20 samples are further samples collected on inspection units (each formed by 100 boards).

data(circuit)
attach(circuit)
summary(circuit)
##        x              size       trial        
##  Min.   : 5.00   Min.   :100   Mode :logical  
##  1st Qu.:16.00   1st Qu.:100   FALSE:20       
##  Median :19.00   Median :100   TRUE :26       
##  Mean   :19.17   Mean   :100                  
##  3rd Qu.:22.00   3rd Qu.:100                  
##  Max.   :39.00   Max.   :100
boxplot(x ~ trial)

plot(x, type="b")

detach(circuit)

Cusum chart for statistical quality control

##
## Grouped-data
##
data(pistonrings)
attach(pistonrings)
diameter <- qcc.groups(diameter, sample)
q <- cusum(diameter[1:25,], decision.interval = 4, se.shift = 1)

summary(q)
## 
## Call:
## cusum(data = diameter[1:25, ], decision.interval = 4, se.shift = 1)
## 
## cusum chart for diameter[1:25, ] 
## 
## Summary of group statistics:
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   73.99   74.00   74.00   74.00   74.00   74.01 
## 
## Group sample size:  5
## Number of groups:  25
## Center of group statistics:  74.00118
## Standard deviation:  0.009785039 
## 
## Decision interval (std.err.): 4 
## Shift detection  (std. err.): 1
q <- cusum(diameter[1:25,], newdata=diameter[26:40,])

summary(q)
## 
## Call:
## cusum(data = diameter[1:25, ], newdata = diameter[26:40, ])
## 
## cusum chart for diameter[1:25, ] 
## 
## Summary of group statistics:
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   73.99   74.00   74.00   74.00   74.00   74.01 
## 
## Group sample size:  5
## Number of groups:  25
## Center of group statistics:  74.00118
## Standard deviation:  0.009785039 
## 
## Summary of group statistics in diameter[26:40, ]:
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## 73.99220 74.00290 74.00720 74.00765 74.01270 74.02340 
## 
## Group sample size:  5
## Number of groups:  15 
## 
## Decision interval (std.err.): 5 
## Shift detection  (std. err.): 1
plot(q, chart.all=FALSE)

detach(pistonrings)

Dyed cloth data

In a textile finishing plant, dyed cloth is inspected for the occurrence of defects per 50 square meters. The data on ten rolls of cloth are presented.

data(dyedcloth)
attach(dyedcloth)
summary(dyedcloth)
##        x              size      
##  Min.   : 7.00   Min.   : 8.00  
##  1st Qu.:11.25   1st Qu.:10.00  
##  Median :15.00   Median :10.25  
##  Mean   :15.30   Mean   :10.75  
##  3rd Qu.:19.75   3rd Qu.:12.00  
##  Max.   :23.00   Max.   :13.00
plot(x/size, type="b")

detach(dyedcloth)

EllipseChart Multivariate Quality Control Charts

Plot an ellipse chart for a bivariate quality control data.

##
##  Subgrouped data
##

# Ryan (2000, Table 9.2) data with p = 2 variables, m = 20 samples, n = 4 sample size:
X1 <- matrix(c(72, 56, 55, 44, 97, 83, 47, 88, 57, 26, 46, 
               49, 71, 71, 67, 55, 49, 72, 61, 35, 84, 87, 73, 80, 26, 89, 66, 
               50, 47, 39, 27, 62, 63, 58, 69, 63, 51, 80, 74, 38, 79, 33, 22, 
               54, 48, 91, 53, 84, 41, 52, 63, 78, 82, 69, 70, 72, 55, 61, 62, 
               41, 49, 42, 60, 74, 58, 62, 58, 69, 46, 48, 34, 87, 55, 70, 94, 
               49, 76, 59, 57, 46), ncol = 4)
X2 <- matrix(c(23, 14, 13, 9, 36, 30, 12, 31, 14, 7, 10, 
               11, 22, 21, 18, 15, 13, 22, 19, 10, 30, 31, 22, 28, 10, 35, 18, 
               11, 10, 11, 8, 20, 16, 19, 19, 16, 14, 28, 20, 11, 28, 8, 6, 
               15, 14, 36, 14, 30, 8, 35, 19, 27, 31, 17, 18, 20, 16, 18, 16, 
               13, 10, 9, 16, 25, 15, 18, 16, 19, 10, 30, 9, 31, 15, 20, 35, 
               12, 26, 17, 14, 16), ncol = 4)
X <- list(X1 = X1, X2 = X2)

q <- mqcc(X, type = "T2")

summary(q)
## 
## Call:
## mqcc(data = X, type = "T2")
## 
## T2 chart for X 
## 
## Summary of group statistics:
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.12429  1.32496  2.50272  6.47013  5.34912 63.76042 
## 
## Number of variables:  2
## Number of groups:  20
## Group sample size:  4
## 
## Center: 
##      X1      X2 
## 60.3750 18.4875 
## 
## Covariance matrix:
##          X1        X2
## X1 222.0333 103.11667
## X2 103.1167  56.57917
## |S|:  1929.414 
## 
## Control limits:
##  LCL      UCL
##    0 11.03976
ellipseChart(q)

ellipseChart(q, show.id = TRUE)

provides “robust” estimates of means and covariance matrix

q <- mqcc(X, type = "T2", pred.limits = TRUE)

# Ryan (2000) discussed Xbar-charts for single variables computed adjusting the 
# confidence level of the T^2 chart:
q1 <- qcc(X1, type = "xbar", confidence.level = q$confidence.level^(1/2))

summary(q1)
## 
## Call:
## qcc(data = X1, type = "xbar", confidence.level = q$confidence.level^(1/2))
## 
## xbar chart for X1 
## 
## Summary of group statistics:
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  40.000  54.000  61.375  60.375  68.250  81.250 
## 
## Group sample size:  4
## Number of groups:  20
## Center of group statistics:  60.375
## Standard deviation:  14.93443 
## 
## Control limits:
##       LCL      UCL
##  37.97352 82.77648
q2 <- qcc(X2, type = "xbar", confidence.level = q$confidence.level^(1/2))

summary(q2)
## 
## Call:
## qcc(data = X2, type = "xbar", confidence.level = q$confidence.level^(1/2))
## 
## xbar chart for X2 
## 
## Summary of group statistics:
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 10.5000 15.3750 19.0000 18.4875 21.5000 29.7500 
## 
## Group sample size:  4
## Number of groups:  20
## Center of group statistics:  18.4875
## Standard deviation:  7.139388 
## 
## Control limits:
##     LCL     UCL
##  7.7785 29.1965
require(MASS)
## Loading required package: MASS
# generate new "in control" data
Xnew <- list(X1 = matrix(NA, 10, 4), X2 =  matrix(NA, 10, 4))
for(i in 1:4)
{ x <- mvrnorm(10, mu = q$center, Sigma = q$cov)
Xnew$X1[,i] <- x[,1]
Xnew$X2[,i] <- x[,2] 
}
qq <- mqcc(X, type = "T2", newdata = Xnew, pred.limits = TRUE)

summary(qq)
## 
## Call:
## mqcc(data = X, type = "T2", pred.limits = TRUE, newdata = Xnew)
## 
## T2 chart for X 
## 
## Summary of group statistics:
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.12429  1.32496  2.50272  6.47013  5.34912 63.76042 
## 
## Number of variables:  2
## Number of groups:  20
## Group sample size:  4
## 
## Center: 
##      X1      X2 
## 60.3750 18.4875 
## 
## Covariance matrix:
##          X1        X2
## X1 222.0333 103.11667
## X2 103.1167  56.57917
## |S|:  1929.414 
## 
## Summary of group statistics in Xnew:
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## 0.4084283 0.6578539 0.8933350 1.0497202 1.1809741 2.0547707 
## 
## Number of groups:  10
## Group sample size:  4
## 
## Control limits:
##  LCL      UCL
##    0 11.03976
## 
## Prediction limits:
##  LPL      UPL
##    0 12.20184
# generate new "out of control" data
Xnew <- list(X1 = matrix(NA, 10, 4), X2 =  matrix(NA, 10, 4))
for(i in 1:4)
{ x <- mvrnorm(10, mu = 1.2*q$center, Sigma = q$cov)
Xnew$X1[,i] <- x[,1]
Xnew$X2[,i] <- x[,2] 
}
qq <- mqcc(X, type = "T2", newdata = Xnew, pred.limits = TRUE)

summary(qq)
## 
## Call:
## mqcc(data = X, type = "T2", pred.limits = TRUE, newdata = Xnew)
## 
## T2 chart for X 
## 
## Summary of group statistics:
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.12429  1.32496  2.50272  6.47013  5.34912 63.76042 
## 
## Number of variables:  2
## Number of groups:  20
## Group sample size:  4
## 
## Center: 
##      X1      X2 
## 60.3750 18.4875 
## 
## Covariance matrix:
##          X1        X2
## X1 222.0333 103.11667
## X2 103.1167  56.57917
## |S|:  1929.414 
## 
## Summary of group statistics in Xnew:
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
##  0.152462  3.049907  6.203956  5.617799  6.980151 14.234999 
## 
## Number of groups:  10
## Group sample size:  4
## 
## Control limits:
##  LCL      UCL
##    0 11.03976
## 
## Prediction limits:
##  LPL      UPL
##    0 12.20184
##
## Individual observations data
##

data(boiler)

q <- mqcc(boiler, type = "T2.single", confidence.level = 0.999)

summary(q)
## 
## Call:
## mqcc(data = boiler, type = "T2.single", confidence.level = 0.999)
## 
## T2.single chart for boiler 
## 
## Summary of group statistics:
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
##  1.316342  5.305689  7.074224  7.680000  9.775744 17.575293 
## 
## Number of variables:  8
## Number of groups:  25
## Group sample size:  1
## 
## Center: 
##     t1     t2     t3     t4     t5     t6     t7     t8 
## 525.00 513.56 538.92 521.68 503.80 512.44 478.72 477.24 
## 
## Covariance matrix:
##            t1        t2        t3         t4         t5         t6
## t1 54.0000000 0.9583333 20.583333 31.2916667 20.3333333 -2.2916667
## t2  0.9583333 4.8400000  2.963333  2.6866667  0.3250000  3.0766667
## t3 20.5833333 2.9633333 22.993333 10.0566667  4.9833333  2.0366667
## t4 31.2916667 2.6866667 10.056667 22.3100000 13.5583333 -2.2700000
## t5 20.3333333 0.3250000  4.983333 13.5583333 11.4166667 -1.6583333
## t6 -2.2916667 3.0766667  2.036667 -2.2700000 -1.6583333  4.5066667
## t7 20.3750000 0.7050000  6.476667 12.6983333 10.6500000 -0.7466667
## t8  0.2083333 3.4433333  2.770000  0.1633333 -0.2833333  3.7233333
##            t7         t8
## t1 20.3750000  0.2083333
## t2  0.7050000  3.4433333
## t3  6.4766667  2.7700000
## t4 12.6983333  0.1633333
## t5 10.6500000 -0.2833333
## t6 -0.7466667  3.7233333
## t7 11.6266667  0.5283333
## t8  0.5283333  3.8566667
## |S|:  8313.241 
## 
## Control limits:
##  LCL      UCL
##    0 17.41705
# generate new "in control" data
boilerNew <- mvrnorm(10, mu = q$center, Sigma = q$cov)
qq <- mqcc(boiler, type = "T2.single", confidence.level = 0.999, 
           newdata = boilerNew, pred.limits = TRUE)

summary(qq)
## 
## Call:
## mqcc(data = boiler, type = "T2.single", pred.limits = TRUE, newdata = boilerNew,     confidence.level = 0.999)
## 
## T2.single chart for boiler 
## 
## Summary of group statistics:
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
##  1.316342  5.305689  7.074224  7.680000  9.775744 17.575293 
## 
## Number of variables:  8
## Number of groups:  25
## Group sample size:  1
## 
## Center: 
##     t1     t2     t3     t4     t5     t6     t7     t8 
## 525.00 513.56 538.92 521.68 503.80 512.44 478.72 477.24 
## 
## Covariance matrix:
##            t1        t2        t3         t4         t5         t6
## t1 54.0000000 0.9583333 20.583333 31.2916667 20.3333333 -2.2916667
## t2  0.9583333 4.8400000  2.963333  2.6866667  0.3250000  3.0766667
## t3 20.5833333 2.9633333 22.993333 10.0566667  4.9833333  2.0366667
## t4 31.2916667 2.6866667 10.056667 22.3100000 13.5583333 -2.2700000
## t5 20.3333333 0.3250000  4.983333 13.5583333 11.4166667 -1.6583333
## t6 -2.2916667 3.0766667  2.036667 -2.2700000 -1.6583333  4.5066667
## t7 20.3750000 0.7050000  6.476667 12.6983333 10.6500000 -0.7466667
## t8  0.2083333 3.4433333  2.770000  0.1633333 -0.2833333  3.7233333
##            t7         t8
## t1 20.3750000  0.2083333
## t2  0.7050000  3.4433333
## t3  6.4766667  2.7700000
## t4 12.6983333  0.1633333
## t5 10.6500000 -0.2833333
## t6 -0.7466667  3.7233333
## t7 11.6266667  0.5283333
## t8  0.5283333  3.8566667
## |S|:  8313.241 
## 
## Summary of group statistics in boilerNew:
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
##  0.966092  2.942749  3.702601  5.167563  6.477616 16.513119 
## 
## Number of groups:  10
## Group sample size:  1
## 
## Control limits:
##  LCL      UCL
##    0 17.41705
## 
## Prediction limits:
##  LPL      UPL
##    0 70.02943
# generate new "out of control" data
boilerNew = mvrnorm(10, mu = 1.01*q$center, Sigma = q$cov)
qq <- mqcc(boiler, type = "T2.single", confidence.level = 0.999, 
           newdata = boilerNew, pred.limits = TRUE)

summary(qq)
## 
## Call:
## mqcc(data = boiler, type = "T2.single", pred.limits = TRUE, newdata = boilerNew,     confidence.level = 0.999)
## 
## T2.single chart for boiler 
## 
## Summary of group statistics:
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
##  1.316342  5.305689  7.074224  7.680000  9.775744 17.575293 
## 
## Number of variables:  8
## Number of groups:  25
## Group sample size:  1
## 
## Center: 
##     t1     t2     t3     t4     t5     t6     t7     t8 
## 525.00 513.56 538.92 521.68 503.80 512.44 478.72 477.24 
## 
## Covariance matrix:
##            t1        t2        t3         t4         t5         t6
## t1 54.0000000 0.9583333 20.583333 31.2916667 20.3333333 -2.2916667
## t2  0.9583333 4.8400000  2.963333  2.6866667  0.3250000  3.0766667
## t3 20.5833333 2.9633333 22.993333 10.0566667  4.9833333  2.0366667
## t4 31.2916667 2.6866667 10.056667 22.3100000 13.5583333 -2.2700000
## t5 20.3333333 0.3250000  4.983333 13.5583333 11.4166667 -1.6583333
## t6 -2.2916667 3.0766667  2.036667 -2.2700000 -1.6583333  4.5066667
## t7 20.3750000 0.7050000  6.476667 12.6983333 10.6500000 -0.7466667
## t8  0.2083333 3.4433333  2.770000  0.1633333 -0.2833333  3.7233333
##            t7         t8
## t1 20.3750000  0.2083333
## t2  0.7050000  3.4433333
## t3  6.4766667  2.7700000
## t4 12.6983333  0.1633333
## t5 10.6500000 -0.2833333
## t6 -0.7466667  3.7233333
## t7 11.6266667  0.5283333
## t8  0.5283333  3.8566667
## |S|:  8313.241 
## 
## Summary of group statistics in boilerNew:
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## 11.69027 17.41133 18.57985 23.01000 23.86838 51.17288 
## 
## Number of groups:  10
## Group sample size:  1
## 
## Control limits:
##  LCL      UCL
##    0 17.41705
## 
## Prediction limits:
##  LPL      UPL
##    0 70.02943
# provides "robust" estimates of means and covariance matrix
library(MASS)
rob <- cov.rob(boiler)
qrob <- mqcc(boiler, type = "T2.single", center = rob$center, cov = rob$cov)

summary(qrob)
## 
## Call:
## mqcc(data = boiler, type = "T2.single", center = rob$center,     cov = rob$cov)
## 
## T2.single chart for boiler 
## 
## Summary of group statistics:
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##   3.2687   6.7675   9.5289  46.4473  23.0518 411.8281 
## 
## Number of variables:  8
## Number of groups:  25
## Group sample size:  1
## 
## Center: 
##       t1       t2       t3       t4       t5       t6       t7       t8 
## 525.0000 513.3889 540.0000 521.0556 503.1667 512.5556 478.4444 477.2778 
## 
## Covariance matrix:
##           t1        t2        t3         t4         t5         t6
## t1 26.117647 3.5882353 11.764706 19.9411765 12.5882353 -2.2941176
## t2  3.588235 6.1339869  5.705882  3.9771242  0.9313725  4.3594771
## t3 11.764706 5.7058824 10.941176 10.0000000  4.0588235  2.3529412
## t4 19.941176 3.9771242 10.000000 15.8202614  9.9313725 -0.7385621
## t5 12.588235 0.9313725  4.058824  9.9313725  9.3235294 -1.7450980
## t6 -2.294118 4.3594771  2.352941 -0.7385621 -1.7450980  4.4967320
## t7 12.823529 1.6993464  4.176471 10.1503268  9.0980392 -1.2026144
## t8 -1.058824 4.7091503  2.647059  0.2777778 -0.6372549  4.4836601
##            t7         t8
## t1 12.8235294 -1.0588235
## t2  1.6993464  4.7091503
## t3  4.1764706  2.6470588
## t4 10.1503268  0.2777778
## t5  9.0980392 -0.6372549
## t6 -1.2026144  4.4836601
## t7 10.4967320  0.2222222
## t8  0.2222222  4.9183007
## |S|:  27.26056 
## 
## Control limits:
##  LCL      UCL
##    0 14.26225