Skip to contents

Wraps the wbs package for randomised changepoint detection via Wild Binary Segmentation.

Usage

wbs_wrapper(x, n_intervals = 5000, threshold = NULL, seed = NULL, ...)

Arguments

x

A numeric vector.

n_intervals

Number of random intervals. Defaults to 5000.

threshold

Manual threshold for detection. If NULL, model selection uses the strengthened Schwarz Information Criterion (sSIC).

seed

Optional seed for reproducibility. The seed is scoped to this call: .Random.seed is saved and restored, so a seeded call inside a simulation loop does not pin the loop's own stream.

...

Additional arguments passed to wbs::wbs().

Value

A ggcpt object.

References

Fryzlewicz P (2014). “Wild Binary Segmentation for Multiple Change-Point Detection.” The Annals of Statistics, 42(6), 2243–2281. doi:10.1214/14-AOS1245 .

Examples

set.seed(2026)
res <- wbs_wrapper(c(rnorm(60), rnorm(60, 4)), n_intervals = 200)
res$changepoints
#> # A tibble: 1 × 2
#>      cp cp_value
#>   <int>    <dbl>
#> 1    60   -0.999
res$penalty$type   # sSIC selection, because `threshold` was not supplied
#> [1] "sSIC"