### Section 4: Validity confirmation
library("edcc")
######### ecoXbar
## 1
ecoXbar(lambda = 0.01, P0 = 200, P1 = 100, T0 =.05, Tc = 2, Cf = 50,
Cr = 25, a = 0.5, b = 0.1)
## 5
# change the initial values for the parameters to be optimized over or
# use grid method
#ecoXbar(lambda = 0.01, P0 = 2000, P1 = 1000, T0 =.05,
#Tc = 2, Cf = 50, Cr = 25, a = 0.5, b = 0.1)
ecoXbar(par = c(0.5, 1, 5), lambda = 0.01, P0 = 2000, P1 = 1000, T0
=.05, Tc = 2, Cf = 50, Cr = 25, a = 0.5, b = 0.1)
## 21
ecoXbar(lambda = 0.01, delta = 0.5, P0 = 3.25, P1 = 1, T0 =.05, Tc = 2,
Cf = 50, Cr = 25, a = 0.5, b = 0.1)
######### ecoCusum
## 1
(y1 <- ecoCusum(P0 = 150, P1 = 50, Cr = 30, d1 = 0, d2 = 0, method = "BFGS"))
(y2 <- ecoCusum(P0 = 150, P1 = 50, Cr = 30, d1 = 0, d2 = 0, lambda = 0.05))
# for this case, optimization method doesn't work, so we have to use the grid method: search the region step by step
#(y14 <- ecoCusum(P0=150,P1=50,Cr=30,delta=0.5,d1=0,d2=0))
(yy14 <- ecoCusum(h = seq(2.55, 2.65, by = 0.01), H = seq(0.3, 0.4, by
= 0.01), n = 28:30, P0 = 150, P1 = 50, Cr = 30, delta = 0.5, d1 = 0,
d2 = 0))
######### ecoEwma
## 1
ecoEwma(w = seq(0.5,1 ,by = 0.1), lambda = 0.01, P0 = 200, P1 = 100,
T0 =.05, Tc = 2, Cf = 50, Cr = 25, a = 0.5, b = 0.1)
(zz1 <- ecoEwma(n = 4:6, w=seq(0.9, 0.95, by = 0.01), lambda = 0.01, P0
= 200, P1 = 100, T0 = 0.05, Tc = 2, Cf = 50, Cr = 25, a = 0.5, b = 0.1))
## 5
ecoEwma(w = seq(0.5, 1, by=.1), lambda = 0.01, P0 = 2000, P1 = 1000,
T0 = 0.05, Tc = 2, Cf = 50, Cr = 25, a = 0.5, b = 0.1)
(zz5 <- ecoEwma(par = c(0.4, 2.9), w = seq(0.85, 0.95, by = 0.01), n =
3:5, lambda = 0.01, P0 = 2000, P1 = 1000, T0 =.05, Tc = 2, Cf = 50, Cr
= 25, a = 0.5, b = 0.1))
## 21
ecoEwma(w = seq(0.1, 1, by = 0.1), lambda = 0.01, delta = 0.5, P0 =
3.25, P1 = 1, T0 =.05, Tc = 2, Cf = 50, Cr = 25, a = 0.5, b = 0.1)
(zz21 <- ecoEwma(n = 34:39, w = seq(0.8, 0.9, by = 0.01), lambda =
0.01, delta = 0.5, P0 = 3.25, P1 = 1, T0 = 0.05, Tc = 2, Cf = 50, Cr =
25, a = 0.5, b = 0.1))
### Section 5: A classical example
(x <- ecoXbar(lambda = 0.05, delta = 2, P0 = 110, P1 = 10, Cr = 25, Cf
= 50, T0 = 0.0167, Tc = 1, Tf = 0, Tr = 0, a = 1, b = 0.1, d1 = 1, d2
= 1))
x1 <- update(x, h = seq(0.7, 0.9, by = 0.01), L = seq(2.8, 3.2, by =
0.01), n = 4:6, contour.plot = TRUE, call.print = FALSE)
x1
(y <- ecoCusum (lambda = 0.05, delta = 2, P0 = 110, P1 = 10, Cr = 25,
Cf = 50, T0 = 0.0167, Tc = 1, Tf = 0, Tr = 0, a = 1, b = 0.1, d1 = 1,
d2 = 1, sided = "two"))
y1 <- update(y, h = seq(0.75, 0.9, by = 0.01), H = seq(0.6, 0.9, by =
.01), n = 4:6, contour.plot = TRUE, call.print = FALSE)
y1
z <- ecoEwma(w = seq(0.1, 1, by = 0.1), lambda = 0.05, delta = 2, P0 =
110, P1 = 10, Cr = 25, Cf= 50, T0 = 0.0167, Tc = 1, Tf = 0, Tr = 0, a
= 1, b = 0.1, d1 = 1, d2= 1)
z
z1 <- update(z, h = seq(0.7, 0.9, by = 0.01), w = seq(0.8, 1, by = 0.01),
k = seq(2.9, 3.1, by = 0.01), n = 4:6, contour.plot = TRUE, call.print
= FALSE)
z1
### Section 6: An industrial application
ecoXbar(n = 1:3, lambda = 0.0021, delta = 1.5, C0 = 0, C1 = 52.8, T0 =
0, Tf = 1/6, Tc = 1/6, Tr = 3/4, d1 = 0, d2 = 0, Cf = 105.6, Cr =
16.84, a = 0, b = 0.56, sided = "one")
ecoCusum(n = 1:3, lambda = 0.0021, delta = 1.5, C0 = 0, C1 = 52.8, T0
= 0, Tf = 1/6, Tc = 1/6, Tr = 3/4, d1 = 0, d2 = 0, Cf = 105.6, Cr =
16.84, a = 0, b = 0.56, sided = "one")
a <- ecoEwma(n = 1:3, w = seq(0.1, 1, by = 0.1), lambda = 0.0021, delta
= 1.5, C0 = 0, C1 = 52.8, T0 = 0, Tf = 1/6, Tc = 1/6, Tr = 3/4, d1 =
0, d2 = 0, Cf = 105.6, Cr = 16.84, a = 0, b = 0.56, sided = "one")
a$optimum
a1 <- update(a, w = seq(0.6, 0.8, by = 0.01))
a1$cost.frame <- NULL; a1
## reset delta to 0.5
ecoXbar(n = 1:3, lambda = 0.0021, delta = 0.5, C0 = 0, C1 = 52.8, T0 =
0, Tf = 1/6, Tc = 1/6, Tr = 3/4, d1 = 0, d2 = 0, Cf = 105.6, Cr =
16.84, a = 0, b = 0.56, sided = "one")
ecoCusum(n = 1:3, lambda = 0.0021, delta = 0.5, C0 = 0, C1 = 52.8, T0
= 0, Tf = 1/6, Tc = 1/6, Tr = 3/4, d1 = 0, d2 = 0, Cf = 105.6, Cr =
16.84, a = 0, b = 0.56, sided = "one")
b <- ecoEwma(n = 1:3, w = seq(0.1, 1, by = 0.1), lambda = 0.0021, delta
= 0.5, C0 = 0, C1 = 52.8, T0 = 0, Tf =1/6, Tc = 1/6, Tr = 3/4, d1 = 0,
d2 = 0, Cf = 105.6, Cr = 16.84, a = 0, b = 0.56, sided = "one")
b$optimum
b1 <- update(b, w = seq(0.1, 0.3, by = 0.01))
b1$cost.frame <- NULL; b1