Scores an online result the way the sequential literature does: how long
after each true change did the first alarm arrive, and how many alarms
were raised with no change behind them. cpt_metrics() is the
wrong tool for an online detector — it asks whether the location
was recovered, which a sequential procedure never claims — and warns if
you point it at one.
Arguments
- object
A
ggcpt_delayobject (forautoplot()).- truth
Integer vector of true changepoint positions, on the same clock as the alarms. When
objectis a monitor built bycpt_replay()the baseline offset is applied automatically.- max_delay
Alarms further than this after a change are treated as false alarms rather than late detections. Defaults to
Inf.- x
A
ggcpt_delayobject.- ...
Ignored.
Value
A ggcpt_delay object: a list with per_change (one
row per true change: truth, alarm, delay,
detected), false_alarms, and the summary statistics
mean_delay, median_delay, n_false_alarms and
arl (mean observations per false alarm).
Examples
set.seed(2026)
mon <- cpt_replay(c(rnorm(200), rnorm(200, 3)), method = "edetector")
cpt_delay(mon, truth = 200)
#> ggcpt_delay
#> True changes: 1
#> Detected: 1
#> Mean delay: 16
#> Median delay: 16
#> False alarms: 4
#> Average run length: 100
#>
#> # A tibble: 1 × 4
#> truth alarm delay detected
#> <int> <int> <dbl> <lgl>
#> 1 200 216 16 TRUE
