Skip to contents

Wraps the mosum package for moving-sum-based changepoint detection, either at a single bandwidth or (with multiscale = TRUE) across a bandwidth grid with localised pruning.

Usage

mosum_wrapper(x, G = NULL, multiscale = FALSE, seed = NULL, ...)

Arguments

x

A numeric vector.

G

Bandwidth. If NULL, automatically selected (min(n/10, 100), but never below 2, for the single-bandwidth procedure; the engine's default bandwidth grid for the multiscale procedure). A bandwidth of 1 leaves the engine's local variance estimate undefined, so the automatic choice is floored at 2.

multiscale

Logical. Use the multiscale MOSUM procedure (mosum::multiscale.localPrune()) instead of a single bandwidth? Defaults to FALSE.

seed

Optional seed for reproducibility.

...

Additional arguments passed to mosum::mosum() or mosum::multiscale.localPrune().

Value

A ggcpt object.

References

Eichinger B, Kirch C (2018). “A MOSUM Procedure for the Estimation of Multiple Random Change Points.” Bernoulli, 24(1), 526–564. doi:10.3150/16-BEJ887 .

Examples

set.seed(2026)
x <- c(rnorm(100), rnorm(100, 3))
mosum_wrapper(x, G = 20)$changepoints
#> # A tibble: 1 × 2
#>      cp cp_value
#>   <int>    <dbl>
#> 1   100    0.369
mosum_wrapper(x, multiscale = TRUE)$changepoints
#> # A tibble: 1 × 2
#>      cp cp_value
#>   <int>    <dbl>
#> 1   100    0.369