cross_spec {fftab} | R Documentation |
Compute the Cross-Spectrum (Cross FFT)
Description
The cross_spec
function computes the cross-spectrum between two inputs
using the Fourier transform. It supports multiple input types including
numeric vectors, time series (ts
), arrays, and fftab
objects.
The function provides options for normalization and controlling whether the
conjugate of the second input is used.
Usage
cross_spec(a, b, norm = FALSE, conj = TRUE)
## Default S3 method:
cross_spec(a, b, norm = FALSE, conj = TRUE)
## S3 method for class 'ts'
cross_spec(a, b, norm = FALSE, conj = TRUE)
## S3 method for class 'array'
cross_spec(a, b, norm = FALSE, conj = TRUE)
## S3 method for class 'fftab'
cross_spec(a, b, norm = FALSE, conj = TRUE)
Arguments
a |
The first input for the cross FFT. Supported types include numeric
vectors, |
b |
The second input for the cross FFT. Must match the dimensions or
structure of |
norm |
Logical; if |
conj |
Logical; if |
Value
An object representing the cross-spectrum:
For
default
andfftab
methods: Afftab
object.For
ts
objects: Afftab
object with.tsp
attributes inherited froma
.For arrays: A
fftab
object with.dim
attributes inherited froma
.
Methods (by class)
-
cross_spec(default)
: Default method for computing cross FFT. Converts inputs tofftab
objects before computation. -
cross_spec(ts)
: Method for time series (ts
) objects. Ensures the time series frequencies are consistent and preserves thetsp
attribute. -
cross_spec(array)
: Method for array inputs. Ensures dimensions are consistent and preserves thedim
attribute. -
cross_spec(fftab)
: Method forfftab
objects. Performs the cross-frequency transform directly using the Fourier transforms ofa
andb
.
See Also
Examples
cross_spec(rnorm(8), rnorm(8), norm = TRUE)
cross_spec(
ts(rnorm(8), frequency = 4),
ts(rnorm(8), frequency = 4)
)