View source: R/univariate_mean.R
BS.univar | R Documentation |
Perform standard binary segmentation for univariate mean change points detection.
BS.univar(y, s, e, delta = 2, level = 0)
y |
A |
s |
A |
e |
A |
delta |
A positive |
level |
Should be fixed as 0. |
An object of class
"BS", which is a list
with the following structure:
S |
A vector of estimated change point locations (sorted in strictly increasing order). |
Dval |
A vector of values of CUSUM statistic. |
Level |
A vector representing the levels at which each change point is detected. |
Parent |
A matrix with the starting indices on the first row and the ending indices on the second row. |
Haotian Xu
Wang, Yu and Rinaldo (2020) <doi:10.1214/20-EJS1710>.
thresholdBS
for obtaining change points estimation, tuneBSunivar
for a tuning version.
set.seed(0) cpt_true = c(20, 50, 170) y = rnorm(300) + c(rep(0,20),rep(2,30),rep(0,120),rep(2,130)) temp = BS.univar(y, 1, length(y), delta = 5) plot.ts(y) points(x = tail(temp$S[order(temp$Dval)],4), y = y[tail(temp$S[order(temp$Dval)],4)], col = "red") BS_result = thresholdBS(temp, tau = 4) BS_result print(BS_result$BS_tree, "value") print(BS_result$BS_tree_trimmed, "value") cpt_hat = sort(BS_result$cpt_hat[,1]) # the threshold tau is specified to be 4 Hausdorff.dist(cpt_hat, cpt_true) cpt_LR = local.refine.univar(cpt_hat, y) Hausdorff.dist(cpt_LR, cpt_true)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.