Skip to contents

Wraps cpm::processStream() (Ross, 2015) for distribution-free sequential changepoint detection via repeated two-sample tests (Mann-Whitney for location, Mood for scale, Lepage, Kolmogorov-Smirnov and Cramer-von-Mises for general changes, and parametric Student/Bartlett/GLR variants). Although the engine is designed for streams, it is run here over the full series in one pass, mimicking online monitoring with average run length arl0.

Usage

cpm_wrapper(x, cpm_type = "Mann-Whitney", arl0 = 500, startup = 20, ...)

Arguments

x

A numeric vector.

cpm_type

Test statistic, passed to cpm::processStream() as cpmType. One of "Mann-Whitney", "Mood", "Lepage", "Kolmogorov-Smirnov", "Cramer-von-Mises", "Student", "Bartlett", "GLR", "Exponential", "GLRAdjusted", "FET". Defaults to "Mann-Whitney".

arl0

Target in-control average run length (how many observations, on average, before a false alarm). Defaults to 500.

startup

Number of observations after each restart before monitoring begins. Defaults to 20.

...

Additional arguments passed to cpm::processStream().

Value

A ggcpt object. The changepoints tibble carries a detection_time column: the index at which the sequential test flagged each change (always later than the estimated location).

References

Ross GJ (2015). “Parametric and nonparametric sequential change detection in R: The cpm package.” Journal of Statistical Software, 66(3), 1–20.

Examples

res <- cpm_wrapper(c(rnorm(100), rnorm(100, 3)))
res$changepoints
#> # A tibble: 1 × 3
#>      cp cp_value detection_time
#>   <int>    <dbl>          <int>
#> 1   100    -1.02            104