Skip to contents

Wraps the IDetect package. Requires the IDetect package.

Usage

idetect_wrapper(x, seed = NULL, ...)

Arguments

x

A numeric vector.

seed

Optional seed for reproducibility.

...

Additional arguments passed to IDetect::ID().

Value

A ggcpt object. When the engine finds no changepoints (including when it signals "No change-points found"), an empty result is returned rather than an error. A constant series likewise returns the empty result; see the note below.

Constant input

IDetect::ID() does not treat a flat series consistently — its statistics become \(0/0\), and what comes back depends on the value and the length. rep(3, 200) yields 126 changepoints, at 1, 3, 4, 6, 7, ...; rep(0, 100) raises "No change-points found"; rep(-2.5, 60) returns the sentinel 0. A constant series plainly has no changepoint, and every other search wrapper here reports none, so this one short-circuits to the empty result. Constancy is decided by exact equality, so a series with tiny but genuine variation still reaches the engine.

References

Anastasiou A, Fryzlewicz P (2022). “Detecting Multiple Generalized Change-Points by Isolating Single Ones.” Metrika, 85, 141–174. doi:10.1007/s00184-021-00821-6 .

Examples

set.seed(2026)
idetect_wrapper(c(rnorm(60), rnorm(60, 4)))$changepoints
#> # A tibble: 1 × 2
#>      cp cp_value
#>   <int>    <dbl>
#> 1    60   -0.999
# a flat series has no changepoint; see "Constant input" above
nrow(idetect_wrapper(rep(3, 100))$changepoints)
#> [1] 0