| symba {seewave} | R Documentation |
This function analyses one or two sequences of symbols from numeric (time) series.
symba(x, y = NULL, symb = 5, collapse = TRUE, entropy = "abs", plot = FALSE, type = "l", lty1 = 1, lty2 = 2, col1 = 2, col2 = 4, cex1 = 0.75, cex2= 0.75, xlab = "index", ylab = "Amplitude", legend=TRUE, ...)
x |
a vector, a matrix (first column),
an object of class ts, Sample (left channel),
or Wave (left channel). |
y |
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. |
entropy |
either "abs" for an absolute value or "rel" for a relative value, i. e. between 0 and 1. |
plot |
logical, if TRUE plots the series x (and y) and the respective symbols. |
type |
if plot is TRUE, type of plot that should be drawn.
See plot for details (by default "l" for lines). |
lty1 |
line type of the object x if type="l". |
lty2 |
line type of the object y if type="l". |
col1 |
colour of the object x. |
col2 |
colour of the object y. |
cex1 |
character size of x symbols. |
cex2 |
character size of y symbols. |
xlab |
title of the x axis. |
ylab |
title of the y axis. |
legend |
logical, if TRUE and if y is not NULL adds a legend to the plot. |
... |
other plot graphical parameters. |
The analysis consists in transforming the series into a sequence of symbols (see the function
discrets) and in computing the absolute frequency of each symbol within the sequence.
The entropy (H) is then calculated using the symbol frequencies.
Using the argument entropy, the entropy can be expressed along an absolute scale or as a relative
value varying between 0 and 1.
If two numeric (time) series are provided (x and y) the absolute symbol
frequencies and entropy of each series is returned. Besides the mutual information (I)
is estimated according to:
I = Hx + Hy - Hxy
with with Hx the entropy of x symbol sequence,
Hy the entropy of y symbol sequence, and Hxy the joint entropy
of x and y symbol sequences.
If y is NULL a list of three items is returned (s1, freq1, h1).
If y is not NULL, a list of 6 items is returned (s1, freq1, h1, s2, freq2, h2, I):
s1 |
the sequence of symbols of x, |
freq1 |
the absolute frequency of each x symbol, |
h1 |
the entropy of x symbol sequence, |
s2 |
the sequence of symbols of y, |
freq2 |
the absolute frequency of each y symbol, |
h2 |
the entropy of y symbol sequence, |
I |
the mutual information between x and y. |
It might be useful to round the values of the input series (see examples).
The mutual information (I) should increase with the similarity
between the series to compare (x and y)..
Jerome Sueur sueur@mnhn.fr
Cazelles, B. 2004 Symbolic dynamics for identifying similarity between rhythms of ecological time series. Ecology Letters, 7: 755-763.
# analysis of a frequency spectrum data(tico) spec1<-spec(tico,f=22050,at=0.2,plot=FALSE) symba(spec1[,2],plot=TRUE) # it might be better to round the values symba(round(spec1[,2],2),plot=TRUE) # in that case the symbol entropy is almost similar to the spectral entropy symba(round(spec1[,2],2),entrop="rel")$h1 sh(spec1) # to compare two frequency spectra spec2<-spec(tico,f=22050,wl=512,at=1.1,plot=FALSE) symba(round(spec1[,2],2),round(spec2[,2],2),plot=TRUE)