changeDetected: Tests Whether a CPM S4 Object Has Encountered a Change Point

Description Usage Arguments Value Author(s) See Also Examples

View source: R/changeDetected.R

Description

Tests whether an existing Change Point Model (CPM) S4 object has encountered a change point. It returns TRUE if a change has been encountered, otherwise FALSE.

Note that this function is part of the S4 object section of the cpm package, which allows for more precise control over the change detection process. For many simple change detection applications this extra complexity will not be required, and the detectChangePoint and processStream functions should be used instead.

For a fuller overview of this function including a description of the CPM framework and examples of how to use the various functions, please consult the package manual "Parametric and Nonparametric Sequential Change Detection in R: The cpm Package" available from www.gordonjross.co.uk

Usage

1
2

Arguments

cpm

The CPM S4 object which is to be tested for whether a change has occurred.

Value

TRUE if a change has been detected, otherwise FALSE.

Author(s)

Gordon J. Ross gordon@gordonjross.co.uk

See Also

makeChangePointModel, processObservation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#generate a sequence containing a single change point
x <- c(rnorm(100,0,1),rnorm(100,1,1))

#use a Student CPM
cpm <- makeChangePointModel(cpmType="Student", ARL0=500)

for (i in 1:length(x)) {

  #process each observation in turn
  cpm <- processObservation(cpm,x[i])
  
  if (changeDetected(cpm)) {
    print(sprintf("change detected at observation %s",i))
    break
  }
}

Example output

[1] "change detected at observation 113"

cpm documentation built on Nov. 16, 2020, 9:13 a.m.

Related to changeDetected in cpm...