View source: R/detectCUSUMMeanCDR.R
| detectCUSUMMean | R Documentation | 
Given a vector x, use the 'CUSUM' method to sequentially detect 
changes (or a single change) in the MEAN of the vector.
detectCUSUMMean(
  x,
  k = 0.25,
  h = 8,
  BL = 50,
  multiple = TRUE,
  single = !multiple,
  usePrechange = FALSE,
  prechangeMean = NULL,
  prechangeSigma = NULL,
  prechangeVar = NULL,
  skipCheck = FALSE
)
| x | The vector (stream) in which to detect change(s). | 
| k | control parameter for 'CUSUM'. Default is  | 
| h | control parameter for 'CUSUM'. Defqult is  | 
| BL | The burn-in length. Default is  | 
| multiple | Boolean to use to decide whether to detect multiple changes
or only a single change. Default is  | 
| single | Boolean to use to decide whether to detect only a single 
change or multiple changes. Set to  | 
| usePrechange | Boolean indicating whether prechange parameters
(mean and variance) are known and will be used 
(or not). Default is
 | 
| prechangeMean | Value to be used for the prechange mean. 
Default is  | 
| prechangeSigma | Value to be used for the prechange standard 
deviation. Default is  | 
| prechangeVar | Value to be used for the prechange variance. 
Default is  | 
| skipCheck | A boolean which allows the function to skip the check 
of the stream. Default is  | 
'CUSUM' updates via:
S_{j} = \max{0, S_{j-1} + (x_{j} - \mu)/ \sigma - k}
and
T_{j} = \max{0, S_{j-1} - (x_{j} - \mu)/ \sigma - k}
where \mu and \sigma are, respectively, the mean 
and variance of the in-control stream, 
x_j is the observation at time j
and k 
is a control parameter for 'CUSUM'. Then, a change is signalled
if S_j > h or T_j > h,
where h is the other control parameter. This is the 
formulation for using 'CUSUM' to detect an increase or decrease
in the mean.
A list with the following elements:
tauhatA vector of the changepoints found.
Dean Bodenham
E. S. Page (1954) Continuous inspection schemes. Biometrika, 41(1/2), 100-115
# create a stream with three changepoints
set.seed(8)
x <- rnorm(400, 5, 1) + rep(c(0:3), each=100) # mean is 5 and s.d. is 1
# multiple changepoints
list_cusum <- detectCUSUMMean(x, k=0.25, h=8.00, BL=50, multiple=TRUE)
# now only a single (the first) changepoint
list_cusum2 <- detectCUSUMMean(x, k=0.25, h=8.00, BL=50, single=TRUE)
# now only a single (the first) changepoint, but with the prechange 
# mean and variance known
list_cusum3 <- detectCUSUMMean(x, k=0.25, h=8.00, BL=50, single=TRUE,
                               prechangeMean=5, prechangeSigma=1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.