Learn R Programming

wbs (version 1.4)

changepoints: Change-points detected by WBS or BS

Description

The function applies user-specified stopping criteria to extract change-points from object generated by wbs or sbs. For object of class 'sbs', the function returns change-points whose corresponding test statistic exceeds threshold given in th. For object of class 'wbs', the change-points can be also detected using information criteria with penalties specified in penalty.

Usage

changepoints(object, ...)

# S3 method for sbs changepoints(object, th = NULL, th.const = 1.3, Kmax = NULL, ...)

# S3 method for wbs changepoints(object, th = NULL, th.const = 1.3, Kmax = 50, penalty = c("ssic.penalty", "bic.penalty", "mbic.penalty"), ...)

Arguments

object

an object of 'wbs' or 'sbs' class returned by, respectively, wbs and sbs functions

...

further arguments that may be passed to the penalty functions

th

a vector of positive scalars

th.const

a vector of positive scalars

Kmax

a maximum number of change-points to be detected

penalty

a character vector with names of penalty functions used

Value

sigma

Median Absolute Deviation estimate of the noise level

th

a vector of thresholds

no.cpt.th

the number of change-points detected for each value of th

cpt.th

a list with the change-points detected for each value of th

Kmax

a maximum number of change-points detected

ic.curve

a list with values of the chosen information criteria

no.cpt.ic

the number of change-points detected for each information criterion considered

cpt.ic

a list with the change-points detected for each information criterion considered

Details

For the change-point detection based on thresholding (object of class 'sbs' or 'wbs'), the user can either specify the thresholds in th directly, determine the maximum number Kmax of change-points to be detected, or let th depend on th.const.

When Kmax is given, the function automatically sets th to the lowest threshold such that the number of detected change-points is lower or equal than Kmax. Note that for the BS algorithm it might be not possible to find the threshold such that exactly Kmax change-points are found.

When th and Kmax are omitted, the threshold value is set to $$th = sigma \times th.const \sqrt{2\log(n)},$$ where sigma is the Median Absolute Deviation estimate of the noise level and \(n\) is the number of elements in x.

For the change-point detection based on information criteria (object of class 'wbs' only), the user can specify both the maximum number of change-points (Kmax) and a type of the penalty used. Parameter penalty should contain a list of characters with names of the functions of at least two arguments (n and cpt). For each penalty given, the following information criterion is minimized over candidate sets of change-points cpt: $$\frac{n}{2}\log\hat{\sigma}_{k}^{2}+penalty(n,cpt),$$ where \(k\) denotes the number of elements in \(cpt\), \(\hat{\sigma}_{k}\) is the corresponding maximum likelihood estimator of the residual variance.

Examples

Run this code
# NOT RUN {
#we generates  gaussian noise + Poisson process signal with 10 jumps on average
set.seed(10)
N <- rpois(1,10)
true.cpt <- sample(1000,N)
m1 <- matrix(rep(1:1000,N),1000,N,byrow=FALSE)
m2 <- matrix(rep(true.cpt,1000),1000,N,byrow=TRUE)
x <- rnorm(1000) + apply(m1>=m2,1,sum)

# we apply  the BS and WBS algorithms with default values for their parameters

s <- sbs(x)
w <- wbs(x)

s.cpt <- changepoints(s)
s.cpt

w.cpt <- changepoints(w)
w.cpt

#we can use different stopping criteria, invoking sbs/wbs functions is not necessary  

s.cpt <- changepoints(s,th.const=c(1,1.3))
s.cpt
w.cpt <- changepoints(w,th.const=c(1,1.3))
w.cpt
# }

Run the code above in your browser using DataLab