Description
A Collection of Change-Point Detection Methods.
Description
Performs a series of offline and/or online change-point detection algorithms for 1) univariate mean: <doi:10.1214/20-EJS1710>, <arXiv:2006.03283>; 2) univariate polynomials: <doi:10.1214/21-EJS1963>; 3) univariate and multivariate nonparametric settings: <doi:10.1214/21-EJS1809>, <doi:10.1109/TIT.2021.3130330>; 4) high-dimensional covariances: <doi:10.3150/20-BEJ1249>; 5) high-dimensional networks with and without missing values: <doi:10.1214/20-AOS1953>, <arXiv:2101.05477>, <arXiv:2110.06450>; 6) high-dimensional linear regression models: <arXiv:2010.10410>, <arXiv:2207.12453>; 7) high-dimensional vector autoregressive models: <arXiv:1909.06359>; 8) high-dimensional self exciting point processes: <arXiv:2006.03572>; 9) dependent dynamic nonparametric random dot product graphs: <arXiv:1911.07494>; 10) univariate mean against adversarial attacks: <arXiv:2105.10417>.
README.md
A collection of change-point localisation methods.
Performs a series of offline and/or online change-point localisation algorithms for
- univariate mean
- univariate polynomials
- univariate and multivariate nonparametric settings
- high-dimensional covariances
- high-dimensional networks with and without missing values
- high-dimensional linear regression models
- high-dimensional vector autoregressive models
- high-dimensional self exciting point processes
- dependent dynamic nonparametric random dot product graphs
- robust univariate mean against adversarial attacks
Installation
Users must have a (C++) compiler installed on their machine that is compatible with R (e.g. Clang). The development version of changepoints
from GitHub can be installed with:
## if not installed
## Install dependencies
install.packages(c("devtools","glmnet","gglasso","ks","data.tree"))
## install.packages("devtools")
devtools::install_github("HaotianXu/changepoints")
Example
This is an example for offline univariate mean change point detection by $l_0$ penalization:
library(changepoints)
## simulate data with true change points being 50, 100 and 150
set.seed(0)
y = c(rep(0, 50), rep(2, 50), rep(0, 50), rep(-2, 50)) + rnorm(200, mean = 0, sd = 1)
## estimate change points by l_0 penalization
gamma_set = c(0.01, 0.5, 1, 5, 10, 50) # possible value of tuning parameter
## perform cross-validation
DP_result = CV.search.DP.univar(y, gamma_set, delta = 5)
## estimate change points and perform local refinement
min_idx = which.min(DP_result$test_error)
cpt_DP_hat = unlist(DP_result$cpt_hat[[min_idx]])
cpt_DP_LR = local.refine.univar(cpt_DP_hat, y)
Alternatively, wild binary segmentation
can also be performed:
## generate random intervals for WBS
intervals = WBS.intervals(M = 100, lower = 1, upper = 200)
## perform WBS
WBS_result = WBS.univar(y, 1, 200, intervals$Alpha, intervals$Beta, delta = 5)
WBS_result
## trim binary tree with threshold being 3
WBS_trimmed = thresholdBS(WBS_result, tau = 3)
## print the trimmed binary tree
print(WBS_trimmed$BS_tree_trimmed, "value")
## estimate change points and perform local refinement
cpt_WBS_hat = sort(WBS_trimmed$cpt_hat[,1])
cpt_BS_LR = local.refine.univar(cpt_WBS_hat, y)
wild binary segmentation
with tuning parameter selected by information criteria :
WBS_CPD_result = tuneBSunivar(WBS_result, y)
WBS_CPD_LR = local.refine.univar(WBS_CPD_result$cpt, y)