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.
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=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")
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)
##
## 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)
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)
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)
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.418811 0.863419 1.878977 2.381357 3.821807 5.898465
##
## 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.131144 2.943108 5.870972 7.132906 11.870166 16.259584
##
## 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.062531 4.430637 5.555175 6.531199 8.246639 12.599345
##
## 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.
## 7.76577 16.31325 18.90918 20.58872 21.77450 36.12311
##
## 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.84328 6.72920 9.05945 17.06577 12.25646 126.63764
##
## Number of variables: 8
## Number of groups: 25
## Group sample size: 1
##
## Center:
## t1 t2 t3 t4 t5 t6 t7 t8
## 524.45 513.50 538.65 521.55 503.85 512.35 478.40 477.10
##
## Covariance matrix:
## t1 t2 t3 t4 t5 t6
## t1 57.944736842 0.9736842 23.744737 34.16052632 21.1763158 -2.6921053
## t2 0.973684211 5.4210526 3.131579 2.97368421 0.7631579 3.6052632
## t3 23.744736842 3.1315789 27.923684 11.46578947 6.1552632 2.3394737
## t4 34.160526316 2.9736842 11.465789 24.89210526 14.2973684 -2.6763158
## t5 21.176315789 0.7631579 6.155263 14.29736842 10.4500000 -1.5236842
## t6 -2.692105263 3.6052632 2.339474 -2.67631579 -1.5236842 5.3973684
## t7 22.284210526 0.7368421 7.515789 13.97894737 11.0631579 -0.7789474
## t8 0.005263158 3.9473684 3.142105 0.04736842 -0.1947368 4.3842105
## t7 t8
## t1 22.2842105 0.005263158
## t2 0.7368421 3.947368421
## t3 7.5157895 3.142105263
## t4 13.9789474 0.047368421
## t5 11.0631579 -0.194736842
## t6 -0.7789474 4.384210526
## t7 12.3578947 0.378947368
## t8 0.3789474 4.410526316
## |S|: 1668.124
##
## Control limits:
## LCL UCL
## 0 14.26225