Skip to contents

Greedy recursive bisection: a split at tau is accepted when C(left) + C(right) + beta < C(segment) (Killick, Fearnhead and Eckley 2012, Sec. 2.1 eq 2); at each step the split with the largest cost reduction over all current segments is taken, up to K changepoints. Method originally due to Scott and Knott (1974).

Usage

Binseg(x, K, cost = "mean", penalty = 0, min_seglen = 1L)

Arguments

x

Numeric series.

K

Maximum number of changepoints.

cost

"mean" or "meanvar".

penalty

Penalty beta in eq 2 (default 0).

min_seglen

Minimum segment length.

Value

List with changepoints (sorted), order (detection order), improvements, n_changepoints, segment_means.

References

Killick, R., Fearnhead, P. and Eckley, I. A. (2012), Journal of the American Statistical Association 107(500), 1590-1598 (arXiv:1101.1438), Sec. 2.1 eq 2; Scott, A. J. and Knott, M. (1974), A cluster analysis method for grouping means in the analysis of variance, Biometrics 30(3), 507-512.

Examples

Binseg(x = c(1, 2, 3, 4, 5, 6, 7, 8), K = 5L)
#> $changepoints
#> [1] 1 2 3 4 6
#> 
#> $order
#> [1] 4 2 6 1 3
#> 
#> $improvements
#> [1] 32.0  4.0  4.0  0.5  0.5
#> 
#> $n_changepoints
#> [1] 5
#> 
#> $segment_means
#> [1] 1.0 2.0 3.0 4.0 5.5 7.5
#> 
#> $estimate
#> [1] 1 2 3 4 6
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "Binary segmentation (Scott-Knott 1974; Killick et al. 2012 Sec. 2.1)"
#>