Constructor for the ChangepointDetector S3 class
ChangepointDetector(dim, method = c("ocd", "Mei", "XS", "Chan"), thresh,
patience = 5000, MC_reps = 100, beta = 1, sparsity = "auto",
b = beta/sqrt(dim), p0 = 1/sqrt(dim), w = 200, lambda = sqrt(8) -
2)Data dimension, all new data must be of this dimension
Four methods are implemented: ocd, Mei, XS
and Chan. They correspond to the methods proposed in Chen, Wang and
Samworth (2020), Mei (2010), Xie and Siegmund (2013) and Chan (2017). The
constructed detector will be of 'OCD', 'Mei', 'XS' and 'Chan' subclass
respectively.
A numeric vector or the character string 'MC'. If 'MC' is
specified then the correct threshold will be computed by Monte Carlo
simulation (the patience argument should be specified for this).
Otherwise, for method ocd, a vector of length 3 (corresponding
to the diagonal statistic, off-diagonal dense statistic and off-diagonal
sparse statistic) should be specifiied; for method Mei, a vector of
length two (corresponding to the max and sum statistics) should be specified;
for methods XS and Chan, a single positive real number should
be specified;
Required patience (average run length without change) of the online changepoint procedure. This is optional if the thresholds for detection are manually specified, but is required if Monte Carlo thresholds are used.
Number of Monte Carlo repetitions to use to estimate the
thresholds. Only used when thresh='MC'.
lower bound on the l_2 norm of the vector of mean change to be
detected. This argument is used by the ocd method.
Parameter used by the ocd. If sparsity='sparse',
then only the diagonal and off-diagonal sparse statistics are used.
If sparsity='dense', then only the diagonal and off-diagonal sparse
statistics are used. If sparsity='auto', all three statistics are used
to detect both sparse and dense change adaptively.
Lower bound on the per-coordinate magnitude of mean change be
detected. This argument is used by the 'Mei' method. If b is
unspecified but beta is specified, the default b = beta/sqrt(dim)
will be used.
A real number between 0 and 1. Sparsity parameter used by XS
and Chan methods. It is the assumed fraction of nonzero coordinates of
change. Default to 1/sqrt(dim).
Window size parameter used by XS and Chan methods.
Number of most recent data points to keep track in memory. Default is 200.
A tuning parameter used by the Chan method. Default is
sqrt(8)-2.
An object of S3 class 'ChangepointDetector'. Depending on the
method argument specified, the object also belongs to a subclass
'OCD', 'Mei', 'XS' or 'Chan' corresponding to method='ocd'. It
contains the following attributes:
class - S3 class and subclass
data_dim - data dimension
method - method used for changepoint detection
param - a list of parameters used in the specific method: beta
and sparsity for method ocd; b for method Mei;
p0 and w for method XS; p0, w and
lambda for method Chan.
threshold - a named vector of thresholds used for detection (see the
thresh argument)
n_obs - number of observations, initialised to 0
baseline_mean - vector of pre-change mean, initialised to a vector of 0,
can be estimated by setting the changepoint detector into baseline mean and
standard deviation estimating status, see setStatus, or set
directly using setBaselineMean.
baseline_sd - vector of standard deviation, initialised to a vector of 1,
can be estimated by setting the changepoint detector into baseline mean and
standard deviation estimating status, see setStatus, or set
directly using setBaselineSD.
tracked - a list of information tracked online by the changepoint
detector: matrices A
and tail for method ocd; vector R for method Mei;
matrices X_recent and CUSUM for methods XS and Chan.
statistics - a named vector of test statistics for changepoint
detection: statistics with names diag, off_d and off_s
for method ocd (note if sparsity is 'dense' or
'sparse', then only (S^diag, S^off,d)
and (S^diag, S^off,s) are included in stat respectively.);
statistics with names max and sum for
method Mei; a single numeric value for methods XS and Chan.
status - one of the following: 'estimating' (the detector is estimating the baseline mean and standard deviation with new data points), 'monitoring' (the detector is detecting changes from the baseline mean from new data points) and an integer recording the time of declaration of changepoint.
This function is a wrapper. The new_OCD,
new_Mei, new_XS and new_Chan carry
out the actual constructor implementation.
Chen, Y., Wang, T. and Samworth, R. J. (2020) High-dimensional multiscale online changepoint detection Preprint. arxiv:2003.03668.
Mei, Y. (2010) Efficient scalable schemes for monitoring a large number of data streams. Biometrika, 97, 419--433.
Xie, Y. and Siegmund, D. (2013) Sequential multi-sensor change-point detection. Ann. Statist., 41, 670--692.
Chan, H. P. (2017) Optimal sequential detection in multi-stream data. Ann. Statist., 45, 2736--2763.
accessor functions such as data_dim, the main function
for processing a new data point getData, other methods for the
ChangepointDetector class including reset,
setBaselineMean, setBaselineSD,
setStatus, normalisedStatistics and
checkChange.
# NOT RUN {
detector_ocd <- ChangepointDetector(dim=100, method='ocd',
thresh=c(11.6, 179.5, 54.9), beta=1)
detector_Mei <- ChangepointDetector(dim=100, method='Mei',
thresh=c(8.6, 125.1), b=0.1)
detector_XS <- ChangepointDetector(dim=100, method='XS', thresh=55.1)
detector_Chan <- ChangepointDetector(dim=100, method='Chan', thresh=8.7)
# }
Run the code above in your browser using DataLab