IT Log
SPC - Control Chart 본문
728x90
반응형
Continuous data
install.packages("qcc")
library(qcc)
data(pistonrings)
# 지정된 데이터세트를 load해준다
attach(pistonrings)
# R검색경로에 첨부되어, DB오브젝트에 이름을 지정하여 액세스 가능하게 해준다
diameter = qcc.groups(diameter, sample)
# qcc함수로 데이터를 쉽게 그룹화 해준다
qcc(diameter[1:25,], type = "xbar")
qcc(diameter[1:25,], type = "xbar", newdata = diameter[26:40,])
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)
qcc(diameter[1:25,], type = "xbar", newdata = diameter[26:40,], confidence.level = 0.99)
qcc(diameter[1:25,], type = "R")
qcc(diameter[1:25,], type = "R", newdata = diameter[26:40,])
qcc(diameter[1:25,], type = "S")
qcc(diameter[1:25,], type = "S", newdata = diameter[26:40,])
경고 limit 추가하기
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))
plot(q, restore.par = FALSE)
abline(h = warn.limits, lty = 3, col = "chocolate")
> (warn.limits = limits.xbar(q$center, q$std.dev, q$sizes, 2))
LCL UCL
73.99242 74.00993
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")
qcc(diameter[1:25,], type = "R")
qcc(diameter[1:25,], type = "S")
qcc(diameter[1:25,], type = "xbar", newdata = diameter[26:40,])
qcc(diameter[1:25,], type = "R", newdata = diameter[26:40,])
qcc(diameter[1:25,], type = "S", newdata = diameter[26:40,])
detach(pistonrings)
Attribute data
data(orangejuice)
attach(orangejuice)
qcc(D[trial], sizes = size[trial], type = "p")
remove out-of-control points (orange juice)
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])
detach(orangejuice)
data(orangejuice2)
attach(orangejuice2)
names(D) = sample
qcc(D[trial], sizes = size[trial], type = "p")
q2 = qcc(D[trial], sizes = size[trial], type = "p", newdata=D[!trial], newsizes = size[!trial])
detach(orangejuice2)
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))
data(circuit)
attach(circuit)
qcc(x[trial], sizes = size[trial], type = "c")
remove out-of-control points (orange juice)
inc = setdiff(which(trial), c(6,20))
qcc(x[inc], sizes = size[inc], type = "c", labels = inc)
qcc(x[inc], sizes = size[inc], type = "c", labels = inc,
newdata = x[!trial], newsizes = size[!trial], newlabels = which(!trial))
qcc(x[inc], sizes = size[inc], type = "u", labels = inc,
newdata = x[!trial], newsizes = size[!trial], newlabels = which(!trial))
detach(circuit)
data(pcmanufact)
attach(pcmanufact)
qcc(x, sizes = size, type = "u")
detach(pcmanufact)
data(dyedcloth)
attach(dyedcloth)
qcc(x, sizes=size, type="u")
standradized 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
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")
qcc(x, type="xbar.one", std.dev = "SD")
출처 : https://www.rdocumentation.org/packages/qcc/versions/2.6/topics/qcc
Grouped-data (EWMA)
data(pistonrings)
attach(pistonrings)
diameter = qcc.groups(diameter, sample)
q = ewma(diameter[1:25,], lambda=0.2, nsigmas = 3)
summary(q)
Call:
ewma(data = diameter[1:25, ], lambda = 0.2, nsigmas = 3)
ewma chart for diameter[1:25, ]
Summary of group statistics:
Min. 1st Qu. Median Mean 3rd Qu. Max.
73.99540 73.99900 74.00140 74.00296 74.00680 74.01920
Summary of group sample sizes:
sizes 4 5
counts 1 24
Number of groups: 25
Center of group statistics: 74.00298
Standard deviation: 0.01192384
Smoothing parameter: 0.2
Control limits:
LCL UCL
1 73.99978 74.00618
2 73.99889 74.00708
...
25 73.99702 74.00895
q = ewma(diameter[1:25,], lambda=0.2, nsigmas = 2.7, newdata = diameter[26:40,], plot=FALSE)
summary(q)
plot(q)
Call:
ewma(data = diameter[1:25, ], lambda = 0.2, nsigmas = 2.7, newdata = diameter[26:40, ], plot = FALSE)
ewma chart for diameter[1:25, ]
Summary of group statistics:
Min. 1st Qu. Median Mean 3rd Qu. Max.
73.99540 73.99900 74.00140 74.00296 74.00680 74.01920
Summary of group sample sizes:
sizes 4 5
counts 1 24
Number of groups: 25
Center of group statistics: 74.00298
Standard deviation: 0.01192384
Summary of group statistics in diameter[26:40, ]:
Min. 1st Qu. Median Mean 3rd Qu. Max.
73.99000 73.99800 74.00275 74.00329 74.00832 74.02300
Summary of group sample sizes:
sizes 2 3 4 5
counts 1 3 2 9
Number of groups: 15
Smoothing parameter: 0.2
Control limits:
LCL UCL
1 74.00010 74.00586
2 73.99930 74.00667
...
40 73.99818 74.00778
728x90
반응형
Comments