*! version 1.0 01apr2016
help cospectdens

Title

cospectdens -- Compute and graph cross spectral measures between x and y

Syntax

cospectdens
varlist
[if] [in]
[,
options]

Main
meanadj Compute deviation from sample mean default=no

detrend Detrend variable, default=no

weights Weights to be applied in smoothing periodogram;
for example: weights(1 2 3 <4> 3 2 1), the number of weights should be odd >1

kernel Kernel function,
options: daniell, mdaniell, bartlett, parzen, tukey, qs

bandwidth one-sided lag length for the kernel function

convdaniell Use weights from the convolution of the uniform (Daniell) weights;
for example conv(3 2) computes weights by repeated application of
uniform weights with lag lengths 3 and 2

out Create an output data set containing frequency, wavelength,
periodograms, spectral density, cross-periodogram, cospectrum, coherency-squared,
amplitude spectrum, phase spectrum, gain spectrum.

Replace Replace out.dta dataset if already exists

nograph No graphical output;
Default is to graph coherency-squared

Description

cospectdens Computes several quantities commonly used in bivariate spectral analysis such as
cospectrum, coherency-squared, phase spectrum and gain spectrum. varlist accepts two time series: the first variable is
treated as the output variable (y), and the second variable is treated as the input variable (x).
Smoothing is directly applied to
individual periodogram and cross-periodogram obtained from the FFT of variables.
Endpoints are adjusted cyclically in the central moving average smoothing.
Users may supply their weights as an option or
choose one of the weighting schemes. Current version does not apply tapering.
This command only graphs the coherency-squared which may be
interpreted as the frequency-domain counterpart of the correlation coefficient. To graph other measures users
may request them to be saved in an output file.

Options

Main

meanadj Request mean-adjustment before computing sample spectral
density, default = no mean adjustment

detrend Request detrending data. Residual vector from the regression
of varlist on the linear trend is used in the computations.
Note that data will also be mean-adjusted. Default = no detrend

weights Odd number of numlist in the form of weights(1 2 3 <4> 3 2 1)
Weights are rescaled to sum to 1.

kernel String name of the kernel function. One of:

daniell (this is also known as uniform or truncated weights)

mdaniell (modified daniell uses half the uniform weight at the endpoints)

bartlett

parzen

tukey

qs (quadratic spectral)

bandwidth One-sided lag window to be used with the kernel function
This option can be used with the kernel option. For example,
when bandwidth(2) the window length is 5 with current periodogram
ordinate at the center. If kernel is specified but not the bandwidth
default values are used.

convdaniell Use weights from repeated application of daniell weights.
For example conv(3 3 2) implies repeated smoothing by daniell
weights with lags 3, 3, and 2.

out Create an output dataset with the name provided in out(string). Out
data set contains frequency, wavelength, sine and cosine transformations of each variable,
periodogram ordinates of each variable, real and imaginary parts of cross-periodogram,
cospectrum, quadrature spectrum, coherency-squared, amplitude, phase, and gain spectra.

replace Replace the out.dta dataset if it already exists.

nograph Requests no graphical output.
Default is to plot coherency-squared (graph).

Examples

. webuse lutkepohl

. cospectdens dlincome dlconsumption, weights(1 2 3 <4> 3 2 1) m

. cospectdens dlincome dlconsumption, conv(3 2) m

. cospectdens dlincome dlinvestment, conv(3 2) m

Saved Results

cospectdens returns:

scalars:
r(dof) = equivalent degrees of freedom
r(N) = number of observations
r(halfbw) = half bandwidth

macros:
r(kernel) : kernel type

matrices:
r(W) : weights
r(P) : floor(N/2)+1 x 11 matrix containing spectral measures

References

P. Bloomfield, Fourier Analysis of Time Series, Wiley, 2nd ed., 2000.
P.J. Brockwell and R.A. Davis, Time Series: Theory and Methods, Springer, 2nd ed., 2006.
J. Hamilton, Time Series Analysis, Princeton, 1st ed., 1994.
R.H. Shumway and D.S. Stoffer, Time Series Analysis and Its Applications, Springer, 3rd ed., 2011.

Author

Hüseyin Tastan (tastan@yildiz.edu.tr)
Yildiz Technical University
Department of Economics
Istanbul Turkey