[R] Spectral Coherence

Joseph Park jpark.us at att.net
Mon Jul 11 23:04:54 CEST 2011

   I would like to estimate a spectral coherence between
   two timeseries. The stats : spectrum() returns a coh matrix
   which estimates coherence (squared).
   A basic test which from which i expect near-zero coherence:
   x = rnorm(500)
   y = rnorm(500)
   xts = ts(x, frequency = 10)
   yts = ts(y, frequency = 10)
   gxy = spectrum( cbind( xts, yts ) )
   plot( gxy $ freq, gxy $ coh )
   yields a white spectrum of 1. Clearly i'm not using
   this correctly... or i mis-interpret the coh as a cross-spectral
   density estimate of coherence |Gxy|^2/(Gxx Gyy)
   Thanks in advance!

More information about the R-help mailing list