File: x.res.ewma.arl.R

package info (click to toggle)
r-cran-spc 1%3A0.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,888 kB
  • sloc: ansic: 22,279; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 766 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Computation of res-EWMA ARLs (mean monitoring)
x.res.ewma.arl <- function(l, c, mu, alpha=0, n=5, hs=0, r=40) {
  if ( l <= 0 || l > 1 )
    stop("l has to be between 0 and 1")
  if ( c <= 0 )
    warning("usually, c has to be positive")
  if ( abs(alpha) > 1 )
    warning("nonstationary AR(1) process")
  if ( n < 1 )
    warning("n is too small")
  n <- round(n)
  if ( abs(hs) > c ) 
    warning("unusual headstart")
  if ( r < 4 )
    stop("r is too small")
  ctyp <- 1 # later more
  arl <- .C("x_res_ewma_arl",as.double(alpha),as.integer(n),
            as.integer(ctyp),as.double(l),
            as.double(c),as.double(hs),
            as.double(mu),as.integer(r),
            ans=double(length=1),PACKAGE="spc")$ans 
  names(arl) <- "arl"
  return (arl)
}