cross_spectrum: Calculate the cross-spectrum of two timeseries

Description Usage Arguments Examples

View source: R/cross.R

Description

Calculate the cross-spectrum of two timeseries

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
cross_spectrum(x, ...)

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

## Default S3 method:
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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)

kitagawa documentation built on July 2, 2020, 1:47 a.m.