Function to process sts object by binomial, beta-binomial or multinomial CUSUM as described by Höhle (2010). Logistic, multinomial logistic, proportional odds or Bradley-Terry regression models are used to specify in-control and out-of-control parameters. The implementation is illustrated in Salmon et al. (2016).

## Usage

categoricalCUSUM(stsObj,control = list(range=NULL,h=5,pi0=NULL,
pi1=NULL, dfun=NULL, ret=c("cases","value")),...)

## Arguments

stsObj

Object of class sts containing the number of counts in each of the $$k$$ categories of the response variable. Time varying number of counts $$n_t$$ is found in slot populationFrac.

control

Control object containing several items

range

Vector of length $$t_{max}$$ with indices of the observed slot to monitor.

h

Threshold to use for the monitoring. Once the CUSUM statistics is larger or equal to h we have an alarm.

pi0

$$(k-1) \times t_{max}$$ in-control probability vector for all categories except the reference category.

mu1

$$(k-1) \times t_{max}$$ out-of-control probability vector for all categories except the reference category.

dfun

The probability mass function (PMF) or density used to compute the likelihood ratios of the CUSUM. In a negative binomial CUSUM this is dnbinom, in a binomial CUSUM dbinom and in a multinomial CUSUM dmultinom. The function must be able to handle the arguments y, size, mu and log. As a consequence, one in the case of, e.g, the beta-binomial distribution has to write a small wrapper function.

ret

Return the necessary proportion to sound an alarm in the slot upperbound or just the value of the CUSUM statistic. Thus, ret is one of the values in c("cases","value"). Note: For the binomial PMF it is possible to compute this value explicitly, which is much faster than the numeric search otherwise conducted. In case dfun just corresponds to dbinom just set the attribute isBinomialPMF for the dfun object.

...

Additional arguments to send to dfun.

## Details

The function allows the monitoring of categorical time series as described by regression models for binomial, beta-binomial or multinomial data. The later includes e.g. multinomial logistic regression models, proportional odds models or Bradley-Terry models for paired comparisons. See the Höhle (2010) reference for further details about the methodology.

Once an alarm is found the CUSUM scheme is reset (to zero) and monitoring continues from there.

LRCUSUM.runlength
An sts object with observed, alarm, etc. slots trimmed to the control\$range indices.