The mirror of cpt_test_at(). A detector found a change on
14 March and something is known to have happened on 1 March: is that the
same event? The detection's confidence interval answers it: an event
inside the interval is consistent with being the change, one outside is
not.
Arguments
- fit
A
ggcptobject.- event
One or more event locations: positions, values of the fit's index, or a
cpt_annotate_events()result.- level
Confidence level of the interval. Defaults to
0.95.- ...
Further arguments for
cpt_confint()(for exampleBorseedfor a bootstrap interval).
Value
A tibble with one row per event: event,
event_position, the nearest changepoint cp (and
cp_index), its interval ci_lower/ci_upper,
distance (positions from the changepoint to the event),
inside and a plain-language verdict.
See also
Other inference:
cpt_assumptions(),
cpt_effect(),
cpt_gof(),
cpt_null_power(),
cpt_robustness(),
cpt_test_at(),
cpt_test_null()
Examples
set.seed(1)
dates <- as.Date("2026-01-01") + 0:119
fit <- cpt_detect(c(rnorm(60), rnorm(60, 3)), method = "strucchange",
index = dates)
cpt_attribute_event(fit, as.Date(c("2026-02-28", "2026-04-10")))
#> # A tibble: 2 × 9
#> event event_position cp cp_index ci_lower ci_upper distance inside
#> <chr> <dbl> <int> <date> <int> <int> <dbl> <lgl>
#> 1 2026-02-28 59 60 2026-03-01 58 61 -1 TRUE
#> 2 2026-04-10 100 60 2026-03-01 58 61 40 FALSE
#> # ℹ 1 more variable: verdict <chr>
