### R code from vignette source 'chLossFunction.Rnw' ################################################### ### code chunk number 1: chLossFunction.Rnw:15-18 (eval = FALSE) ################################################### ## source("../../R/chOptions.R") ## setwd("E:/eclipseprojects/SixSigma_Book/Book/chSweave/chLossFunction") ## #setwd("/media/Datos/R/workspace/SixSigma_Book/Book/chSweave/chLossFunction") ################################################### ### code chunk number 2: chLossFunction.Rnw:124-140 ################################################### curve(dnorm(x,10,.5),8,12, type="l", lty=2, ylab="frequency", las=1, xlab="Observed value of the characteristic", axes=FALSE) axis(side=1, labels=FALSE) axis(side=2, labels=FALSE) abline(v=11.5) abline(v=8.5) abline(v=10) abline(h=0) text(10.1,0.6,"T") text(8.8,0.6,"LSL") text(11.8,0.6,"USL") text(11,0.2,"Variation") box("outer") ################################################### ### code chunk number 3: chLossFunction.Rnw:171-189 ################################################### curve(2*x^2,-10,10, axes=FALSE, lty=0, ylab="Cost of Poor Quality", xlab="Observed value of the characteristic") axis(side=1, labels=FALSE) axis(side=2, labels=FALSE) abline(v=-8) abline(v=8) abline(v=0) abline(h=0) text(0.5,100,"T") text(-8.7,100,"LSL") text(8.7,100,"USL") lines(c(-11,-8.1),c(128,128), lty=3, lwd=3) lines(c(-8.1,-8.1),c(128,0.3), lty=3, lwd=3) lines(c(-8.1,8.1),c(0.3,0.3), lty=3, lwd=3) lines(c(8.1,8.1), c(0.3, 128), lty=3, lwd=3) lines(c(8.1,11), c(128,128), lty=3, lwd=3) box("outer") ################################################### ### code chunk number 4: chLossFunction.Rnw:250-268 ################################################### curve(0.5*(x)^2,-10,10, axes=FALSE, lty=1, lwd=2, ylab="Cost of Poor Quality", xlab="Observed value of the characteristic") text(-5, 0.5*25, "k=0.5 ", adj=1) axis(side=1, labels=FALSE) axis(side=2, labels=FALSE) abline(v=-8, lty=2) abline(v=8, lty=2) abline(v=0, lty=2) abline(h=0) text(0.5,50,"T") text(-8.7,50,"LSL") text(8.7,50,"USL") curve(1*(x)^2,-10,10, lty=1, lwd=2, add=TRUE) text(-5, 25, "k=1 ", adj=1) curve(2*(x)^2,-10,10, lty=1, lwd=2, add=TRUE) text(-4.5, 40, "k=2 ", adj=1) box("outer") ################################################### ### code chunk number 5: chLossFunction.Rnw:327-328 ################################################### 0.001/0.5 ################################################### ### code chunk number 6: curva (eval = FALSE) ################################################### ## curve(0.002 * (x - 10)^2, 9, 11, ## lty = 1, ## lwd = 2, ## ylab = "Cost of Poor Quality", ## xlab = "Observed value of the characteristic", ## main = expression(L(Y) == 0.002 ~ (Y - 10)^2)) ## abline(v = 9.5, lty = 2) ## abline(v = 10.5, lty = 2) ## abline(v = 10, lty = 2) ## abline(h = 0) ## text(10, 0.002, "T", adj = 2) ## text(9.5, 0.002, "LSL", adj = 1) ## text(10.5, 0.002, "USL", adj = -0.1) ################################################### ### code chunk number 7: chLossFunction.Rnw:356-358 ################################################### curve(0.002 * (x - 10)^2, 9, 11, lty = 1, lwd = 2, ylab = "Cost of Poor Quality", xlab = "Observed value of the characteristic", main = expression(L(Y) == 0.002 ~ (Y - 10)^2)) abline(v = 9.5, lty = 2) abline(v = 10.5, lty = 2) abline(v = 10, lty = 2) abline(h = 0) text(10, 0.002, "T", adj = 2) text(9.5, 0.002, "LSL", adj = 1) text(10.5, 0.002, "USL", adj = -0.1) box("outer") ################################################### ### code chunk number 8: chLossFunction.Rnw:401-406 ################################################### ss.bookTable(matrix(ss.data.bolts$diameter,ncol=5), tcaption = "Data for the bolts example.", tlabel = "tab:lfa:sample", trows = FALSE, tcols = FALSE, tdigits = 4) ################################################### ### code chunk number 9: chLossFunction.Rnw:412-413 ################################################### 0.002*(sum((ss.data.bolts$diameter-10)^2))/length(ss.data.bolts$diameter) ################################################### ### code chunk number 10: chLossFunction.Rnw:432-434 ################################################### 100000 * 0.002 * (sum((ss.data.bolts$diameter - 10)^2))/ length(ss.data.bolts$diameter) ################################################### ### code chunk number 11: lfa ################################################### ss.lfa(ss.data.bolts, "diameter", 0.5, 10, 0.001, lfa.sub = "10 mm. Bolts Project", lfa.size = 100000, lfa.output = "both") ################################################### ### code chunk number 12: chLossFunction.Rnw:525-526 ################################################### ss.lfa(ss.data.bolts, "diameter", 0.5, 10, 0.001, lfa.sub = "10 mm. Bolts Project", lfa.size = 100000, lfa.output = "both") ################################################### ### code chunk number 13: chLossFunction.Rnw:540-543 ################################################### my.lfa <- ss.lfa(ss.data.bolts, "diameter", 0.5, 10, 0.001, lfa.sub = "10 mm. Bolts Project", lfa.size = 100000, lfa.output = "both") ################################################### ### code chunk number 14: chLossFunction.Rnw:585-603 ################################################### curve(0.5*(x)^2,0,10, axes=FALSE, lty=1, lwd=2, ylab="Cost of Poor Quality", xlab="Observed value of the characteristic") text(5, 0.5*25, "k=0.5 ", adj=1) axis(side=1, at=c(0,1:8), labels=c("0",rep("",8))) axis(side=2, at=c(0,seq(1,80, 5)), labels=c("0", rep("",16))) #abline(v=-8, lty=2) abline(v=5.5, lty=2) abline(v=0, lty=1, lwd=2) abline(h=0, lwd=2) text(0.5,50,"T") #text(-8.7,50,"LSL") text(6,50,"USL") curve(1*(x)^2,-10,10, lty=1, lwd=2, add=TRUE) text(5, 25, "k=1 ", adj=1) curve(2*(x)^2,-10,10, lty=1, lwd=2, add=TRUE) text(4.5, 40, "k=2 ", adj=1) box("outer") ################################################### ### code chunk number 15: chLossFunction.Rnw:631-651 ################################################### curve(40*(1/(x)^2), 0, axes=FALSE, lty=1, lwd=2, ylab="Cost of Poor Quality", xlab="Observed value of the characteristic", xlim=c(0,6), ylim=c(0,50)) text(1.95, 15, "k1 ", adj=1) axis(side=1, at=c(0,1:8), labels=c("0",rep("",8))) axis(side=2, at=c(0,seq(1,80, 5)), labels=c("0", rep("",16))) #abline(v=-8, lty=2) abline(v=2, lty=2) abline(v=0, lty=1, lwd=2) abline(h=0, lwd=2) text(0.1,50,"T") #text(-8.7,50,"LSL") text(2.2,50,"LSL") curve(20*(1/(x)^2),0,10, lty=1, lwd=2, add=TRUE) text(1.45, 8, "k2 ", adj=1) curve(5*(1/(x)^2),0,10, lty=1, lwd=2, add=TRUE) text(0.8, 5, "k3 ", adj=1) box("outer")