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.529324 1.408208 2.095664 2.749772 2.919993 7.081939 
## 
## 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.769729  2.461302  4.842636  6.281593  8.414939 15.176342 
## 
## 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. 
##  2.194816  4.965012  6.917537  9.335068 10.951624 20.706077 
## 
## 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.49644 17.01095 22.33408 23.11782 27.66262 40.48811 
## 
## 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. 
##   1.60771   5.86731   8.16792  26.20657  12.38431 215.91907 
## 
## Number of variables:  8
## Number of groups:  25
## Group sample size:  1
## 
## Center: 
##       t1       t2       t3       t4       t5       t6       t7       t8 
## 526.2381 513.4286 540.2381 521.9524 504.2381 512.5238 479.1905 477.3333 
## 
## Covariance matrix:
##           t1       t2        t3          t4         t5        t6
## t1 34.890476 3.042857 12.940476 26.21190476 15.6404762 -4.430952
## t2  3.042857 5.457143  5.242857  3.77142857  1.0428571  3.664286
## t3 12.940476 5.242857 10.890476 11.41190476  4.6404762  1.019048
## t4 26.211905 3.771429 11.411905 21.04761905 11.6619048 -2.873810
## t5 15.640476 1.042857  4.640476 11.66190476  8.9904762 -1.730952
## t6 -4.430952 3.664286  1.019048 -2.87380952 -1.7309524  4.961905
## t7 14.152381 1.664286  4.302381 10.80952381  8.7523810 -1.054762
## t8 -1.333333 4.100000  2.216667 -0.08333333 -0.3333333  4.116667
##            t7          t8
## t1 14.1523810 -1.33333333
## t2  1.6642857  4.10000000
## t3  4.3023810  2.21666667
## t4 10.8095238 -0.08333333
## t5  8.7523810 -0.33333333
## t6 -1.0547619  4.11666667
## t7  9.8619048  0.38333333
## t8  0.3833333  4.33333333
## |S|:  171.5704 
## 
## Control limits:
##  LCL      UCL
##    0 14.26225