VAR_cpDetect_Online: VAR_cpDetect_Online: Sequential change point Detection for...

View source: R/main_function.R

VAR_cpDetect_OnlineR Documentation

VAR_cpDetect_Online: Sequential change point Detection for Vector Auto-Regressive Models

Description

This function performs sequential change point detection in high-dimensional time series data modeled as a Vector Auto-Regressive (VAR) process, targeting changes in the transition matrices that encode temporal and cross-correlations.

Usage

VAR_cpDetect_Online(
  data,
  n0,
  w,
  alpha,
  h,
  RLmode = TRUE,
  needRefine = TRUE,
  refineSize = 1/5,
  needRefineCorrection = TRUE
)

Arguments

data

A matrix where rows represent different dimensions (features) and columns represent observations. The first n0 columns are treated as historical data.

n0

Integer. The size of the historical data (number of columns in data treated as historical).

w

Integer. The size of the sliding window used for calculating test statistics; referred to as the pre-specified detection delay.

alpha

Numeric. The desired false alarm rate, where 1/alpha represents the targeted average run length (ARL), which should exceed the length of the data to be monitored.

h

Integer. The order of the VAR process.

RLmode

Logical. If TRUE, the algorithm terminates when the first alarm is issued.

needRefine

Logical. If TRUE, a refinement process is conducted to pinpoint the change point location.

refineSize

Numeric. The proportion of the new window size to the original window size, used during refinement.

needRefineCorrection

Logical. If TRUE, a confirmation step is performed during the refinement process to verify the detected change point.

Details

This function fits a VAR model to the historical data using the l1 penalty and calculates test statistics for the sliding window to detect change points. If refinement is enabled, a second step narrows down the change point location. Optionally, a correction step can verify the detected change points.

Value

A list containing:

RL

The index (ignoring historical data) of the last observation read by the algorithm when the first alarm is issued. This is returned only if RLmode = TRUE.

cp_refined

The refined estimate for the location (ignoring historical data) of the change point. This is returned only if RLmode = TRUE and needRefine = TRUE.

alarm_locations

A vector of indices (ignoring historical data) where alarms were raised. This is returned only if RLmode = FALSE.

cp_locations

A vector of refined change point locations (ignoring historical data), corresponding 1-to-1 with the alarm_locations. This is returned only if RLmode = FALSE and needRefine = TRUE.

Examples

library(MASS)
set.seed(2024)
As <- list(matrix(c(0.5, 0.2, 0.1, 0.4), 2, 2))
As_new <- list(matrix(c(-0.5, 0.2, 0.1, -0.4), 2, 2))
Sig <- diag(2)
data_IC <- generateVAR(n = 400, As = As, Sig = Sig, h = 1)
data_OC <- generateVAR(n = 100, As = As_new, Sig = Sig, h = 1,
                       isOldProvided = TRUE, oldxs = data_IC[, ncol(data_IC)])
data <- cbind(data_IC, data_OC)
result <- VAR_cpDetect_Online(data, n0 = 300, w = 20, alpha = 1/200, h = 1,
                              RLmode = TRUE, needRefine = TRUE, refineSize = 1/5,
                              needRefineCorrection = TRUE)
print(result)


VARcpDetectOnline documentation built on April 12, 2025, 1:44 a.m.