naginterfaces.library.tsa.multi_​spectrum_​lag

naginterfaces.library.tsa.multi_spectrum_lag(nxy, mtxy, pxy, iw, mw, ish, ic, cxy, cyx, kc, l, xg=None, yg=None)[source]

multi_spectrum_lag calculates the smoothed sample cross spectrum of a bivariate time series using one of four lag windows: rectangular, Bartlett, Tukey or Parzen.

For full information please refer to the NAG Library document for g13cc

https://www.nag.com/numeric/nl/nagdoc_27.1/flhtml/g13/g13ccf.html

Parameters
nxyint

, the length of the time series and .

mtxyint

If cross-covariances are to be calculated by the function (), must specify whether the data is to be initially mean or trend corrected.

For no correction.

For mean correction.

For trend correction.

If cross-covariances are supplied , is not used.

pxyfloat

If cross-covariances are to be calculated by the function (), must specify the proportion of the data (totalled over both ends) to be initially tapered by the split cosine bell taper. A value of implies no tapering.

If cross-covariances are supplied , is not used.

iwint

The choice of lag window.

Rectangular.

Bartlett.

Tukey.

Parzen.

mwint

, the ‘cut-off’ point of the lag window, relative to any alignment shift that has been applied. Windowed cross-covariances at lags or less, and at lags or greater are zero.

ishint

, the alignment shift between the and series. If leads , the shift is positive.

icint

Indicates whether cross-covariances are to be calculated in the function or supplied in the call to the function.

Cross-covariances are to be calculated.

Cross-covariances are to be supplied.

cxyfloat, array-like, shape

If , must contain the cross-covariances between values in the series and earlier values in time in the series, for lags from to .

If , need not be set.

cyxfloat, array-like, shape

If , must contain the cross-covariances between values in the series and later values in time in the series, for lags from to .

If , need not be set.

kcint

If , must specify the order of the fast Fourier transform (FFT) used to calculate the cross-covariances.

If , that is if covariances are supplied, is not used.

lint

, the frequency division of the spectral estimates as . Therefore, it is also the order of the FFT used to construct the sample spectrum from the cross-covariances.

xgNone or float, array-like, shape , optional

Note: the required length for this argument is determined as follows: if : ; otherwise: .

If the cross-covariances are to be calculated, then must contain the data points of the series. If covariances are supplied, need not be set.

ygNone or float, array-like, shape , optional

Note: the required length for this argument is determined as follows: if : ; otherwise: .

If cross-covariances are to be calculated, must contain the data points of the series. If covariances are supplied, need not be set.

Returns
cxyfloat, ndarray, shape

If , will contain the calculated cross-covariances.

If , the contents of will be unchanged.

cyxfloat, ndarray, shape

If , will contain the calculated cross-covariances.

If , the contents of will be unchanged.

xgfloat, ndarray, shape

Contains the real parts of the complex spectral estimates in elements to , and to contain . The series leads the series.

ygfloat, ndarray, shape

Contains the imaginary parts of the complex spectral estimates in elements to , and to contain . The series leads the series.

ngint

The number, , of complex spectral estimates, whose separate parts are held in and .

Raises
NagValueError
(errno )

On entry, , and .

Constraint: if , .

(errno )

On entry, , and .

Constraint: if , .

(errno )

On entry, .

Constraint: if , .

(errno )

On entry, .

Constraint: if , .

(errno )

On entry, .

Constraint: if then , or .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, , and .

Constraint: .

(errno )

On entry, , and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: , , or .

(errno )

On entry, .

Constraint: .

(errno )

On entry, , and .

Constraint: if , .

(errno )

On entry, and .

Constraint: .

Notes

The smoothed sample cross spectrum is a complex valued function of frequency , , defined by its real part or co-spectrum

and imaginary part or quadrature spectrum

where , for , is the smoothing lag window as defined in the description of uni_spectrum_lag(). The alignment shift is recommended to be chosen as the lag at which the cross-covariances peak, so as to minimize bias.

The results are calculated for frequency values

where denotes the integer part.

The cross-covariances may be supplied by you, or constructed from supplied series ; as

this convolution being carried out using the finite Fourier transform.

The supplied series may be mean and trend corrected and tapered before calculation of the cross-covariances, in exactly the manner described in uni_spectrum_lag() for univariate spectrum estimation. The results are corrected for any bias due to tapering.

The bandwidth associated with the estimates is not returned. It will normally already have been calculated in previous calls of uni_spectrum_lag() for estimating the univariate spectra of and .

References

Bloomfield, P, 1976, Fourier Analysis of Time Series: An Introduction, Wiley

Jenkins, G M and Watts, D G, 1968, Spectral Analysis and its Applications, Holden–Day