discrets {seewave}R Documentation

Time series discretisation

Description

This function transforms a numeric (time) series into a sequence of symbols

Usage

discrets(x, symb = 5, collapse = TRUE, plateau=1)

Arguments

x

a vector, a matrix (first column), an object of class ts, Sample (left channel), or Wave (left channel).

symb

the number of symbols used for the discretisation, can be set to 3 or 5 only.

collapse

logical, if TRUE, the symbols are pasted in a character string of length 1.

plateau

a numeric vector of length 1 taking the values 1 or 2 only. See details.

Details

The function partitions the numeric (time) series into a sequence of finite number of symbols. These symbols result of the comparaison of each series value with its temporal neighbours.
They are two discretisations available:
when symb is set to 3, each value will be replaced by either:
- I if the series is Increasing,
- D if the series is Decreasing,
- F if the series remains Flat,
when symb is set to 5, each value will be replaced by either:
- I if the series is Increasing,
- D if the series is Decreasing,
- F if the series remains Flat,
- P if the series shows a Peak,
- T if the series shows a Trough.

The argument plateau can be used to control the way a plateau is encoded. A plateau is an elevated flat region that can be either considered a 'flat peak' encoded as PF...FP (plateau = 1) or as an increase, a flat region and a decrease encoded as IF...FD (plateau = 1. The default value (plateau = 1) refers to Cazelles et al. (2004).

Value

A character string of length 1 if collapse is TRUE. Otherwise, a character string of length n-2 if symbol=5 (the first and last values cannot be replaced with a symbol) or n-1 if symbol=3 (the first value cannot be replaced with a symbol.)

Author(s)

Jerome Sueur, improved by Laurent Lellouch

References

Cazelles, B. 2004 Symbolic dynamics for identifying similarity between rhythms of ecological time series. Ecology Letters, 7: 755-763.

See Also

symba

Examples

# a random variable
discrets(rnorm(30))
discrets(rnorm(30),symb=3)
# a frequency spectrum
data(tico)
spec1<-spec(tico,f=22050,at=0.2,plot=FALSE)
discrets(spec1[,2])

[Package seewave version 2.1.6 Index]