corenv {seewave} | R Documentation |
Cross-correlation between two time wave envelopes
Description
This function tests the similarity between two time wave envelopes by returning their maximal correlation and the time shift related to it.
Usage
corenv(wave1, wave2, f, channel=c(1,1), envt="hil", msmooth = NULL, ksmooth = NULL,
ssmooth = NULL, plot = TRUE, plotval = TRUE,
method = "spearman", col = "black", colval = "red",
cexval = 1, fontval = 1, xlab = "Time (s)",
ylab = "Coefficient of correlation (r)", type = "l", pb = FALSE, ...)
Arguments
wave1 |
a first R object. |
wave2 |
a second R object. |
f |
sampling frequency of |
channel |
channel of the R objects, by default left channel (1) for each object. |
envt |
the type of envelope to be used: either "abs" for absolute
amplitude envelope or "hil" for Hilbert amplitude envelope. See |
msmooth |
a vector of length 2 to smooth the amplitude envelope with a
mean sliding window. The first component is the window length
(in number of points). The second component is the overlap between
successive windows (in %). See |
ksmooth |
|
ssmooth |
sum smooth. See |
plot |
logical, if |
plotval |
logical, if |
method |
a character string indicating which correlation coefficient is
to be computed ("pearson", "spearman", or "kendall")
(see |
col |
colour of r values. |
colval |
colour of r max and frequency offset values. |
cexval |
character size of r max and frequency offset values. |
fontval |
font of r max and frequency offset values. |
xlab |
title of the frequency axis. |
ylab |
title of the r axis. |
type |
if |
pb |
if |
... |
other |
Details
Successive correlations between the envelopes of wave1
and wave2
are computed when regularly sliding forward and backward wave2
along
wave1
.
The maximal correlation is obtained at a particular shift (time offset).
This shift may be positive or negative.
The higher smooth
is set up,
the faster will be the computation but less precise the results will be.
The corresponding p value, obtained with cor.test
, is plotted.
Inverting wave1
and wave2
may give slight different results.
Value
If plot
is FALSE
, corenv
returns a list containing four
components:
r |
a two-column matrix, the first colum corresponding to the time
shift (frequency x-axis) and the second column corresponding to the successive
r correlation values between |
rmax |
the maximum correlation value between |
p |
the p value corresponding to |
t |
the time offset corresponding to |
Author(s)
Jerome Sueur
See Also
env
,corspec
,covspectro
,
cor
,cor.test
.
Examples
## Not run:
data(orni)
# cross-correlation between two echemes of a cicada song
wave1<-cutw(orni,f=22050,from=0.3,to=0.4,plot=FALSE)
wave2<-cutw(orni,f=22050,from=0.58,to=0.68,plot=FALSE)
corenv(wave1,wave2,f=22050)
## End(Not run)