ggplot2 - R: Non-normal distribution with specification limits -> quartiles & Cp/Cpk -
i having problem plot quartiles of mixed distribution , furthermore calculate cp & cpk.
my data:
> dput(hist) structure(list(index = c(1, 10, 11, 12, 128044, 128045, 128046, 128047, 128048, 128049, 128050, 128051, 128052, 128053, 128054, 128055, 128056, 128057, 128058, 128059, 128060, 128061, 128062, 128063, 128064, 128065, 128066, 128067, 128068, 128069, 128070, 128071, 128072, 128073, 128074, 128075, 128076, 128077, 128078, 128079, 128080, 128081, 128082, 13, 14, 15, 150780, 150781, 150782, 150783, 150784, 150785, 150786, 150787, 150788, 150789, 150790, 150791, 150792, 150793, 150794, 150795, 150796, 150797, 150798, 150799, 150800, 16, 163525, 163526, 163527, 163528, 163529, 163530, 163531, 163532, 163533, 163534, 163535, 163536, 163537, 163538, 163539, 163540, 163541, 163542, 163543, 163544, 163545, 163546, 163547, 163548, 163549, 163550, 163551, 163552, 17), rundheit = c(0.24, 0.25, 0.23, 0.24, 0.23, 0.24, 0.22, 0.24, 0.21, 0.22, 0.23, 0.24, 0.22, 0.24, 0.27, 0.23, 0.26, 0.27, 0.35, 0.27, 0.27, 0.27, 0.27, 0.27, 0.28, 0.32, 0.31, 0.3, 0.29, 0.28, 0.28, 0.27, 0.28, 0.27, 0.28, 0.28, 0.29, 0.29, 0.28, 0.28, 0.27, 0.26, 0.27, 0.23, 0.26, 0.24, 0.17, 0.52, 0.18, 0.19, 0.17, 0.18, 0.18, 0.18, 0.18, 0.2, 0.17, 0.17, 0.18, 0.18, 0.18, 0.18, 0.18, 0.2, 0.19, 0.18, 0.18, 0.25, 0.23, 0.23, 0.22, 0.23, 0.23, 0.23, 0.22, 0.23, 0.2, 0.21, 0.21, 0.22, 0.23, 0.23, 0.23, 0.23, 0.22, 0.22, 0.23, 0.22, 0.22, 0.22, 0.23, 0.23, 0.23, 0.23, 0.23, 0.23, 0.24)), .names = c("index", "rundheit"), row.names = c(17l, 45l, 311125l, 622233l, 872553l, 872581l, 872609l, 872637l, 872665l, 872693l, 872749l, 872777l, 872805l, 872833l, 872861l, 872889l, 872917l, 872945l, 872973l, 873001l, 873057l, 873085l, 873113l, 873141l, 873169l, 873197l, 873225l, 873253l, 873281l, 873309l, 873365l, 873393l, 873421l, 873449l, 873477l, 873505l, 873533l, 873561l, 873589l, 873617l, 873673l, 873701l, 873729l, 933341l, 1244449l, 1555557l, 1579889l, 1579917l, 1579945l, 1579973l, 1580001l, 1580029l, 1580057l, 1580085l, 1580113l, 1580141l, 1580197l, 1580225l, 1580253l, 1580281l, 1580309l, 1580337l, 1580365l, 1580393l, 1580421l, 1580449l, 1580533l, 1866665l, 1976397l, 1976425l, 1976453l, 1976481l, 1976509l, 1976565l, 1976593l, 1976621l, 1976649l, 1976677l, 1976705l, 1976733l, 1976761l, 1976789l, 1976817l, 1976873l, 1976901l, 1976929l, 1976957l, 1976985l, 1977013l, 1977041l, 1977069l, 1977097l, 1977125l, 1977181l, 1977209l, 1977237l, 2177773l), na.action = structure(98:100, .names = c("2412637", "2412665", "2412721"), class = "omit"), class = "data.frame")
i have ploted ggplot, , density looks quite good, quartiles (+/-2s , +/- 3s) not correct. plot:
vec <- quantile(hist$rundheit, na.rm = true) ggplot(data=hist, aes(rundheit)) + geom_bar(aes( y=..count..), stat="bin",position="dodge", fill="gray40", colour="white") + stat_density(color="red", geom="line", size=1, position="identity") + geom_vline(xintercept=vec, linetype=2, colour="blue", size=1) + #tolerance/limits geom_vline(aes(xintercept=0.55), size = 1, color="red") + #tolerance/limits geom_vline(aes(xintercept=0), size = 1, color="red")
furthermore have tried calculate cp , cpk using sixsigma
package:
library(sixsigma) cp<- ss.ca.cp(hist$rundheit, 0,0.55) cp [1] 1.922963 cpk <- ss.ca.cpk(hist$rundheit, 0,0.55) cpk [1] 1.658759
however numbers of cp , cpka calculated sixsigma not match numbers received using programme, whereas cp=2.35 , cpk=2.11
just info not have background in statistics
thanks tipps!
how this? after? don't know cp, cpk, lsl , usl are, honest.
(i renamed hist
dat
, hist
commonly used function.)
m <- mean(dat$rundheit) s <- sd(dat$rundheit) vec <- data.frame(val = c(m, m - 3*s, m + 3*s, m - 5*s, m + 5*s), sigma = factor(c('mean', '3s', '3s', '5s', '5s'), c('mean', '3s', '5s'))) library(ggplot2) ggplot(data=dat, aes(rundheit)) + geom_bar(aes( y=..count..), stat="bin",position="dodge", fill="gray40", colour="white") + stat_density(color="red", geom="line", size=1, position="identity") + geom_vline(data = vec, aes(xintercept = val, lty = sigma), colour = "blue", size = 1)
Comments
Post a Comment