# Re: [R] Cross Spectrum Analysis

From: stephen sefick <ssefick_at_gmail.com>
Date: Sun, 04 May 2008 15:14:38 -0400

Stephen

On Sat, May 3, 2008 at 6:11 PM, Maura E Monville <maura.monville_at_gmail.com> wrote:

> In the case of muitivariate, from the documentation it looks like I can
> compare more than two signals at a time.
> Each column of the input matix seem to accommodate a signal.
> The problem is that my signals do NOT have the same number of samples
> (length).
> They were all collected at 30Hz so the sampling time interval is roughly
> 0.033[s].
> Some signals have about 5000 samples and other ones have more than 8000.
> The R routine "spectrum" expect the multivariate to be a matrix ...
> Any idea how to overcome such an obstacle ?
> Padding with zeros would alter (I think) the phenomen being studied that
> is breathing patterns.
> Is there a way to feed the "spectrum" function with the signal spectrum
> (power density) instead of the time domain signal ?
> Since the sampling interval is equal for all the signal, so is the Nyquist
> frequency. I can easily get the power spectrum
> defined over the domain [0, Nyquist-frequency] which does not have the
> problem of different lengths ... ???
>
> Thank you so much.
>
> Maura
>
> On Wed, Apr 30, 2008 at 8:56 AM, stephen sefick <ssefick_at_gmail.com> wrote:
>
> > \$names
> > [1] "freq" "spec" "coh" "phase" "kernel" "df"
> > [7] "bandwidth" "n.used" "orig.n" "series" "snames"
> > "method"
> > [13] "taper" "pad" "detrend" "demean"
> >
> > \$freq and \$spec are used to plot the power spectrum. freq is the x-axis
> > and spec is the y-axis. \$coh is the squared coherency between the two
> > signals in your case and I believe that this is also plotted against
> > frequency. This is your "correlation" strength. Phase I haven't been able
> > to figure out- I think that it is some sort of estimator for the phase
> > shift. to get either phase or coherency plot add the plot.type argument to
> >
> > x <- spectrum(yourdata, log="no") #this will plot it without a log scale
> > I find it useful to look at both the no log plot and then the logscale plot
> > (just remove the log="no")
> >
> > plot(x, plot.type="marginal") #this is the default type (the
> > powerspectrum)
> > plot(x, plot.type="phase")
> > plot(x, plot.type="coherency")
> >
> > also just look at
> >
> > ?spectrum
> > schumway is a good book - I think it is something like time series
> > analysis with examples in R
> >
> > hope this helps
> >
> > stephen
> >
> >
> > On Tue, Apr 29, 2008 at 8:54 PM, Maura E Monville <
> > maura.monville_at_gmail.com> wrote:
> >
> > > I am reading some documentation about Cross Spectrum Analysis as a
> > > technique
> > > to compare spectra.
> > > My understanding is that it estimates the correlation strength
> > > between
> > > quasi-periodic structures embedded in two signals. I believe it may be
> > > useful for my signals analysis.
> > >
> > > I was referred to the R functions that implement this type of
> > > analysis. I
> > > tried all the examples which generated a series of fancy plots. But I
> > > need
> > > to work on the numerical results.
> > >
> > > I have read that the following info is available through Cross Spectra
> > > analysis:
> > > *Cross-periodogram, Cross-Density, Quadrature-density,
> > > Cross-amplitude, Squared
> > > Coherency, Gain, and Phase Shift*
> > > I went through a couple of the two-series (bivariate) cross-spectrum
> > > analysis examples with R.
> > > I also printed out the attributes of the analysis (see the following).
> > > I
> > > cannot quite match the above quantities with the attributes/features
> > > output
> > > of cross-spectra analysis with R.
> > > I would greatly appreciate some explanation (which is what) and seeing
> > > some
> > > more worked out examples.
> > >
> > > > attributes(mfdeaths.spc)
> > > \$names
> > > [1] "freq" "spec" "coh" "phase" "kernel" "df"
> > > [7] "bandwidth" "n.used" "orig.n" "series" "snames"
> > > "method"
> > > [13] "taper" "pad" "detrend" "demean"
> > >
> > > \$class
> > > [1] "spec"
> > >
> > >
> > > Thank you so much.
> > >
> > > Yours Faithfully,
> > > --
> > > Maura E.M
> > >
> > > [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > R-help_at_r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> > >
> >
> >
> >
> > --
> > Let's not spend our time and resources thinking about things that are so
> > little or so large that all they really do for us is puff us up and make us
> > feel like gods. We are mammals, and have not exhausted the annoying little
> > problems of being mammals.
> >
> > -K. Mullis
>
>
>
>
> --
> Maura E.M

```--
Let's not spend our time and resources thinking about things that are so
little or so large that all they really do for us is puff us up and make us
feel like gods. We are mammals, and have not exhausted the annoying little
problems of being mammals.

-K. Mullis

[[alternative HTML version deleted]]

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help