## Mittag et al. (1998)
## compare their upper critical value 2.91 that
## leads to the upper control limit via the formula shown below
## (for the usual upper EWMA \eqn{S^2}{S^2})
l <- 0.18
L0 <- 250
df <- 4
limits <- sewma.crit(l, L0, df=df)
limits["cu"]
limits.cu.mittag_et_al <- 1 + sqrt(l/(2-l))*sqrt(2/df)*2.91
limits.cu.mittag_et_al
## Knoth{2005}
## reproduce the critical value given in Figure 2 (c=1.661865) for
## upper EWMA \eqn{S^2}{S^2} with df=1
l <- 0.025
L0 <- 250
df <- 1
limits <- sewma.crit(l, L0, df=df)
cv.Fig2 <- (limits["cu"]-1)/( sqrt(l/(2-l))*sqrt(2/df) )
cv.Fig2
## the small difference (sixth digit after decimal point) stems from
## tighter criterion in the secant rule implemented in the R package.
## demo of unbiased ARL curves
## Deploy, please, not matrix dimensions smaller than 50 -- for the
## sake of accuracy, the value 80 was used.
## Additionally, this example needs between 1 and 2 minutes on a 1.6 Ghz box.
l <- 0.1
L0 <- 500
df <- 4
limits <- sewma.crit(l, L0, df=df, sided="two", mode="unbiased", r=80)
SEWMA.arl <- Vectorize(sewma.arl, vectorize.args="sigma")
SEWMA.ARL <- function(sigma)
SEWMA.arl(l, limits[1], limits[2], sigma, df, sided="two", r=80)
layout(matrix(1:2, nrow=1))
curve(SEWMA.ARL, .75, 1.25, log="y")
curve(SEWMA.ARL, .95, 1.05, log="y")Run the code above in your browser using DataLab