1
$\begingroup$

Currently I'm writing my master thesis and I'm having troubles with coherence definition. My question is similar to https://stats.stackexchange.com/questions/92412/clear-steps-to-calculate-coherence-between-two-time-series

Mathematically it's defined as

$$C_{xy}(\omega) = \displaystyle{\frac{|S_{xy}(\omega)|^2}{S_{xx}(\omega) S_{yy}(\omega)}} $$

where $S_{xy}$ is the cross-spectrum between $X$, $Y$ and $S_{xx} \text{ and } S_{yy}$ the corresponding power spectra and $|*|$ operator corresponding to complex numbers magnitude. However, when doing the math using the periodogram estimation

$$\hat{S}_{xy}(\omega) = \frac{1}{N} x(\omega) y^{*}(\omega)$$

(being $x(\omega)$ the DFT of $X$ and $y^{*}(\omega)$ the conjugated DFT of $Y$) everything cancels out and $C_{xy}$ turn to be $1$ for all $\omega$. Let $x(\omega)= a+bi$ and $y(\omega)=c+di$, using periodogram estimation we get:

  1. $\hat{S}_{xx}(\omega) = \frac{1}{N} x(\omega)x^*(\omega) = \frac{1}{N}|x(\omega)|^2 = \frac{1}{N} (a^2+b^2)$
  2. $\hat{S}_{yy}(\omega) = \frac{1}{N} y(\omega)y^*(\omega) = \frac{1}{N}|y(\omega)|^2 = \frac{1}{N} (c^2+d^2)$
  3. $|\hat{S}_{yy}(\omega)|^2 = |\frac{1}{N} x(\omega)y^*(\omega)|^2 = \frac{1}{N^2} |(a+bi)(c+di)|^2 = \frac{1}{N^2} |(ac-bd)+(ad+bc)i|^2 = \frac{1}{N^2} ((ac-bd)^2+(ad+bc)^2) = \frac{1}{N^2} (a^2c^2+b^2d^2+a^2d^2+b^2c^2) = \hat{S}_{xx}(\omega)\hat{S}_{yy}(\omega)$

so when computing $C_{xy}(\omega)$ it turns to be 1 for all $\omega$. This is where my question arises:

I'm using seewave::coh function from R to compute coherence, which calls spec.pgram function in this part of the source code:

Y <- spec.pgram(cbind(wave1, wave2), fast = FALSE, taper = FALSE, spans = c(3, 3), plot = FALSE)$coh

I get that spans argument allows to avoid the "always 1 problem", but I don't get the "how". I would really appreciate if some of you could explain $\text{how}$ this works in the definition given above. Thank you so much.

$\endgroup$
  • $\begingroup$ "Everything cancels out": How so? $\endgroup$ – Marcus Müller Dec 2 at 7:16
  • $\begingroup$ Your “definitions” have problems, What have you read? $\endgroup$ – Stanley Pawlukiewicz Dec 2 at 13:11
  • $\begingroup$ @MarcusMüller if you consider the cross-spectrum and power-spectrum definition and do use complex numbers to represent $X(\omega)$ and $Y(\omega)$, you get the result. $\endgroup$ – Jorge Mendoza Ruiz Dec 2 at 16:57
  • $\begingroup$ @StanleyPawlukiewicz I read it in 'Signal Processing for Neuroscientists' from 'Wim van Drongelen'. Cap 8, Page 141. May I ask which definitions have problems? $\endgroup$ – Jorge Mendoza Ruiz Dec 2 at 17:00
  • $\begingroup$ @JorgeMendozaRuiz again, I don't. How do you get that result where things cancel? Please add your calculation to your question. $\endgroup$ – Marcus Müller Dec 2 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.