getARL: Average Run Length (ARL)

Description Usage Arguments Value Examples

View source: R/UnivariateObtainAverageRunLength.R

Description

Get the ARL getRL

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
getARL(
  n,
  m,
  theta = NULL,
  Ftheta = NULL,
  dist,
  mu,
  sigma,
  dist.par = c(0, 1, 1),
  chart,
  chart.par,
  scoring = "Z",
  Chi2corrector = "None",
  replicates = 10000,
  isParallel = TRUE,
  print.RL = FALSE,
  progress = FALSE,
  calibrate = FALSE,
  arl0 = 370,
  alignment = "unadjusted",
  constant = NULL,
  absolute = FALSE,
  isFixed = FALSE,
  rounding.factor = NULL
)

Arguments

n

scalar. Subroup size

m

scalar. Reference sample size

theta

scalar. Value corresponig with the Ftheta quantile.

Ftheta

scalar. Quantile of the data distribution. The values that take are between (0,1).

dist

character string. Select from:

  • "Uniform: Continuous Uniform distribution .

  • "Normal": Normal distribution (default).

  • "Normal2": Squared Normal distribution (also known as Chi-squared).

  • "DoubleExp": Double exponential distribution (also known as Laplace distribution).

  • "DoubleExp2": Double exponential squared distribution from a DoubleExp(0,1).

  • "LogNormal": Lognormal distribution.

  • "Gamma": Gamma distribution.

  • "Weibull": Weibull distribution.

  • "t": Student-t distribution.

mu

vector. Two elements, the first one is the mean of the reference sample and the second one is the mean of the monitoring sample.

sigma

vector. Two elements, the first one is the sd of the reference sample and the second one is the sd of the monitoring sample.

dist.par

vector. Distribution parameters. c(par.a, par.b). Default c(0,1).

chart

character string. Selected type of chart. Three options are available: Shewhart, CUSUM, EWMA

chart.par

vector. The size depends on the selected chart:

Shewhart scheme:

is c(k), where k comes from UCL = mu + kσ, LCL = mu - kσ.

CUSUM scheme:

is c(k, h, t) where k is the reference value and h is the control limit, and t is the type of the chart (1:positive, 2:negative, 3:two sides)

EWMA scheme:

is c(lambda, L), where lambda is the smoothing constant and L multiplies standard deviation to get the control limit

scoring

character string. If "Z" (normal scores) (default). If "Z-SQ" (normal scores squared).

Chi2corrector

character string. Only when scoring is Z-SQ. Select from

  • "approx: Z^2*(m + 1 + 1.3)/(m+1).

  • "exact": Z^2/mean(Z).

  • "none": Z^2.

If "approx" () (default). If "exact" (normal scores squared).

replicates

scalar. Number of replicates to get the ARL

isParallel

logical. If TRUE the code runs in parallel according to the number of cores in the computer,otherwise the code runs sequentially. Default TRUE.

print.RL

logical. If TRUE return the vectors of RL for each iteration.

progress

logical. If TRUE it shows the progress in the console.

calibrate

logical. If TRUE the RL is limit to 10 times the target ARL.

arl0

scalar. Expected value of the RL. Default 370.

alignment

character string. Aligment of the data X and Y. Select from

  • "unadjusted": nothing is sustracte from X and Y (default).

  • "overallmean": overall mean is sustracted from X and Y.

  • "overallmedian": overall median is sustracted from X and Y.

  • "samplemean": mean from corresponding group (X and Y) is sustracted from its corresponing vector.

  • "samplemedian": median from corresponding group (X and Y) is sustracted from its corresponing vector.

  • "referencemean": mean from Y is subtracted from X and Y.

  • "referencemedian": median from Y is subtracted from X and Y.

  • "constantvalue": a constant value is subtracted from X and Y.

constant

scalar. Only used when the alignment is selected "constantvalue". Default NULL.

absolute

logical. If TRUE, the absolute aligned values are obtained. (Default FALSE)

isFixed

logical. If TRUE the reference sample does not update, otherwise the reference sample is updated whenever the batch is in control.

rounding.factor

scalar. positive value that determine the range between two consecutive rounded values.

Value

Multiple output. Select by output$

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
n <- 5 # subgroup size
m <- 100 # reference-sample size
dist <- "Normal"
mu <- c(0, 0) # c(reference sample mean, monitoring sample mean)
sigma <- c(1, 1) # c(reference sample sd, monitoring sample sd)

#### Normal distribution parameters
dist.par <- c(0, 1) # c(location, scale)

#### Other Parameters
replicates <- 2
print.RL <- TRUE
isParallel <- FALSE
calibrate <- FALSE
progress <- TRUE
arl0 <- 370

#### Control chart parameters
chart <- "Shewhart"
chart.par <- c(3)
shewhart <- getARL(n, m,
  theta = NULL, Ftheta = NULL, dist, mu, sigma, dist.par = dist.par,
  chart = chart, chart.par = chart.par, print.RL = print.RL,
  replicates = replicates, isParallel = isParallel,
  calibrate = calibrate, arl0 = arl0
)

chart <- "CUSUM"
chart.par <- c(0.25, 4.4181, 3)
cusum <- getARL(n, m,
  theta = NULL, Ftheta = NULL, dist, mu, sigma, dist.par = dist.par,
  chart = chart, chart.par = chart.par, print.RL = print.RL,
  replicates = replicates, isParallel = isParallel,
  calibrate = calibrate, arl0 = arl0
)

chart <- "EWMA"
chart.par <- c(0.2, 2.962)
shewhart <- getARL(n, m,
  theta = NULL, Ftheta = NULL, dist, mu, sigma, dist.par = dist.par,
  chart = chart, chart.par = chart.par, print.RL = print.RL,
  replicates = replicates, isParallel = isParallel,
  calibrate = calibrate, arl0 = arl0
)

LuisBenavides/SNS documentation built on April 11, 2021, 3:50 p.m.