wbs: Change-point detection via Wild Binary Segmentation

Description Usage Arguments Value Examples

View source: R/wbs.R

Description

The function applies the Wild Binary Segmentation algorithm to identify potential locations of the change-points in the mean of the input vector x. The object returned by this routine can be further passed to the changepoints function, which finds the final estimate of the change-points based on chosen stopping criteria.

Usage

1
2
3
4
5
wbs(x, ...)

## Default S3 method:
wbs(x, M = 5000, rand.intervals = TRUE,
  integrated = TRUE, ...)

Arguments

x

a numeric vector

...

not in use

M

a number of intervals used in the WBS algorithm

rand.intervals

a logical variable; if rand.intervals=TRUE intervals used in the procedure are random, thus the output of the algorithm may slightly vary from run to run; for rand.intervals=FALSE the intervals used depend on M and the length of x only, hence the output is always the same for given input parameters

integrated

a logical variable indicating the version of Wild Binary Segmentation algorithm used; when integrated=TRUE, augmented version of WBS is launched, which combines WBS and BS into one

Value

an object of class "wbs", which contains the following fields

x

the input vector provided

n

the length of x

M

the number of intervals used

rand.intervals

a logical variable indicating type of intervals

integrated

a logical variable indicating type of WBS procedure

res

a 6-column matrix with results, where 's' and 'e' denote start- end points of the intervals in which change-points candidates 'cpt' have been found; column 'CUSUM' contains corresponding value of CUSUM statistic; 'min.th' is the smallest threshold value for which given change-point candidate would be not added to the set of estimated change-points; the last column is the scale at which the change-point has been found

Examples

1
2
3
4
5
6
7
8
x <- rnorm(300) + c(rep(1,50),rep(0,250))
w <- wbs(x)
plot(w)
w.cpt <- changepoints(w)
w.cpt
th <- c(w.cpt$th,0.7*w.cpt$th)
w.cpt <- changepoints(w,th=th)
w.cpt$cpt.th

Example output

$sigma
[1] 1.01788

$th
[1] 4.469267

$no.cpt.th
[1] 1

$cpt.th
$cpt.th[[1]]
[1] 52


$Kmax
[1] 50

$ic.curve
$ic.curve$ssic.penalty
 [1]  -8.4004911 -15.2257319 -14.5474336 -13.2517953  -7.5276527  -1.7910167
 [7]  -1.2690605  -0.9185226   4.8356312  10.0650358  15.5006957  16.7054999
[13]  18.7654211  22.8923430  25.9691081  27.5101908  28.9441351  32.4901492
[19]  35.9447042  41.5445190  46.7148157  49.4234377  52.9425058  58.6748659
[25]  60.9734957  63.6484703  69.4204024  73.4995736  75.6769348  80.1221500
[31]  83.3730628  88.2458964  90.9398746  95.9285430 100.6890101 104.6606878
[37] 107.8540699 110.3617279 110.6376928 114.4159685 116.7171077 121.6614364
[43] 124.3826817 129.3271983 132.1026213 135.0676393 137.7878851 139.7791018
[49] 142.4731503 146.3850549 151.9006760

$ic.curve$bic.penalty
 [1]  -8.400491 -15.325912 -14.747793 -13.552335  -7.928372  -2.291916
 [7]  -1.870140  -1.619781   4.034192   9.163417  14.498897  15.603522
[13]  17.563263  21.590005  24.566590  26.007493  27.341258  30.787092
[19]  34.141467  39.641102  44.711219  47.319661  50.738549  56.370730
[25]  58.569180  61.143974  66.815727  70.794718  72.871899  77.216935
[31]  80.367668  85.140321  87.734120  92.622608  97.282896 101.154393
[37] 104.247596 106.655074 106.830859 110.508955 112.709914 117.554063
[43] 120.175128 125.019465 127.694708 130.559546 133.179612 135.070649
[49] 137.664518 141.476243 146.891684

$ic.curve$mbic.penalty
 [1]  -8.400491 -13.445467 -11.983714  -9.571232  -2.731608   4.835455
 [7]   5.213725   5.460694  12.458591  19.273454  26.070967  27.165282
[13]  30.159508  35.289229  39.003768  40.397016  43.181954  47.268255
[19]  50.511059  56.833596  63.106145  65.688941  69.907763  76.413597
[25]  79.117848  82.585038  89.118173  93.515289  95.515395 101.137380
[31] 104.659081 109.821815 112.964919 118.291142 123.906201 127.686538
[37] 131.651225 134.349663 134.381607 138.511931 141.059464 146.520985
[43] 149.050890 153.804066 156.453663 159.206929 161.683154 163.752528
[49] 166.306376 169.915368 176.381766


$cpt.ic
$cpt.ic$ssic.penalty
[1] 52

$cpt.ic$bic.penalty
[1] 52

$cpt.ic$mbic.penalty
[1] 52


$no.cpt.ic
ssic.penalty  bic.penalty mbic.penalty 
           1            1            1 

[[1]]
[1] 52 58 70

[[2]]
[1] 52

wbs documentation built on May 30, 2017, 3:56 a.m.