Detects regime changes in time series data using multiple methods including cumulative peaks, changepoint detection, variance shifts, threshold analysis, gradient changes, and entropy analysis.
Usage
detect_regimes(
data,
method = "smart",
sensitivity = "medium",
min_change,
window = 10L,
peak = 2,
cumulative = 0.6
)Arguments
- data
[
ts,numeric()]
Univariate time series data.- method
[
character(1):"smart"]
Regime detection method. The available options are:"cumulative_peaks": Detects cumulative complexity peaks using Z-tests."changepoint": Change point detection (multi-window mean-shift test)."threshold": Adaptive quartile-based regime classification."variance_shift": Detects changes in variance patterns."slope": Detects changes in local slope (rolling linear models)."entropy": Detects changes in the Shannon entropy of the complexity series, calculated in rolling windows."smart"(default): Combines gradient, peaks, and changepoint methods."all": Applies all individual methods listed above and uses ensemble voting.
- sensitivity
[
character(1):"medium"]
Detection sensitivity level. The available options are:"low","medium", and"high". Controls thresholds and window sizes within the detection methods.- min_change
[
integer(1)]
Minimum number of observations between changes. If not provided, the value is determined automatically (typically 10% of observations, minimum of 10).- window
[
integer(1):10L]
Base window size for rolling calculations. This is further adjusted bysensitivity- peak
[
numeric(1):2.0]
Base z-score threshold for individual peak detection with the"cumulative_peaks"method. Adjusted bysensitivity.- cumulative
[
numeric(1):0.6]
A value between 0 and 1 that defines the base proportion threshold for identifying cumulative peak regions. Adjusted bysensitivity.
Value
An object of class regimes which is a tibble containing
the following columns:
value: Original time series data.
time: Original time points.
change: A logical vector indicating regime changes.
id: An integer regime identifier.
type: Type of change detected by the method.
magnitude: Magnitude of the change (method-specific interpretation)
confidence: Confidence in the detection
(method-specific interpretation, typically between 0 and 1, or NA)
stability: Categorical stability: "Stable", "Transitional", and
"Unstable".
score: A numeric stability score between 0 and 1.