regimes: Identify regimes via unsupervised ML algorithms

Description Usage Arguments Value Examples

View source: R/regimes.R

Description

Regime assignment (clustering) methods available include the unsupervised random forest, k-mean clustering, Fraley and Raftery Model-based clustering EM algorithm, and the Bai & Perron (2003) method for simultaneous estimation of multiple breakpoints.

Usage

1
regimes(data, method = "rf", regime.n = NULL)

Arguments

data

data.frame, matrix, ts, xts, zoo: Endogenous regressors

method

string: regime assignment technique ('rf', 'kmeans', 'EM', or 'BP)

regime.n

int: number of regimes to estimate (applies to kmeans and EM)

Value

data as a data.frame with a regime column assigning rows to mutually exclusive regimes

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
 # simple time series
 AA = c(1:100) + rnorm(100)
 BB = c(1:100) + rnorm(100)
 CC = AA + BB + rnorm(100)
 date = seq.Date(from = as.Date('2000-01-01'), by = 'month', length.out = 100)
 Data = data.frame(date = date, AA, BB, CC)

 # estimate reigme
 regime =
  sovereign::regimes(
     data = Data,
     method = 'kmeans',
     regime.n = 3)

sovereign documentation built on Jan. 5, 2022, 1:08 a.m.