segment function

Segment a time series using a variety of algorithms

Segment a time series using a variety of algorithms

A wrapper function that encapsulates various algorithms for detecting changepoint sets in univariate time series.

segment(x, method = "null", ...) ## S3 method for class 'tbl_ts' segment(x, method = "null", ...) ## S3 method for class 'xts' segment(x, method = "null", ...) ## S3 method for class 'numeric' segment(x, method = "null", ...) ## S3 method for class 'ts' segment(x, method = "null", ...)

Arguments

  • x: a numeric vector coercible into a stats::ts object
  • method: a character string indicating the algorithm to use. See Details.
  • ...: arguments passed to methods

Returns

An object of class tidycpt .

Details

Currently, segment() can use the following algorithms, depending on the value of the method argument:

  • pelt: Uses the PELT algorithm as implemented in segment_pelt(), which wraps either changepoint::cpt.mean() or changepoint::cpt.meanvar(). The segmenter is of class cpt.
  • binseg: Uses the Binary Segmentation algorithm as implemented by changepoint::cpt.meanvar(). The segmenter is of class cpt.
  • segneigh: Uses the Segmented Neighborhood algorithm as implemented by changepoint::cpt.meanvar(). The segmenter is of class cpt.
  • single-best: Uses the AMOC criteria as implemented by changepoint::cpt.meanvar(). The segmenter is of class cpt.
  • wbs: Uses the Wild Binary Segmentation algorithm as implemented by wbs::wbs(). The segmenter is of class wbs.
  • ga: Uses the Genetic algorithm implemented by segment_ga(), which wraps GA::ga(). The segmenter is of class tidyga.
  • ga-shi: Uses the genetic algorithm implemented by segment_ga_shi(), which wraps segment_ga(). The segmenter is of class tidyga.
  • ga-coen: Uses Coen's heuristic as implemented by segment_ga_coen(). The segmenter is of class tidyga. This implementation supersedes the following one.
  • coen: Uses Coen's heuristic as implemented by segment_coen(). The segmenter is of class seg_basket(). Note that this function is deprecated.
  • random: Uses a random basket of changepoints as implemented by segment_ga_random(). The segmenter is of class tidyga.
  • manual: Uses the vector of changepoints in the tau argument. The segmenter is of class seg_cpt `.
  • null: The default. Uses no changepoints. The segmenter is of class seg_cpt .

Examples

# Segment a time series using PELT segment(DataCPSim, method = "pelt") # Segment a time series using PELT and the BIC penalty segment(DataCPSim, method = "pelt", penalty = "BIC") # Segment a time series using Binary Segmentation segment(DataCPSim, method = "binseg", penalty = "BIC") # Segment a time series using a random changepoint set segment(DataCPSim, method = "random") # Segment a time series using a manually-specified changepoint set segment(DataCPSim, method = "manual", tau = c(826)) # Segment a time series using a null changepoint set segment(DataCPSim)

See Also

changepoint::cpt.meanvar(), wbs::wbs(), GA::ga(), segment_ga()