corenv                package:seewave                R Documentation

_C_r_o_s_s-_c_o_r_r_e_l_a_t_i_o_n _b_e_t_w_e_e_n _t_w_o _t_i_m_e _w_a_v_e _e_n_v_e_l_o_p_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     This function tests the similarity between two time wave envelopes
     by returning their maximal correlation and the time shift related
     to it.

_U_s_a_g_e:

     corenv(wave1, wave2, f, smooth = 20, plot = TRUE, plotval = TRUE,
     method = "spearman", col = "black", colval = "red",
     cexval = 1, fontval = 1, xlab = "Time (s)",
     ylab = "Coefficient of correlation (r)", ...)

_A_r_g_u_m_e_n_t_s:

   wave1: data describing a first time wave.

   wave2: data describing a second time wave.

       f: sampling frequency of 'wave1' and 'wave2'.

  smooth: smoothes the envelopes of 'wave1' and 'wave2' by averaging
          the number of points selected.

    plot: logical, if 'TRUE' plots r values against frequency shift (by
          default 'TRUE').

 plotval: logical, if 'TRUE' adds to the plot maximum r value and
          frequency offset (by default 'TRUE').

  method: a character string indicating which correlation coefficient
          is to be computed ("pearson", "spearman", or "kendall") (see
          'cor').

     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.

     ...: other 'plot' graphical parameters.

_D_e_t_a_i_l_s:

     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.

_V_a_l_u_e:

     If 'plot' is 'FALSE', 'corenv' returns a list containing four
     components: 

       r: the successive correlation values between 'x' and 'y'.

    rmax: the maximum correlation value between 'x' and 'y'.

       p: the p value corresponding to 'rmax'.

       f: the time offset corresponding to 'rmax'.

_A_u_t_h_o_r(_s):

     Jrme Sueur jerome.sueur@ibaic.u-psud.fr

_S_e_e _A_l_s_o:

     'spec','covspectro', 'cor', 'cor.test'.

_E_x_a_m_p_l_e_s:

     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,type="l",ylim=c(-0.7,1.1))

