Learn R Programming

fftab (version 0.1.0)

cross_spec: 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)

# S3 method for default cross_spec(a, b, norm = FALSE, conj = TRUE)

# S3 method for ts cross_spec(a, b, norm = FALSE, conj = TRUE)

# S3 method for array cross_spec(a, b, norm = FALSE, conj = TRUE)

# S3 method for fftab cross_spec(a, b, norm = FALSE, conj = TRUE)

Value

An object representing the cross-spectrum:

  • For default and fftab methods: A fftab object.

  • For ts objects: A fftab object with .tsp attributes inherited from a.

  • For arrays: A fftab object with .dim attributes inherited from a.

Arguments

a

The first input for the cross FFT. Supported types include numeric vectors, ts objects, arrays, and fftab objects.

b

The second input for the cross FFT. Must match the dimensions or structure of a.

norm

Logical; if TRUE, normalizes the Fourier transforms before computation. Default is FALSE.

conj

Logical; if TRUE, uses the complex conjugate of the Fourier transform of b. Default is TRUE.

Methods (by class)

  • cross_spec(default): Default method for computing cross FFT. Converts inputs to fftab objects before computation.

  • cross_spec(ts): Method for time series (ts) objects. Ensures the time series frequencies are consistent and preserves the tsp attribute.

  • cross_spec(array): Method for array inputs. Ensures dimensions are consistent and preserves the dim attribute.

  • cross_spec(fftab): Method for fftab objects. Performs the cross-frequency transform directly using the Fourier transforms of a and b.

See Also

fftab()

Examples

Run this code
cross_spec(rnorm(8), rnorm(8), norm = TRUE)

cross_spec(
  ts(rnorm(8), frequency = 4),
  ts(rnorm(8), frequency = 4)
)

Run the code above in your browser using DataLab