Learn R Programming

wbs (version 1.4)

wbs: Change-point detection via Wild Binary Segmentation

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

wbs(x, ...)

# S3 method for default 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

Run this code
# NOT RUN {
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
# }

Run the code above in your browser using DataLab