Learn R Programming

timsac (version 1.3.0)

fftcor: Auto And/Or Cross Correlations via FFT

Description

Compute auto and/or cross covariances and correlations via FFT.

Usage

fftcor(y, lag=NULL, isw=4, plot=TRUE, lag_axis=TRUE)

Arguments

y
data of channel X and Y (data of channel Y is given for isw = 2 or 4 only).
lag
maximum lag. Default is $2 \sqrt{n}$, where $n$ is the length of the time series y.
isw
numerical flag giving the type of computation. rl{ 1 : auto-correlation of X (one-channel) 2 : auto-correlations of X and Y (two-channel) 4 : auto- and cross- correlations of X and Y (two-channel) }
plot
logical. If TRUE (default) cross-correlations are plotted.
lag_axis
logical. If TRUE (default) with plot=TRUE, $x$-axis is drawn.

Value

  • acovauto-covariance.
  • ccov12cross-covariance.
  • ccov21cross-covariance.
  • acorauto-correlation.
  • ccor12cross-correlation.
  • ccor21cross-correlation.
  • meanmean.

References

H.Akaike and T.Nakagawa (1988) Statistical Analysis and Control of Dynamic Systems. Kluwer Academic publishers.

Examples

Run this code
# Example 1
  x <- rnorm(200)
  y <- rnorm(200)
  xy <- array(c(x,y), dim=c(200,2))
  fftcor(xy, lag_axis=FALSE)

  # Example 2
  xorg <- rnorm(1003)
  x <- matrix(0,1000,2)
  x[,1] <- xorg[1:1000]
  x[,2] <- xorg[4:1003]+0.5*rnorm(1000)
  fftcor(x, lag=20)

Run the code above in your browser using DataLab