Learn R Programming

RegimeChange (version 0.1.1)

cusum: CUSUM Changepoint Detection

Description

Detects changepoints using the Cumulative Sum (CUSUM) statistic. Foundational method for detecting changes in mean.

Usage

cusum(
  data,
  type = "mean",
  threshold = 4,
  mode = "offline",
  mu0 = NULL,
  sigma = NULL,
  ...
)

Value

List with changepoints and statistics

Arguments

data

Numeric vector

type

Type of change ("mean", "variance", "both")

threshold

Detection threshold (alarm when statistic exceeds this)

mode

"offline" for retrospective or "online" for sequential

mu0

Target mean under null hypothesis (for online mode)

sigma

Known standard deviation (if NULL, estimated from data)

...

Additional arguments

Examples

Run this code
data <- c(rnorm(50), rnorm(50, mean = 2))
result <- cusum(data)

Run the code above in your browser using DataLab