Skip to contents

Wraps the fpop package for optimal changepoint detection via functional pruning.

Usage

fpop_wrapper(x, penalty = NULL, ...)

Arguments

x

A numeric vector.

penalty

Penalty value. Defaults to 2 * log(length(x)) (BIC). This is an absolute penalty on the residual sum of squares, so it is only calibrated for noise of standard deviation 1: on wider data the default under-penalises badly and the segmentation shatters. Standardise the series, or scale the penalty by the noise variance (for example 2 * log(length(x)) * stats::var(diff(x)) / 2). See the scale-sensitivity section of cpt_detect. This default differs from the one cpt_detect applies, which resolves its "MBIC" default to a stronger numeric value, so the two entry points need not agree unless penalty is given.

...

Additional arguments passed to fpop::Fpop().

Value

A ggcpt object.

References

Maidstone R, Hocking T, Rigaill G, Fearnhead P (2017). “On Optimal Multiple Changepoint Algorithms for Large Data.” Statistics and Computing, 27(2), 519–533. doi:10.1007/s11222-016-9636-3 .

Examples

set.seed(2026)
x <- c(rnorm(60), rnorm(60, 4))
fpop_wrapper(x)$changepoints
#> # A tibble: 1 × 2
#>      cp cp_value
#>   <int>    <dbl>
#> 1    60   -0.999
# the default penalty assumes sd 1; scale it for wider noise
y <- 5 * x
fpop_wrapper(y, penalty = log(length(y)) * var(diff(y)))$changepoints
#> # A tibble: 1 × 2
#>      cp cp_value
#>   <int>    <dbl>
#> 1    60    -5.00