Learn R Programming

kitagawa (version 3.1.2)

cross_spectrum: Calculate the cross-spectrum of two timeseries

Description

Calculate the cross-spectrum of two timeseries

Usage

cross_spectrum(x, ...)

# S3 method for mts cross_spectrum(x, ...)

# S3 method for default cross_spectrum( x, y, k = 10, samp = 1, q, adaptive = FALSE, verbose = FALSE, ... )

Arguments

x

numeric; timeseries

...

additional arguments to pspectrum

y

numeric; timeseries. if missing, assumed to be column no. 2 in x

k

integer; the number of sine tapers, unless this is NULL; in the latter case a Welch-based spectrum is calculated rather than a multitaper spectrum. There are distinct advantages and disadvantages to either of these.

samp

numeric; the sampling rate (e.g., deltat) of the data; must be the same for x and y

q

numeric; the probability quantile [0,1] to calculate coherence significance levels; if missing, a pre-specified sequence is included. This is will be ignored for Welch-based spectra (see k).

adaptive

logical; should adaptive multitaper estimation be used?

verbose

logical; should messages be printed?

Examples

Run this code
require(stats)
require(psd)

n <- 1000
ramp <- seq_len(n)
parab <- ramp^2

set.seed(1255)
X <- ts(rnorm(n) + ramp/2)
Y <- ts(rnorm(n) + ramp/10 + parab/100)

# Calculate the multitaper cross spectrum
csd <- cross_spectrum(X, Y, k=20)

Run the code above in your browser using DataLab