envcpt_wrapper: EnvCpt wrapper: changepoints versus trends versus...

View source: R/wrap-regression.R

envcpt_wrapperR Documentation

EnvCpt wrapper: changepoints versus trends versus autocorrelation

Description

Wraps EnvCpt::envcpt() (Beaulieu and Killick, 2018), which fits up to twelve competing models (constant mean or linear trend, each with or without changepoints, and with white-noise, AR(1) or AR(2) errors) and lets an information criterion decide whether the series really contains changepoints or merely trend/autocorrelation ("memory"). The changepoints of the winning model (if any) are returned, and the winning model's name is recorded, guarding against the classic false positive of running a mean-shift detector on autocorrelated data.

Usage

envcpt_wrapper(
  x,
  models = c("mean", "meancpt", "meanar1", "meanar2", "meanar1cpt", "meanar2cpt",
    "trend", "trendcpt", "trendar1", "trendar2", "trendar1cpt", "trendar2cpt"),
  criterion = c("AIC", "BIC"),
  minseglen = 5,
  ...
)

Arguments

x

A numeric vector.

models

Character vector of models to fit; see EnvCpt::envcpt(). Defaults to all twelve.

criterion

Model selection criterion: "AIC" (default) or "BIC".

minseglen

Minimum segment length. Defaults to 5.

...

Additional arguments passed to EnvCpt::envcpt().

Value

A ggcpt object. $fit holds the full envcpt output; the selected model name is stored in the penalty descriptor and printed by glance() via penalty_type. Individual model fits that fail are expected (the criterion ignores them), so the engine's own try() output is not passed on; genuine warnings still are, and a series on which no model fits at all raises an error. A constant series has no changepoints and is not handed to the engine, so $fit is NULL there.

References

\insertRef

beaulieu2018envcptggchangepoint

See Also

Other changepoint engines: bcp_wrapper(), beast_wrapper(), bfast_wrapper(), binsegrcpp_wrapper(), bocpd_wrapper(), capa_wrapper(), cpm_wrapper(), cpop_wrapper(), cpt_wrapper(), decafs_wrapper(), ecp_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)
res <- envcpt_wrapper(c(rnorm(100), rnorm(100, 3)))
res$changepoints


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