cusum: Calculates a sequence of Cusum statistics

Description Usage Arguments Details Value Methods (by generic) References Examples

View source: R/cusum.R

Description

Calculates a sequence of one-sided upper Cusum statistics given the reference value and the control limit.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
cusum(X, k, h, initial = 0, reset = TRUE)

## S3 method for class 'cusum'
print(x, ...)

## S3 method for class 'cusum'
plot(x, indexes = NULL, emphOOC = TRUE, ...)

## S3 method for class 'cusum'
signal(object, ...)

Arguments

X

A numeric vector.

k

The reference value.

h

The upper control limit.

initial

The starting value of the Cusum (C[0]).

reset

Logical indicating whether the Cusum is reset to 0 after crossing the control limit.

x

Object of class cusum

...

Additional arguments to print.default or plot.default. Ignored by the signal method.

indexes

A vector of indexes that select the elements of the cusum statistics that will be plotted.

emphOOC

A logical indicating whether out of control points should be emphasized in red.

object

Object of class cusum

Details

Cusum is assumed to be of the form: C[i] = max(0, C[i-1] + X[i] - k), where the signal occurs when C[i] > h. Note that X can be the Cusum scores, or weights, given by the log-likelihood ratio, in which case k = 0 would make sense.

Value

A object of class cusum, which is a vector of the Cusum statistics, along with the following attributes: X, k, h, initial, and reset (which correspond to the original arguments provided to the function) and resetCounter, a vector of integers corresponding to cusum that indicates when the Cusum resets.

Methods (by generic)

References

Hawkins DM and Olwell DH. (1998) Cumulative Sum Charts and Charting for Quality Improvement. Springer.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
y <- cusum(rnorm(50), 0.2, 2)
y

# Plot the cusum
plot(y)

# Show the indexes where the chart signaled
signal(y)

# A look at the attributes
attributes(y)

Smisc documentation built on May 2, 2019, 2:46 a.m.