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)
data(pistonrings)
attach(pistonrings)
diameter <- qcc.groups(diameter, sample)
beta <- oc.curves.xbar(qcc(diameter, type="xbar", nsigmas=3, plot=FALSE))
print(round(beta, digits=4))
## sample size
## shift (std.dev) n=5 n=1 n=10 n=15 n=20
## 0 0.9973 0.9973 0.9973 0.9973 0.9973
## 0.05 0.9971 0.9973 0.9970 0.9968 0.9966
## 0.1 0.9966 0.9972 0.9959 0.9952 0.9944
## 0.15 0.9957 0.9970 0.9940 0.9920 0.9900
## 0.2 0.9944 0.9968 0.9909 0.9869 0.9823
## 0.25 0.9925 0.9964 0.9864 0.9789 0.9701
## 0.3 0.9900 0.9960 0.9798 0.9670 0.9514
## 0.35 0.9866 0.9956 0.9708 0.9500 0.9243
## 0.4 0.9823 0.9950 0.9586 0.9266 0.8871
## 0.45 0.9769 0.9943 0.9426 0.8957 0.8383
## 0.5 0.9701 0.9936 0.9220 0.8562 0.7775
## 0.55 0.9616 0.9927 0.8963 0.8078 0.7055
## 0.6 0.9514 0.9916 0.8649 0.7505 0.6243
## 0.65 0.9390 0.9905 0.8275 0.6853 0.5371
## 0.7 0.9243 0.9892 0.7842 0.6137 0.4481
## 0.75 0.9071 0.9877 0.7351 0.5379 0.3616
## 0.8 0.8871 0.9860 0.6809 0.4608 0.2817
## 0.85 0.8642 0.9842 0.6225 0.3851 0.2115
## 0.9 0.8383 0.9821 0.5612 0.3136 0.1527
## 0.95 0.8094 0.9798 0.4983 0.2485 0.1059
## 1 0.7775 0.9772 0.4355 0.1913 0.0705
## 1.05 0.7428 0.9744 0.3743 0.1431 0.0450
## 1.1 0.7055 0.9713 0.3161 0.1038 0.0275
## 1.15 0.6659 0.9678 0.2622 0.0730 0.0161
## 1.2 0.6243 0.9641 0.2134 0.0497 0.0090
## 1.25 0.5812 0.9599 0.1703 0.0328 0.0048
## 1.3 0.5371 0.9554 0.1333 0.0209 0.0024
## 1.35 0.4925 0.9505 0.1022 0.0129 0.0012
## 1.4 0.4481 0.9452 0.0768 0.0077 0.0006
## 1.45 0.4043 0.9394 0.0564 0.0045 0.0002
## 1.5 0.3616 0.9332 0.0406 0.0025 0.0001
## 1.55 0.3206 0.9265 0.0286 0.0013 0.0000
## 1.6 0.2817 0.9192 0.0197 0.0007 0.0000
## 1.65 0.2453 0.9115 0.0133 0.0003 0.0000
## 1.7 0.2115 0.9032 0.0088 0.0002 0.0000
## 1.75 0.1806 0.8943 0.0056 0.0001 0.0000
## 1.8 0.1527 0.8849 0.0036 0.0000 0.0000
## 1.85 0.1278 0.8749 0.0022 0.0000 0.0000
## 1.9 0.1059 0.8643 0.0013 0.0000 0.0000
## 1.95 0.0869 0.8531 0.0008 0.0000 0.0000
## 2 0.0705 0.8413 0.0004 0.0000 0.0000
## 2.05 0.0566 0.8289 0.0002 0.0000 0.0000
## 2.1 0.0450 0.8159 0.0001 0.0000 0.0000
## 2.15 0.0353 0.8023 0.0001 0.0000 0.0000
## 2.2 0.0275 0.7881 0.0000 0.0000 0.0000
## 2.25 0.0211 0.7734 0.0000 0.0000 0.0000
## 2.3 0.0161 0.7580 0.0000 0.0000 0.0000
## 2.35 0.0121 0.7422 0.0000 0.0000 0.0000
## 2.4 0.0090 0.7257 0.0000 0.0000 0.0000
## 2.45 0.0066 0.7088 0.0000 0.0000 0.0000
## 2.5 0.0048 0.6915 0.0000 0.0000 0.0000
## 2.55 0.0034 0.6736 0.0000 0.0000 0.0000
## 2.6 0.0024 0.6554 0.0000 0.0000 0.0000
## 2.65 0.0017 0.6368 0.0000 0.0000 0.0000
## 2.7 0.0012 0.6179 0.0000 0.0000 0.0000
## 2.75 0.0008 0.5987 0.0000 0.0000 0.0000
## 2.8 0.0006 0.5793 0.0000 0.0000 0.0000
## 2.85 0.0004 0.5596 0.0000 0.0000 0.0000
## 2.9 0.0002 0.5398 0.0000 0.0000 0.0000
## 2.95 0.0002 0.5199 0.0000 0.0000 0.0000
## 3 0.0001 0.5000 0.0000 0.0000 0.0000
## 3.05 0.0001 0.4801 0.0000 0.0000 0.0000
## 3.1 0.0000 0.4602 0.0000 0.0000 0.0000
## 3.15 0.0000 0.4404 0.0000 0.0000 0.0000
## 3.2 0.0000 0.4207 0.0000 0.0000 0.0000
## 3.25 0.0000 0.4013 0.0000 0.0000 0.0000
## 3.3 0.0000 0.3821 0.0000 0.0000 0.0000
## 3.35 0.0000 0.3632 0.0000 0.0000 0.0000
## 3.4 0.0000 0.3446 0.0000 0.0000 0.0000
## 3.45 0.0000 0.3264 0.0000 0.0000 0.0000
## 3.5 0.0000 0.3085 0.0000 0.0000 0.0000
## 3.55 0.0000 0.2912 0.0000 0.0000 0.0000
## 3.6 0.0000 0.2743 0.0000 0.0000 0.0000
## 3.65 0.0000 0.2578 0.0000 0.0000 0.0000
## 3.7 0.0000 0.2420 0.0000 0.0000 0.0000
## 3.75 0.0000 0.2266 0.0000 0.0000 0.0000
## 3.8 0.0000 0.2119 0.0000 0.0000 0.0000
## 3.85 0.0000 0.1977 0.0000 0.0000 0.0000
## 3.9 0.0000 0.1841 0.0000 0.0000 0.0000
## 3.95 0.0000 0.1711 0.0000 0.0000 0.0000
## 4 0.0000 0.1587 0.0000 0.0000 0.0000
## 4.05 0.0000 0.1469 0.0000 0.0000 0.0000
## 4.1 0.0000 0.1357 0.0000 0.0000 0.0000
## 4.15 0.0000 0.1251 0.0000 0.0000 0.0000
## 4.2 0.0000 0.1151 0.0000 0.0000 0.0000
## 4.25 0.0000 0.1056 0.0000 0.0000 0.0000
## 4.3 0.0000 0.0968 0.0000 0.0000 0.0000
## 4.35 0.0000 0.0885 0.0000 0.0000 0.0000
## 4.4 0.0000 0.0808 0.0000 0.0000 0.0000
## 4.45 0.0000 0.0735 0.0000 0.0000 0.0000
## 4.5 0.0000 0.0668 0.0000 0.0000 0.0000
## 4.55 0.0000 0.0606 0.0000 0.0000 0.0000
## 4.6 0.0000 0.0548 0.0000 0.0000 0.0000
## 4.65 0.0000 0.0495 0.0000 0.0000 0.0000
## 4.7 0.0000 0.0446 0.0000 0.0000 0.0000
## 4.75 0.0000 0.0401 0.0000 0.0000 0.0000
## 4.8 0.0000 0.0359 0.0000 0.0000 0.0000
## 4.85 0.0000 0.0322 0.0000 0.0000 0.0000
## 4.9 0.0000 0.0287 0.0000 0.0000 0.0000
## 4.95 0.0000 0.0256 0.0000 0.0000 0.0000
## 5 0.0000 0.0228 0.0000 0.0000 0.0000
# or to identify points on the plot use
## Not run: oc.curves.xbar(qcc(diameter, type="xbar", nsigmas=3, plot=FALSE), identify=TRUE)
detach(pistonrings)
data(orangejuice)
attach(orangejuice)
beta <- oc.curves(qcc(D[trial], sizes=size[trial], type="p", plot=FALSE))
## Warning in oc.curves.p(object, ...): Some computed values for the type
## II error have been rounded due to the discreteness of the binomial
## distribution. Thus, some ARL values might be meaningless.
print(round(beta, digits=4))
## 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09
## 0.0000 0.0894 0.2642 0.4447 0.5995 0.7206 0.8100 0.8735 0.9173 0.9468
## 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19
## 0.9662 0.9788 0.9869 0.9920 0.9951 0.9971 0.9983 0.9990 0.9993 0.9995
## 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29
## 0.9995 0.9993 0.9987 0.9978 0.9962 0.9937 0.9900 0.9845 0.9768 0.9662
## 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39
## 0.9522 0.9343 0.9118 0.8844 0.8518 0.8139 0.7711 0.7236 0.6722 0.6176
## 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49
## 0.5610 0.5035 0.4461 0.3901 0.3365 0.2862 0.2398 0.1980 0.1609 0.1287
## 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59
## 0.1013 0.0784 0.0596 0.0446 0.0327 0.0235 0.0166 0.0115 0.0078 0.0052
## 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69
## 0.0034 0.0021 0.0013 0.0008 0.0005 0.0003 0.0002 0.0001 0.0000 0.0000
## 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79
## 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89
## 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99
## 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## 1
## 0.0000
# or to identify points on the plot use
## Not run: oc.curves(qcc(D[trial], sizes=size[trial], type="p", plot=FALSE), identify=TRUE)
detach(orangejuice)
data(circuit)
attach(circuit)
q <- qcc(x[trial], sizes=size[trial], type="c", plot=FALSE)
beta <- oc.curves(q)
## Warning in oc.curves.c(object, ...): Some computed values for the
## type II error have been rounded due to the discreteness of the Poisson
## distribution. Thus, some ARL values might be meaningless.
print(round(beta, digits=4))
## 0 1 2 3 4 5 6 7 8 9
## 0.0000 0.0006 0.0166 0.0839 0.2149 0.3840 0.5543 0.6993 0.8088 0.8843
## 10 11 12 13 14 15 16 17 18 19
## 0.9329 0.9625 0.9797 0.9893 0.9945 0.9972 0.9986 0.9991 0.9992 0.9986
## 20 21 22 23 24 25 26 27 28 29
## 0.9972 0.9945 0.9895 0.9813 0.9686 0.9502 0.9249 0.8918 0.8505 0.8011
## 30 31 32 33 34 35 36 37 38 39
## 0.7444 0.6818 0.6150 0.5461 0.4772 0.4102 0.3470 0.2888 0.2365 0.1907
## 40 41 42 43 44 45 46 47 48 49
## 0.1514 0.1184 0.0912 0.0693 0.0519 0.0383 0.0280 0.0201 0.0143 0.0101
## 50 51 52 53 54 55 56 57 58 59
## 0.0070 0.0048 0.0033 0.0022 0.0015 0.0010 0.0006 0.0004 0.0003 0.0002
## 60 61 62 63 64 65
## 0.0001 0.0001 0.0000 0.0000 0.0000 0.0000
# or to identify points on the plot use
## Not run: oc.curves(qcc(x[trial], sizes=size[trial], type="c", plot=FALSE), identify=TRUE)
detach(circuit)
data(orangejuice)
orangejuice$d <- orangejuice$D/orangejuice$size
attach(orangejuice)
summary(orangejuice)
## sample D size trial
## Min. : 1.00 Min. : 2.000 Min. :50 Mode :logical
## 1st Qu.:14.25 1st Qu.: 5.000 1st Qu.:50 FALSE:24
## Median :27.50 Median : 7.000 Median :50 TRUE :30
## Mean :27.50 Mean : 8.889 Mean :50
## 3rd Qu.:40.75 3rd Qu.:12.000 3rd Qu.:50
## Max. :54.00 Max. :24.000 Max. :50
## d
## Min. :0.0400
## 1st Qu.:0.1000
## Median :0.1400
## Mean :0.1778
## 3rd Qu.:0.2400
## Max. :0.4800
boxplot(d ~ trial)
mark <- ifelse(trial, 1, 2)
plot(sample, d, type="b", col=mark, pch=mark)
detach(orangejuice)
data(orangejuice2)
orangejuice2$d <- orangejuice2$D/orangejuice2$size
attach(orangejuice2)
summary(orangejuice2)
## sample D size trial
## Min. :31.00 Min. : 1.000 Min. :50 Mode :logical
## 1st Qu.:46.75 1st Qu.: 4.000 1st Qu.:50 FALSE:40
## Median :62.50 Median : 5.000 Median :50 TRUE :24
## Mean :62.50 Mean : 5.484 Mean :50
## 3rd Qu.:78.25 3rd Qu.: 7.000 3rd Qu.:50
## Max. :94.00 Max. :12.000 Max. :50
## d
## Min. :0.0200
## 1st Qu.:0.0800
## Median :0.1000
## Mean :0.1097
## 3rd Qu.:0.1400
## Max. :0.2400
boxplot(d ~ trial)
mark <- ifelse(trial, 1, 2)
plot(sample, d, type="b", col=mark, pch=mark)
detach(orangejuice2)
defect <- c(80, 27, 66, 94, 33)
names(defect) <- c("price code", "schedule date", "supplier code", "contact num.", "part num.")
pareto.chart(defect, ylab = "Error frequency")
##
## Pareto chart analysis for defect
## Frequency Cum.Freq. Percentage Cum.Percent.
## contact num. 94.00000 94.00000 31.33333 31.33333
## price code 80.00000 174.00000 26.66667 58.00000
## supplier code 66.00000 240.00000 22.00000 80.00000
## part num. 33.00000 273.00000 11.00000 91.00000
## schedule date 27.00000 300.00000 9.00000 100.00000
pareto.chart(defect, ylab = "Error frequency", xlab = "Error causes", las=1)
##
## Pareto chart analysis for defect
## Frequency Cum.Freq. Percentage Cum.Percent.
## contact num. 94.00000 94.00000 31.33333 31.33333
## price code 80.00000 174.00000 26.66667 58.00000
## supplier code 66.00000 240.00000 22.00000 80.00000
## part num. 33.00000 273.00000 11.00000 91.00000
## schedule date 27.00000 300.00000 9.00000 100.00000
pareto.chart(defect, ylab = "Error frequency", col=rainbow(length(defect)))
##
## Pareto chart analysis for defect
## Frequency Cum.Freq. Percentage Cum.Percent.
## contact num. 94.00000 94.00000 31.33333 31.33333
## price code 80.00000 174.00000 26.66667 58.00000
## supplier code 66.00000 240.00000 22.00000 80.00000
## part num. 33.00000 273.00000 11.00000 91.00000
## schedule date 27.00000 300.00000 9.00000 100.00000
pareto.chart(defect, cumperc = seq(0, 100, by = 5), ylab2 = "A finer tickmarks grid")
##
## Pareto chart analysis for defect
## Frequency Cum.Freq. Percentage Cum.Percent.
## contact num. 94.00000 94.00000 31.33333 31.33333
## price code 80.00000 174.00000 26.66667 58.00000
## supplier code 66.00000 240.00000 22.00000 80.00000
## part num. 33.00000 273.00000 11.00000 91.00000
## schedule date 27.00000 300.00000 9.00000 100.00000
data(pcmanufact)
attach(pcmanufact)
summary(pcmanufact)
## x size
## Min. : 5.00 Min. :5
## 1st Qu.: 7.00 1st Qu.:5
## Median :10.00 Median :5
## Mean : 9.65 Mean :5
## 3rd Qu.:11.25 3rd Qu.:5
## Max. :16.00 Max. :5
plot(x/size, type="b")
detach(pcmanufact)
data(pistonrings)
attach(pistonrings)
## The following object is masked _by_ .GlobalEnv:
##
## diameter
summary(pistonrings)
## diameter sample trial
## Min. :73.97 Min. : 1.00 Mode :logical
## 1st Qu.:74.00 1st Qu.:10.75 FALSE:75
## Median :74.00 Median :20.50 TRUE :125
## Mean :74.00 Mean :20.50
## 3rd Qu.:74.01 3rd Qu.:30.25
## Max. :74.04 Max. :40.00
boxplot(pistonrings$diameter ~ pistonrings$sample)
plot(sample, diameter, cex=0.7)
lines(tapply(diameter,sample,mean))
detach(pistonrings)
data(pistonrings)
attach(pistonrings)
## The following object is masked _by_ .GlobalEnv:
##
## diameter
diameter <- qcc.groups(diameter, sample)
q <- qcc(diameter[1:25,], type="xbar", nsigmas=3, plot=FALSE)
process.capability(q, spec.limits=c(73.95,74.05))
##
## Process Capability Analysis
##
## Call:
## process.capability(object = q, spec.limits = c(73.95, 74.05))
##
## Number of obs = 125 Target = 74
## Center = 74 LSL = 73.95
## StdDev = 0.01187 USL = 74.05
##
## Capability indices:
##
## Value 2.5% 97.5%
## Cp 1.405 1.230 1.579
## Cp_l 1.490 1.327 1.653
## Cp_u 1.319 1.173 1.465
## Cp_k 1.319 1.145 1.493
## Cpm 1.360 1.187 1.534
##
## Exp<LSL 0% Obs<LSL 0%
## Exp>USL 0% Obs>USL 0%
process.capability(q, spec.limits=c(73.95,74.05), target=74.02)
##
## Process Capability Analysis
##
## Call:
## process.capability(object = q, spec.limits = c(73.95, 74.05), target = 74.02)
##
## Number of obs = 125 Target = 74.02
## Center = 74 LSL = 73.95
## StdDev = 0.01187 USL = 74.05
##
## Capability indices:
##
## Value 2.5% 97.5%
## Cp 1.4046 1.2299 1.5790
## Cp_l 1.4902 1.3270 1.6534
## Cp_u 1.3190 1.1727 1.4652
## Cp_k 1.3190 1.1447 1.4932
## Cpm 0.8055 0.6765 0.9341
##
## Exp<LSL 0% Obs<LSL 0%
## Exp>USL 0% Obs>USL 0%
process.capability(q, spec.limits=c(73.99,74.01))
##
## Process Capability Analysis
##
## Call:
## process.capability(object = q, spec.limits = c(73.99, 74.01))
##
## Number of obs = 125 Target = 74
## Center = 74 LSL = 73.99
## StdDev = 0.01187 USL = 74.01
##
## Capability indices:
##
## Value 2.5% 97.5%
## Cp 0.2809 0.2460 0.3158
## Cp_l 0.3665 0.3043 0.4288
## Cp_u 0.1953 0.1422 0.2484
## Cp_k 0.1953 0.1320 0.2586
## Cpm 0.2721 0.2374 0.3068
##
## Exp<LSL 14% Obs<LSL 11%
## Exp>USL 28% Obs>USL 24%
process.capability(q, spec.limits = c(73.99, 74.1))
##
## Process Capability Analysis
##
## Call:
## process.capability(object = q, spec.limits = c(73.99, 74.1))
##
## Number of obs = 125 Target = 74.05
## Center = 74 LSL = 73.99
## StdDev = 0.01187 USL = 74.1
##
## Capability indices:
##
## Value 2.5% 97.5%
## Cp 1.5450 1.3529 1.7369
## Cp_l 0.3665 0.3043 0.4288
## Cp_u 2.7236 2.4349 3.0122
## Cp_k 0.3665 0.2924 0.4407
## Cpm 0.4205 0.3483 0.4926
##
## Exp<LSL 14% Obs<LSL 11%
## Exp>USL 0% Obs>USL 0%
Create an object of class ‘qcc’ to perform statistical quality control. This object may then be used to plot Shewhart charts, drawing OC curves, computes capability indices, and more.
##
## Continuous data
##
data(pistonrings)
attach(pistonrings)
## The following object is masked _by_ .GlobalEnv:
##
## diameter
## The following objects are masked from pistonrings (pos = 3):
##
## diameter, sample, trial
diameter <- qcc.groups(diameter, sample)
qcc(diameter[1:25,], type="xbar")
## List of 11
## $ call : language qcc(data = diameter[1:25, ], type = "xbar")
## $ type : chr "xbar"
## $ data.name : chr "diameter[1:25, ]"
## $ data : num [1:25, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:25] 74 74 74 74 74 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ sizes : Named int [1:25] 5 5 5 5 5 5 5 5 5 5 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ center : num 74
## $ std.dev : num 0.0113
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 74 74
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
qcc(diameter[1:25,], type="xbar", newdata=diameter[26:40,])
## List of 15
## $ call : language qcc(data = diameter[1:25, ], type = "xbar", newdata = diameter[26:40, ])
## $ type : chr "xbar"
## $ data.name : chr "diameter[1:25, ]"
## $ data : num [1:25, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics : Named num [1:25] 74 74 74 74 74 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ sizes : Named int [1:25] 5 5 5 5 5 5 5 5 5 5 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ center : num 74
## $ std.dev : num 0.0113
## $ newstats : Named num [1:15] 74 74 74 74 74 ...
## ..- attr(*, "names")= chr [1:15] "26" "27" "28" "29" ...
## $ newdata : num [1:15, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ newsizes : Named int [1:15] 5 5 5 5 5 5 5 5 5 5 ...
## ..- attr(*, "names")= chr [1:15] "26" "27" "28" "29" ...
## $ newdata.name: chr "diameter[26:40, ]"
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 74 74
## ..- attr(*, "dimnames")=List of 2
## $ violations :List of 2
## - attr(*, "class")= chr "qcc"
q <- qcc(diameter[1:25,], type="xbar", newdata=diameter[26:40,], plot=FALSE)
plot(q, chart.all=FALSE)
qcc(diameter[1:25,], type="xbar", newdata=diameter[26:40,], nsigmas=2)
## List of 15
## $ call : language qcc(data = diameter[1:25, ], type = "xbar", newdata = diameter[26:40, ], nsigmas = 2)
## $ type : chr "xbar"
## $ data.name : chr "diameter[1:25, ]"
## $ data : num [1:25, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics : Named num [1:25] 74 74 74 74 74 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ sizes : Named int [1:25] 5 5 5 5 5 5 5 5 5 5 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ center : num 74
## $ std.dev : num 0.0113
## $ newstats : Named num [1:15] 74 74 74 74 74 ...
## ..- attr(*, "names")= chr [1:15] "26" "27" "28" "29" ...
## $ newdata : num [1:15, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ newsizes : Named int [1:15] 5 5 5 5 5 5 5 5 5 5 ...
## ..- attr(*, "names")= chr [1:15] "26" "27" "28" "29" ...
## $ newdata.name: chr "diameter[26:40, ]"
## $ nsigmas : num 2
## $ limits : num [1, 1:2] 74 74
## ..- attr(*, "dimnames")=List of 2
## $ violations :List of 2
## - attr(*, "class")= chr "qcc"
qcc(diameter[1:25,], type="xbar", newdata=diameter[26:40,], confidence.level=0.99)
## List of 15
## $ call : language qcc(data = diameter[1:25, ], type = "xbar", newdata = diameter[26:40, ], confidence.level = 0.99)
## $ type : chr "xbar"
## $ data.name : chr "diameter[1:25, ]"
## $ data : num [1:25, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics : Named num [1:25] 74 74 74 74 74 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ sizes : Named int [1:25] 5 5 5 5 5 5 5 5 5 5 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ center : num 74
## $ std.dev : num 0.0113
## $ newstats : Named num [1:15] 74 74 74 74 74 ...
## ..- attr(*, "names")= chr [1:15] "26" "27" "28" "29" ...
## $ newdata : num [1:15, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ newsizes : Named int [1:15] 5 5 5 5 5 5 5 5 5 5 ...
## ..- attr(*, "names")= chr [1:15] "26" "27" "28" "29" ...
## $ newdata.name : chr "diameter[26:40, ]"
## $ confidence.level: num 0.99
## $ limits : num [1, 1:2] 74 74
## ..- attr(*, "dimnames")=List of 2
## $ violations :List of 2
## - attr(*, "class")= chr "qcc"
qcc(diameter[1:25,], type="R")
## List of 11
## $ call : language qcc(data = diameter[1:25, ], type = "R")
## $ type : chr "R"
## $ data.name : chr "diameter[1:25, ]"
## $ data : num [1:25, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:25] 0.042 0.018 0.031 0.029 0.038 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ sizes : Named int [1:25] 5 5 5 5 5 5 5 5 5 5 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ center : num 0.0262
## $ std.dev : num 0.0113
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 0 0.0555
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
qcc(diameter[1:25,], type="R", newdata=diameter[26:40,])
## List of 15
## $ call : language qcc(data = diameter[1:25, ], type = "R", newdata = diameter[26:40, ])
## $ type : chr "R"
## $ data.name : chr "diameter[1:25, ]"
## $ data : num [1:25, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics : Named num [1:25] 0.042 0.018 0.031 0.029 0.038 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ sizes : Named int [1:25] 5 5 5 5 5 5 5 5 5 5 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ center : num 0.0262
## $ std.dev : num 0.0113
## $ newstats : Named num [1:15] 0.022 0.043 0.02 0.043 0.014 ...
## ..- attr(*, "names")= chr [1:15] "26" "27" "28" "29" ...
## $ newdata : num [1:15, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ newsizes : Named int [1:15] 5 5 5 5 5 5 5 5 5 5 ...
## ..- attr(*, "names")= chr [1:15] "26" "27" "28" "29" ...
## $ newdata.name: chr "diameter[26:40, ]"
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 0 0.0555
## ..- attr(*, "dimnames")=List of 2
## $ violations :List of 2
## - attr(*, "class")= chr "qcc"
qcc(diameter[1:25,], type="S")
## List of 11
## $ call : language qcc(data = diameter[1:25, ], type = "S")
## $ type : chr "S"
## $ data.name : chr "diameter[1:25, ]"
## $ data : num [1:25, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:25] 0.0164 0.0074 0.0111 0.0115 0.0155 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ sizes : Named int [1:25] 5 5 5 5 5 5 5 5 5 5 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ center : num 0.0108
## $ std.dev : num 0.0115
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 0 0.0225
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
qcc(diameter[1:25,], type="S", newdata=diameter[26:40,])
## List of 15
## $ call : language qcc(data = diameter[1:25, ], type = "S", newdata = diameter[26:40, ])
## $ type : chr "S"
## $ data.name : chr "diameter[1:25, ]"
## $ data : num [1:25, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics : Named num [1:25] 0.0164 0.0074 0.0111 0.0115 0.0155 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ sizes : Named int [1:25] 5 5 5 5 5 5 5 5 5 5 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ center : num 0.0108
## $ std.dev : num 0.0115
## $ newstats : Named num [1:15] 0.01033 0.01749 0.00888 0.01613 0.00572 ...
## ..- attr(*, "names")= chr [1:15] "26" "27" "28" "29" ...
## $ newdata : num [1:15, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ newsizes : Named int [1:15] 5 5 5 5 5 5 5 5 5 5 ...
## ..- attr(*, "names")= chr [1:15] "26" "27" "28" "29" ...
## $ newdata.name: chr "diameter[26:40, ]"
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 0 0.0225
## ..- attr(*, "dimnames")=List of 2
## $ violations :List of 2
## - attr(*, "class")= chr "qcc"
# add warning limits at 2 std. deviations
q <- qcc(diameter[1:25,], type="xbar", newdata=diameter[26:40,], plot=FALSE)
(warn.limits <- limits.xbar(q$center, q$std.dev, q$sizes, 2))
## LCL UCL
## 73.99273 74.01291
plot(q, restore.par = FALSE)
abline(h = warn.limits, lty = 3, col = "chocolate")
# variable control limits
out <- c(9, 10, 30, 35, 45, 64, 65, 74, 75, 85, 99, 100)
diameter <- qcc.groups(pistonrings$diameter[-out], sample[-out])
qcc(diameter[1:25,], type="xbar")
## List of 11
## $ call : language qcc(data = diameter[1:25, ], type = "xbar")
## $ type : chr "xbar"
## $ data.name : chr "diameter[1:25, ]"
## $ data : num [1:25, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:25] 74 74 74 74 74 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ sizes : Named int [1:25] 5 3 5 5 5 4 4 5 4 5 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ center : num 74
## $ std.dev : num 0.00986
## $ nsigmas : num 3
## $ limits : num [1:25, 1:2] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
qcc(diameter[1:25,], type="R")
## List of 11
## $ call : language qcc(data = diameter[1:25, ], type = "R")
## $ type : chr "R"
## $ data.name : chr "diameter[1:25, ]"
## $ data : num [1:25, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:25] 0.038 0.009 0.036 0.022 0.026 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ sizes : Named int [1:25] 5 3 5 5 5 4 4 5 4 5 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ center : num 0.0223
## $ std.dev : num 0.00986
## $ nsigmas : num 3
## $ limits : num [1:25, 1:2] 0 0 0 0 0 0 0 0 0 0 ...
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
qcc(diameter[1:25,], type="S")
## List of 11
## $ call : language qcc(data = diameter[1:25, ], type = "S")
## $ type : chr "S"
## $ data.name : chr "diameter[1:25, ]"
## $ data : num [1:25, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:25] 0.01477 0.00458 0.01475 0.00908 0.01222 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ sizes : Named int [1:25] 5 3 5 5 5 4 4 5 4 5 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ center : num 0.00939
## $ std.dev : num 0.00993
## $ nsigmas : num 3
## $ limits : num [1:25, 1:2] 0 0 0 0 0 0 0 0 0 0 ...
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
qcc(diameter[1:25,], type="xbar", newdata=diameter[26:40,])
## List of 15
## $ call : language qcc(data = diameter[1:25, ], type = "xbar", newdata = diameter[26:40, ])
## $ type : chr "xbar"
## $ data.name : chr "diameter[1:25, ]"
## $ data : num [1:25, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics : Named num [1:25] 74 74 74 74 74 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ sizes : Named int [1:25] 5 3 5 5 5 4 4 5 4 5 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ center : num 74
## $ std.dev : num 0.00986
## $ newstats : Named num [1:15] 74 74 74 74 74 ...
## ..- attr(*, "names")= chr [1:15] "26" "27" "28" "29" ...
## $ newdata : num [1:15, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ newsizes : Named int [1:15] 5 5 5 5 5 5 5 5 5 5 ...
## ..- attr(*, "names")= chr [1:15] "26" "27" "28" "29" ...
## $ newdata.name: chr "diameter[26:40, ]"
## $ nsigmas : num 3
## $ limits : num [1:40, 1:2] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ violations :List of 2
## - attr(*, "class")= chr "qcc"
qcc(diameter[1:25,], type="R", newdata=diameter[26:40,])
## List of 15
## $ call : language qcc(data = diameter[1:25, ], type = "R", newdata = diameter[26:40, ])
## $ type : chr "R"
## $ data.name : chr "diameter[1:25, ]"
## $ data : num [1:25, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics : Named num [1:25] 0.038 0.009 0.036 0.022 0.026 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ sizes : Named int [1:25] 5 3 5 5 5 4 4 5 4 5 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ center : num 0.0223
## $ std.dev : num 0.00986
## $ newstats : Named num [1:15] 0.044 0.025 0.015 0.019 0.017 ...
## ..- attr(*, "names")= chr [1:15] "26" "27" "28" "29" ...
## $ newdata : num [1:15, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ newsizes : Named int [1:15] 5 5 5 5 5 5 5 5 5 5 ...
## ..- attr(*, "names")= chr [1:15] "26" "27" "28" "29" ...
## $ newdata.name: chr "diameter[26:40, ]"
## $ nsigmas : num 3
## $ limits : num [1:40, 1:2] 0 0 0 0 0 0 0 0 0 0 ...
## ..- attr(*, "dimnames")=List of 2
## $ violations :List of 2
## - attr(*, "class")= chr "qcc"
qcc(diameter[1:25,], type="S", newdata=diameter[26:40,])
## List of 15
## $ call : language qcc(data = diameter[1:25, ], type = "S", newdata = diameter[26:40, ])
## $ type : chr "S"
## $ data.name : chr "diameter[1:25, ]"
## $ data : num [1:25, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics : Named num [1:25] 0.01477 0.00458 0.01475 0.00908 0.01222 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ sizes : Named int [1:25] 5 3 5 5 5 4 4 5 4 5 ...
## ..- attr(*, "names")= chr [1:25] "1" "2" "3" "4" ...
## $ center : num 0.00939
## $ std.dev : num 0.00993
## $ newstats : Named num [1:15] 0.01655 0.01033 0.00691 0.0075 0.00673 ...
## ..- attr(*, "names")= chr [1:15] "26" "27" "28" "29" ...
## $ newdata : num [1:15, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ newsizes : Named int [1:15] 5 5 5 5 5 5 5 5 5 5 ...
## ..- attr(*, "names")= chr [1:15] "26" "27" "28" "29" ...
## $ newdata.name: chr "diameter[26:40, ]"
## $ nsigmas : num 3
## $ limits : num [1:40, 1:2] 0 0 0 0 0 0 0 0 0 0 ...
## ..- attr(*, "dimnames")=List of 2
## $ violations :List of 2
## - attr(*, "class")= chr "qcc"
detach(pistonrings)
##
## Attribute data
##
data(orangejuice)
attach(orangejuice)
## The following objects are masked from pistonrings:
##
## sample, trial
qcc(D[trial], sizes=size[trial], type="p")
## List of 11
## $ call : language qcc(data = D[trial], type = "p", sizes = size[trial])
## $ type : chr "p"
## $ data.name : chr "D[trial]"
## $ data : int [1:30, 1] 12 15 8 10 4 7 16 9 14 10 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:30] 0.24 0.3 0.16 0.2 0.08 0.14 0.32 0.18 0.28 0.2 ...
## ..- attr(*, "names")= chr [1:30] "1" "2" "3" "4" ...
## $ sizes : int [1:30] 50 50 50 50 50 50 50 50 50 50 ...
## $ center : num 0.231
## $ std.dev : num 0.422
## $ nsigmas : num 3
## $ limits : num [1:30, 1:2] 0.0524 0.0524 0.0524 0.0524 0.0524 ...
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
# remove out-of-control points (see help(orangejuice) for the reasons)
inc <- setdiff(which(trial), c(15,23))
q1 <- qcc(D[inc], sizes=size[inc], type="p")
qcc(D[inc], sizes=size[inc], type="p", newdata=D[!trial], newsizes=size[!trial])
## List of 15
## $ call : language qcc(data = D[inc], type = "p", sizes = size[inc], newdata = D[!trial], newsizes = size[!trial])
## $ type : chr "p"
## $ data.name : chr "D[inc]"
## $ data : int [1:28, 1] 12 15 8 10 4 7 16 9 14 10 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics : Named num [1:28] 0.24 0.3 0.16 0.2 0.08 0.14 0.32 0.18 0.28 0.2 ...
## ..- attr(*, "names")= chr [1:28] "1" "2" "3" "4" ...
## $ sizes : int [1:28] 50 50 50 50 50 50 50 50 50 50 ...
## $ center : num 0.215
## $ std.dev : num 0.411
## $ newstats : Named num [1:24] 0.18 0.12 0.24 0.1 0.12 0.08 0.12 0.06 0.14 0.12 ...
## ..- attr(*, "names")= chr [1:24] "29" "30" "31" "32" ...
## $ newdata : int [1:24, 1] 9 6 12 5 6 4 6 3 7 6 ...
## $ newsizes : int [1:24] 50 50 50 50 50 50 50 50 50 50 ...
## $ newdata.name: chr "D[!trial]"
## $ nsigmas : num 3
## $ limits : num [1:52, 1:2] 0.0407 0.0407 0.0407 0.0407 0.0407 ...
## ..- attr(*, "dimnames")=List of 2
## $ violations :List of 2
## - attr(*, "class")= chr "qcc"
detach(orangejuice)
data(orangejuice2)
attach(orangejuice2)
## The following objects are masked from pistonrings:
##
## sample, trial
names(D) <- sample
qcc(D[trial], sizes=size[trial], type="p")
## List of 11
## $ call : language qcc(data = D[trial], type = "p", sizes = size[trial])
## $ type : chr "p"
## $ data.name : chr "D[trial]"
## $ data : int [1:24, 1] 9 6 12 5 6 4 6 3 7 6 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:24] 0.18 0.12 0.24 0.1 0.12 0.08 0.12 0.06 0.14 0.12 ...
## ..- attr(*, "names")= chr [1:24] "31" "32" "33" "34" ...
## $ sizes : int [1:24] 50 50 50 50 50 50 50 50 50 50 ...
## $ center : num 0.111
## $ std.dev : num 0.314
## $ nsigmas : num 3
## $ limits : num [1:24, 1:2] 0 0 0 0 0 0 0 0 0 0 ...
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
q2 <- qcc(D[trial], sizes=size[trial], type="p", newdata=D[!trial], newsizes=size[!trial])
detach(orangejuice2)
# put on the same graph the two orange juice samples
oldpar <- par(no.readonly = TRUE)
par(mfrow=c(1,2), mar=c(5,5,3,0))
plot(q1, title="First samples", ylim=c(0,0.5), add.stats=FALSE, restore.par=FALSE)
par("mar"=c(5,0,3,3), yaxt="n")
plot(q2, title="Second samples", add.stats=FALSE, ylim=c(0,0.5))
par(oldpar)
data(circuit)
attach(circuit)
## The following object is masked from pistonrings:
##
## trial
qcc(x[trial], sizes=size[trial], type="c")
## List of 11
## $ call : language qcc(data = x[trial], type = "c", sizes = size[trial])
## $ type : chr "c"
## $ data.name : chr "x[trial]"
## $ data : int [1:26, 1] 21 24 16 12 15 5 28 20 31 25 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named int [1:26] 21 24 16 12 15 5 28 20 31 25 ...
## ..- attr(*, "names")= chr [1:26] "1" "2" "3" "4" ...
## $ sizes : int [1:26] 100 100 100 100 100 100 100 100 100 100 ...
## $ center : num 19.8
## $ std.dev : num 4.45
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 6.48 33.21
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
# remove out-of-control points (see help(circuit) for the reasons)
inc <- setdiff(which(trial), c(6,20))
qcc(x[inc], sizes=size[inc], type="c", labels=inc)
## List of 11
## $ call : language qcc(data = x[inc], type = "c", sizes = size[inc], labels = inc)
## $ type : chr "c"
## $ data.name : chr "x[inc]"
## $ data : int [1:24, 1] 21 24 16 12 15 28 20 31 25 20 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named int [1:24] 21 24 16 12 15 28 20 31 25 20 ...
## ..- attr(*, "names")= chr [1:24] "1" "2" "3" "4" ...
## $ sizes : int [1:24] 100 100 100 100 100 100 100 100 100 100 ...
## $ center : num 19.7
## $ std.dev : num 4.43
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 6.36 32.97
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
qcc(x[inc], sizes=size[inc], type="c", labels=inc,
newdata=x[!trial], newsizes=size[!trial], newlabels=which(!trial))
## List of 15
## $ call : language qcc(data = x[inc], type = "c", sizes = size[inc], labels = inc, newdata = x[!trial], newsizes = size[!trial]| __truncated__
## $ type : chr "c"
## $ data.name : chr "x[inc]"
## $ data : int [1:24, 1] 21 24 16 12 15 28 20 31 25 20 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics : Named int [1:24] 21 24 16 12 15 28 20 31 25 20 ...
## ..- attr(*, "names")= chr [1:24] "1" "2" "3" "4" ...
## $ sizes : int [1:24] 100 100 100 100 100 100 100 100 100 100 ...
## $ center : num 19.7
## $ std.dev : num 4.43
## $ newstats : Named int [1:20] 16 18 12 15 24 21 28 20 25 19 ...
## ..- attr(*, "names")= chr [1:20] "27" "28" "29" "30" ...
## $ newdata : int [1:20, 1] 16 18 12 15 24 21 28 20 25 19 ...
## $ newsizes : int [1:20] 100 100 100 100 100 100 100 100 100 100 ...
## $ newdata.name: chr "x[!trial]"
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 6.36 32.97
## ..- attr(*, "dimnames")=List of 2
## $ violations :List of 2
## - attr(*, "class")= chr "qcc"
qcc(x[inc], sizes=size[inc], type="u", labels=inc,
newdata=x[!trial], newsizes=size[!trial], newlabels=which(!trial))
## List of 15
## $ call : language qcc(data = x[inc], type = "u", sizes = size[inc], labels = inc, newdata = x[!trial], newsizes = size[!trial]| __truncated__
## $ type : chr "u"
## $ data.name : chr "x[inc]"
## $ data : int [1:24, 1] 21 24 16 12 15 28 20 31 25 20 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics : Named num [1:24] 0.21 0.24 0.16 0.12 0.15 0.28 0.2 0.31 0.25 0.2 ...
## ..- attr(*, "names")= chr [1:24] "1" "2" "3" "4" ...
## $ sizes : int [1:24] 100 100 100 100 100 100 100 100 100 100 ...
## $ center : num 0.197
## $ std.dev : num 0.443
## $ newstats : Named num [1:20] 0.16 0.18 0.12 0.15 0.24 0.21 0.28 0.2 0.25 0.19 ...
## ..- attr(*, "names")= chr [1:20] "27" "28" "29" "30" ...
## $ newdata : int [1:20, 1] 16 18 12 15 24 21 28 20 25 19 ...
## $ newsizes : int [1:20] 100 100 100 100 100 100 100 100 100 100 ...
## $ newdata.name: chr "x[!trial]"
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 0.0636 0.3297
## ..- attr(*, "dimnames")=List of 2
## $ violations :List of 2
## - attr(*, "class")= chr "qcc"
detach(circuit)
data(pcmanufact)
attach(pcmanufact)
qcc(x, sizes=size, type="u")
## List of 11
## $ call : language qcc(data = x, type = "u", sizes = size)
## $ type : chr "u"
## $ data.name : chr "x"
## $ data : int [1:20, 1] 10 12 8 14 10 16 11 7 10 15 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:20] 2 2.4 1.6 2.8 2 3.2 2.2 1.4 2 3 ...
## ..- attr(*, "names")= chr [1:20] "1" "2" "3" "4" ...
## $ sizes : int [1:20] 5 5 5 5 5 5 5 5 5 5 ...
## $ center : num 1.93
## $ std.dev : num 1.39
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 0.0661 3.7939
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
detach(pcmanufact)
data(dyedcloth)
attach(dyedcloth)
qcc(x, sizes=size, type="u")
## List of 11
## $ call : language qcc(data = x, type = "u", sizes = size)
## $ type : chr "u"
## $ data.name : chr "x"
## $ data : int [1:10, 1] 14 12 20 11 7 10 21 16 19 23
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:10] 1.4 1.5 1.538 1.1 0.737 ...
## ..- attr(*, "names")= chr [1:10] "1" "2" "3" "4" ...
## $ sizes : num [1:10] 10 8 13 10 9.5 10 12 10.5 12 12.5
## $ center : num 1.42
## $ std.dev : num 1.19
## $ nsigmas : num 3
## $ limits : num [1:10, 1:2] 0.291 0.158 0.431 0.291 0.262 ...
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
# standardized control chart
q <- qcc(x, sizes=size, type="u", plot=FALSE)
z <- (q$statistics - q$center)/sqrt(q$center/q$size)
plot(z, type="o", ylim=range(z,3,-3), pch=16)
abline(h=0, lty=2)
abline(h=c(-3,3), lty=2)
detach(dyedcloth)
##
## Continuous one-at-time data
##
# viscosity data (Montgomery, pag. 242)
x <- c(33.75, 33.05, 34, 33.81, 33.46, 34.02, 33.68, 33.27, 33.49, 33.20,
33.62, 33.00, 33.54, 33.12, 33.84)
qcc(x, type="xbar.one")
## List of 11
## $ call : language qcc(data = x, type = "xbar.one")
## $ type : chr "xbar.one"
## $ data.name : chr "x"
## $ data : num [1:15, 1] 33.8 33 34 33.8 33.5 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:15] 33.8 33 34 33.8 33.5 ...
## ..- attr(*, "names")= chr [1:15] "1" "2" "3" "4" ...
## $ sizes : int [1:15] 1 1 1 1 1 1 1 1 1 1 ...
## $ center : num 33.5
## $ std.dev : num 0.426
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 32.2 34.8
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
qcc(x, type="xbar.one", std.dev = "SD")
## List of 11
## $ call : language qcc(data = x, type = "xbar.one", std.dev = "SD")
## $ type : chr "xbar.one"
## $ data.name : chr "x"
## $ data : num [1:15, 1] 33.8 33 34 33.8 33.5 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:15] 33.8 33 34 33.8 33.5 ...
## ..- attr(*, "names")= chr [1:15] "1" "2" "3" "4" ...
## $ sizes : int [1:15] 1 1 1 1 1 1 1 1 1 1 ...
## $ center : num 33.5
## $ std.dev : num 0.342
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 32.5 34.5
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
data(pistonrings)
attach(pistonrings)
## The following object is masked _by_ .GlobalEnv:
##
## diameter
## The following objects are masked from pistonrings (pos = 3):
##
## diameter, sample, trial
# 40 sample of 5 obs each
qcc.groups(diameter, sample)
## [,1] [,2] [,3] [,4] [,5]
## 1 74.030 73.995 73.988 74.002 73.992
## 2 74.009 73.995 73.985 74.008 73.998
## 3 73.994 74.004 73.983 74.006 74.012
## 4 74.000 73.994 74.006 73.984 74.000
## 5 73.988 74.004 74.010 74.015 73.982
## 6 74.012 73.995 73.987 74.008 74.003
## 7 73.994 74.008 74.001 74.015 74.030
## 8 74.001 74.015 74.035 74.017 74.010
## 9 74.002 73.992 74.024 73.996 74.007
## 10 73.994 74.006 74.003 73.995 74.000
## 11 73.998 74.000 74.002 73.967 74.014
## 12 73.984 74.012 74.010 74.002 74.010
## 13 74.001 73.999 73.989 74.008 73.984
## 14 74.015 74.010 73.999 74.010 74.000
## 15 74.003 74.002 74.004 74.000 74.005
## 16 73.990 74.020 74.010 74.013 74.005
## 17 74.019 74.001 74.021 73.993 74.015
## 18 73.997 73.994 73.993 74.009 73.990
## 19 73.994 74.007 73.998 73.994 73.998
## 20 74.005 73.986 74.018 74.003 74.013
## 21 74.009 73.990 73.990 73.993 73.995
## 22 74.030 73.990 73.985 74.003 74.001
## 23 74.015 74.018 73.990 74.016 74.000
## 24 73.995 74.024 74.012 74.036 74.029
## 25 73.992 NA 74.005 74.015 73.989
## 26 73.985 74.000 74.015 74.005 74.007
## 27 73.995 74.000 NA 74.000 NA
## 28 73.998 74.005 74.003 74.005 NA
## 29 74.005 74.006 74.009 74.000 74.017
## 30 73.986 74.015 74.000 73.991 73.986
## 31 74.020 73.995 73.996 74.025 74.016
## 32 74.010 74.005 74.015 74.025 74.000
## 33 74.008 NA 74.002 74.009 74.014
## 34 NA NA 73.988 NA 73.995
## 35 73.990 73.996 NA 73.984 NA
## 36 73.996 NA 74.000 73.997 NA
## 37 73.996 74.009 74.014 74.010 74.013
## 38 74.000 74.001 73.990 74.006 73.997
## 39 74.004 74.005 73.998 74.000 74.012
## 40 74.024 74.019 74.026 74.026 74.020
# some obs are removed, the result is still a 40x5 matrix but with NAs added
qcc.groups(diameter[-c(1,2,50,52, 199)], sample[-c(1,2,50,52, 199)])
## [,1] [,2] [,3] [,4] [,5]
## 1 73.988 74.002 73.992 NA NA
## 2 74.009 73.995 73.985 74.008 73.998
## 3 73.994 74.004 73.983 74.006 74.012
## 4 74.000 73.994 74.006 73.984 74.000
## 5 73.988 74.004 74.010 74.015 73.982
## 6 74.012 73.995 73.987 74.008 74.003
## 7 73.994 74.008 74.001 74.015 74.030
## 8 74.001 74.015 74.035 74.017 74.010
## 9 74.002 73.992 74.024 73.996 74.007
## 10 73.994 74.006 74.003 73.995 NA
## 11 73.998 74.002 73.967 74.014 NA
## 12 73.984 74.012 74.010 74.002 74.010
## 13 74.001 73.999 73.989 74.008 73.984
## 14 74.015 74.010 73.999 74.010 74.000
## 15 74.003 74.002 74.004 74.000 74.005
## 16 73.990 74.020 74.010 74.013 74.005
## 17 74.019 74.001 74.021 73.993 74.015
## 18 73.997 73.994 73.993 74.009 73.990
## 19 73.994 74.007 73.998 73.994 73.998
## 20 74.005 73.986 74.018 74.003 74.013
## 21 74.009 73.990 73.990 73.993 73.995
## 22 74.030 73.990 73.985 74.003 74.001
## 23 74.015 74.018 73.990 74.016 74.000
## 24 73.995 74.024 74.012 74.036 74.029
## 25 73.992 NA 74.005 74.015 73.989
## 26 73.985 74.000 74.015 74.005 74.007
## 27 73.995 74.000 NA 74.000 NA
## 28 73.998 74.005 74.003 74.005 NA
## 29 74.005 74.006 74.009 74.000 74.017
## 30 73.986 74.015 74.000 73.991 73.986
## 31 74.020 73.995 73.996 74.025 74.016
## 32 74.010 74.005 74.015 74.025 74.000
## 33 74.008 NA 74.002 74.009 74.014
## 34 NA NA 73.988 NA 73.995
## 35 73.990 73.996 NA 73.984 NA
## 36 73.996 NA 74.000 73.997 NA
## 37 73.996 74.009 74.014 74.010 74.013
## 38 74.000 74.001 73.990 74.006 73.997
## 39 74.004 74.005 73.998 74.000 74.012
## 40 74.024 74.019 74.026 74.020 NA
This function can be used to control the behavior of the ‘qcc’ library such as the background color, out-of-control points appearance, and many others.
old <- qcc.options() # save defaults
qcc.options("cex.stats") # get a single parameter
## [1] 0.9
qcc.options("cex.stats"=1.2) # change parameters
qcc.options(bg.margin="azure2")
qcc.options("violating.runs" = list(pch = 15, col = "purple"))
qcc.options("beyond.limits" = list(pch = 15, col = "orangered"))
qcc(rnorm(100), type = "xbar.one", std.dev = 0.7) # see the results
## List of 11
## $ call : language qcc(data = rnorm(100), type = "xbar.one", std.dev = 0.7)
## $ type : chr "xbar.one"
## $ data.name : chr "rnorm(100)"
## $ data : num [1:100, 1] -1.063 -0.281 -0.922 0.555 1.014 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:100] -1.063 -0.281 -0.922 0.555 1.014 ...
## ..- attr(*, "names")= chr [1:100] "1" "2" "3" "4" ...
## $ sizes : int [1:100] 1 1 1 1 1 1 1 1 1 1 ...
## $ center : num 0.0929
## $ std.dev : num 0.7
## $ nsigmas : num 3
## $ limits : num [1, 1:2] -2.01 2.19
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
qcc.options(old) # restore old defaults
# data from Wetherill and Brown (1991) pp. 212--213, 216--218:
x <- c(12,11,18,11,10,16,9,11,14,15,11,9,10,13,12,
8,12,13,10,12,13,16,12,18,16,10,16,10,12,14)
size <- rep(50, length(x))
qcc.overdispersion.test(x,size)
##
## Overdispersion test Obs.Var/Theor.Var Statistic p-value
## binomial data 0.7644566 22.16924 0.81311
x <- c(11,8,13,11,13,17,25,23,11,16,9,15,10,16,12,
8,9,15,4,12,12,12,15,17,14,17,12,12,7,16)
qcc.overdispersion.test(x)
##
## Overdispersion test Obs.Var/Theor.Var Statistic p-value
## poisson data 1.472203 42.69388 0.048579
shewhart.rules
stats.c
stats.g
success <- rbinom(1000, 1, 0.01)
num.noevent <- diff(which(c(1,success)==1))-1
qcc(success, type = "np", sizes = 1)
## List of 11
## $ call : language qcc(data = success, type = "np", sizes = 1)
## $ type : chr "np"
## $ data.name : chr "success"
## $ data : int [1:1000, 1] 0 0 0 0 0 0 0 0 0 0 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named int [1:1000] 0 0 0 0 0 0 0 0 0 0 ...
## ..- attr(*, "names")= chr [1:1000] "1" "2" "3" "4" ...
## $ sizes : num [1:1000] 1 1 1 1 1 1 1 1 1 1 ...
## $ center : num 0.01
## $ std.dev : num 0.0995
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 0 0.308
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
qcc(num.noevent, type = "g")
## Warning in limits.g(center = 94.6, std.dev = 94.0986716165537, sizes =
## c(1L, : The Geometric distribution is quite skewed, it is better to set
## conf at the required confidence level (0 < conf < 1) instead of as a
## multiplier of sigma.
## List of 11
## $ call : language qcc(data = num.noevent, type = "g")
## $ type : chr "g"
## $ data.name : chr "num.noevent"
## $ data : num [1:10, 1] 72 157 69 190 11 49 90 53 173 82
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:10] 72 157 69 190 11 49 90 53 173 82
## ..- attr(*, "names")= chr [1:10] "1" "2" "3" "4" ...
## $ sizes : int [1:10] 1 1 1 1 1 1 1 1 1 1
## $ center : num 94.6
## $ std.dev : num 94.1
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 0 377
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
stats.np
stats.p
stats.R
stats.S
stats.T2
stats.T2.single
stats.u
stats.xbar
stats.xbar.one
# Water content of antifreeze data (Wetherill and Brown, 1991, p. 120)
x <- c(2.23, 2.53, 2.62, 2.63, 2.58, 2.44, 2.49, 2.34, 2.95, 2.54, 2.60, 2.45,
2.17, 2.58, 2.57, 2.44, 2.38, 2.23, 2.23, 2.54, 2.66, 2.84, 2.81, 2.39,
2.56, 2.70, 3.00, 2.81, 2.77, 2.89, 2.54, 2.98, 2.35, 2.53)
# the Shewhart control chart for one-at-time data
# 1) using MR (default)
qcc(x, type="xbar.one", data.name="Water content (in ppm) of batches of antifreeze")
## List of 11
## $ call : language qcc(data = x, type = "xbar.one", data.name = "Water content (in ppm) of batches of antifreeze")
## $ type : chr "xbar.one"
## $ data.name : chr "Water content (in ppm) of batches of antifreeze"
## $ data : num [1:34, 1] 2.23 2.53 2.62 2.63 2.58 2.44 2.49 2.34 2.95 2.54 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:34] 2.23 2.53 2.62 2.63 2.58 2.44 2.49 2.34 2.95 2.54 ...
## ..- attr(*, "names")= chr [1:34] "1" "2" "3" "4" ...
## $ sizes : int [1:34] 1 1 1 1 1 1 1 1 1 1 ...
## $ center : num 2.57
## $ std.dev : num 0.179
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 2.03 3.11
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
# 2) using SD
qcc(x, type="xbar.one", std.dev = "SD", data.name="Water content (in ppm) of batches of antifreeze")
## List of 11
## $ call : language qcc(data = x, type = "xbar.one", std.dev = "SD", data.name = "Water content (in ppm) of batches of antifreeze")
## $ type : chr "xbar.one"
## $ data.name : chr "Water content (in ppm) of batches of antifreeze"
## $ data : num [1:34, 1] 2.23 2.53 2.62 2.63 2.58 2.44 2.49 2.34 2.95 2.54 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:34] 2.23 2.53 2.62 2.63 2.58 2.44 2.49 2.34 2.95 2.54 ...
## ..- attr(*, "names")= chr [1:34] "1" "2" "3" "4" ...
## $ sizes : int [1:34] 1 1 1 1 1 1 1 1 1 1 ...
## $ center : num 2.57
## $ std.dev : num 0.222
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 1.9 3.23
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
# "as the size increases further, we would expect sigma-hat to settle down
# at a value close to the overall sigma-hat" (Wetherill and Brown, 1991,
# p. 121)
sigma <- NA
k <- 2:24
for (j in k)
sigma[j] <- sd.xbar.one(x, k=j)
plot(k, sigma[k], type="b") # plot estimates of sigma for
abline(h=sd(x), col=2, lty=2) # different values of k