Learn R Programming

RegimeChange (version 0.1.1)

regime_detector: Create Online Regime Detector

Description

Creates a detector object for online (sequential) changepoint detection. The detector maintains state and can be updated incrementally as new observations arrive.

Usage

regime_detector(
  method = c("bocpd", "cusum", "shiryaev"),
  prior = NULL,
  hazard = NULL,
  threshold = NULL,
  ...
)

Value

An object of class "regime_detector"

Arguments

method

Detection method: "bocpd", "cusum", or "shiryaev"

prior

Prior specification for Bayesian methods

hazard

Hazard prior for changepoint occurrence

threshold

Detection threshold (probability or statistic value)

...

Additional method-specific parameters

Examples

Run this code
detector <- regime_detector(method = "bocpd",
                            prior = normal_gamma(),
                            threshold = 0.5)

# \donttest{
for (x in rnorm(100)) {
  detector <- update(detector, x)
  if (detector$last_result$alarm) {
    message("Change detected at observation ", detector$last_result$t)
    detector <- reset(detector)
  }
}
# }

Run the code above in your browser using DataLab