BS.univar {changepoints} R Documentation

## Standard binary segmentation for univariate mean change points detection.

### Description

Perform standard binary segmentation for univariate mean change points detection.

### Usage

BS.univar(y, s, e, delta = 2, level = 0)


### Arguments

 y A numeric vector of observations. s A integer scalar of starting index. e A integer scalar of ending index. delta A positive numeric scalar of minimum spacing. level Should be fixed as 0.

### Value

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

### References

Wang, Yu and Rinaldo (2020) <doi:10.1214/20-EJS1710>.

thresholdBS for obtaining change points estimation, tuneBSunivar for a tuning version.

### Examples

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)


[Package changepoints version 1.1.0 Index]