Create a ggcpt object
Usage
new_ggcpt(
changepoints = tibble::tibble(cp = integer(), cp_value = numeric()),
segments = tibble::tibble(seg_id = integer(), start = integer(), end = integer(), n =
integer(), param_estimate = numeric()),
data = tibble::tibble(index = integer(), value = numeric()),
method = NA_character_,
change_in = NA_character_,
penalty = list(type = NA_character_, value = NA_real_),
fit = NULL,
call = NULL,
cp_convention = "left",
runtime = NA_real_
)Arguments
- changepoints
A tibble with columns
cpandcp_value.- segments
A tibble with segment information:
seg_id,start,end,n,param_estimate.- data
A tibble with
indexandvalue.- method
Character. The detection method used. A length-one string; defaults to
NA_character_. (A zero-length value would makeglance()return zero rows instead of its documented single row, because every other column would be recycled against it.)- change_in
Character. What was detected (e.g. "mean", "var", "meanvar"). A length-one string; defaults to
NA_character_.- penalty
A list with
typeandvalue.- fit
The raw upstream object. Every wrapper stores one except
"ecp":ecp::e.agglo()returns a cluster-progression matrix that is quadratic in the series length, so keeping it by default would make the result object explode on a long series. Callecp::e.divisive()orecp::e.agglo()directly if you need it. A few of the engines that are kept are still large relative to the data — measured on a 2000-point series,strucchangecosts about 135 MB (a triangular \(O(n^2)\) RSS matrix),bfastabout 53 MB andbocpdabout 31 MB, while every other engine stays under 4 MB. That is the engine's own object, not overhead this package adds, and it matters mainly when many results are held at once:cpt_batch(keep_fit = FALSE)drops them, or assignres$fit <- NULLyourself.- call
The matched call.
- cp_convention
Character. The convention for reporting changepoint locations:
"left"(last index of left segment, used bychangepoint) or"right"(first index of right segment, used byecp). Defaults to"left".- runtime
Numeric. Elapsed detection time in seconds, if measured. Defaults to
NA.
Optional slots
Beyond the components in the signature, a ggcpt may carry any of
these, each present only when something supplied it and each safe to test
for with is.null():
data_wideindex plus one column per coordinate, for a multivariate result.
index,index_labela time index (one value per observation) and its axis label; see the
indexargument ofcpt_detect().regionsa tibble of significance regions (
start,end, ...) for the interval-valued methods — seensp_wrapper()andgeom_cpt_region().diagnosticsa named list of engine internals rendered by
ggcpt_statistic(),ggcpt_solution_path()andggcpt_scale_space().registeredTRUEwhen the result came from a user-registered detector rather than a wired engine.
as_ggcpt() is the validating way to build one of these from
the outside; this constructor does not check its arguments.
See also
Other result class:
annotate_segments(),
as_cpt_series(),
as_ggcpt(),
cpt_annotations(),
is_ggcpt()
Examples
set.seed(2026)
new_ggcpt(
changepoints = tibble::tibble(cp = 50L, cp_value = 0.1),
data = tibble::tibble(index = 1:100,
value = c(rnorm(50), rnorm(50, 4))),
method = "manual", change_in = "mean")
#> ggcpt (changepoint detection result)
#> Method: manual
#> Change in: mean
#> Changepoints found: 1
#> CP convention: left
#> Penalty: NA
#> Series length: 100
#>
#> Changepoints:
#> # A tibble: 1 × 2
#> cp cp_value
#> <int> <dbl>
#> 1 50 0.1
