cpop_wrapper: CPOP wrapper: optimal change-in-slope detection

View source: R/wrap-slope.R

cpop_wrapperR Documentation

CPOP wrapper: optimal change-in-slope detection

Description

Wraps cpop::cpop() (Fearnhead, Maidstone and Letchford, 2019; Fearnhead and Grose, 2024): exact penalised estimation of a continuous piecewise-linear mean via dynamic programming with functional pruning. This is the engine behind cpt_detect(change_in = "slope"). The fitted broken line is stored in the fitted column and renders via autoplot(show_fit = TRUE).

Usage

cpop_wrapper(x, penalty = NULL, sd = NULL, ...)

Arguments

x

A numeric vector.

penalty

Penalty for adding a changepoint. Defaults to 2 * log(length(x)). cpt_detect resolves its own "MBIC" default to a stronger numeric value, so the two entry points need not agree unless penalty is given.

sd

Noise standard deviation; when NULL it is estimated from the data by the engine's default difference-based estimator.

...

Additional arguments passed to cpop::cpop().

Value

A ggcpt object with change_in = "slope". For a continuous fit the reported location is the kink point itself.

References

\insertRef

fearnhead2019cpopggchangepoint

\insertRef

fearnhead2024cpopggchangepoint

See Also

Other changepoint engines: bcp_wrapper(), beast_wrapper(), bfast_wrapper(), binsegrcpp_wrapper(), bocpd_wrapper(), capa_wrapper(), cpm_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)
y <- cumsum(c(rep(0.3, 100), rep(-0.4, 100))) + rnorm(200)
res <- cpop_wrapper(y)
res$changepoints
ggplot2::autoplot(res, show_fit = TRUE)


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