binsegrcpp_wrapper: Fast binary segmentation across loss functions

View source: R/wrap-applied.R

binsegrcpp_wrapperR Documentation

Fast binary segmentation across loss functions

Description

Wraps binsegRcpp::binseg() (Hocking): a C++ binary segmentation that runs in O(n \log n) for the best case and supports several loss functions, including ones no other engine here offers (Poisson, \ell_1). It is the package's performance path for binary segmentation on long series, and it returns the whole nested family of segmentations, so it also feeds cpt_solution_path().

Usage

binsegrcpp_wrapper(
  x,
  change_in = c("mean", "meanvar"),
  distribution = NULL,
  max_segments = NULL,
  n_segments = NULL,
  min_segment_length = NULL
)

Arguments

x

A numeric vector.

change_in

"mean" (Gaussian, the default) or "meanvar", mapped to the engine's mean_norm and meanvar_norm distributions. binsegRcpp has no variance-only cost, so "var" is not offered here; use "meanvar", or cpt_detect(method = "pelt", change_in = "var") for a variance-only change.

distribution

Loss function, overriding the mapping from change_in. Run binsegRcpp::get_distribution_info() for the list ("mean_norm", "meanvar_norm", "poisson", "l1", ...).

max_segments

Largest number of segments searched. Defaults to min(20, floor(n / 5)).

n_segments

Number of segments to report. When NULL (the default) it is chosen by BIC over the nested family the engine returns.

min_segment_length

Minimum segment length. Defaults to 2 for the single-parameter costs (mean_norm, poisson, l1), whose engine default allows one-observation segments, and to the engine's own default otherwise.

Value

A ggcpt object.

References

\insertRef

hocking2024binsegrcppggchangepoint

See Also

Other changepoint engines: bcp_wrapper(), beast_wrapper(), bfast_wrapper(), bocpd_wrapper(), capa_wrapper(), cpm_wrapper(), cpop_wrapper(), cpt_wrapper(), decafs_wrapper(), ecp_wrapper(), envcpt_wrapper(), esac_wrapper(), fabisearch_wrapper(), fastcpd_wrapper(), fcov_wrapper(), fmean_wrapper(), fpop_wrapper(), geomcp_wrapper(), hdcov_wrapper(), hdreg_wrapper(), idetect_wrapper(), inspect_wrapper(), kcp_wrapper(), kwc_wrapper(), mcp_wrapper(), mosum_wrapper(), network_wrapper(), not_wrapper(), npmojo_wrapper(), nsp_wrapper(), ocd_wrapper(), pilliat_wrapper(), segmented_wrapper(), smuce_wrapper(), sn_wrapper(), strucchange_wrapper(), taylor_wrapper(), tguh_wrapper(), trend_wrapper(), var_wrapper(), wbs2_wrapper(), wbs_wrapper(), wbsts_wrapper()

Examples


set.seed(2026)
binsegrcpp_wrapper(c(rnorm(100), rnorm(100, 3)))


ggchangepoint documentation built on Nov. 5, 2026, 9:06 a.m.