*
* @CROSSPEC( options ) series1 series2 start end
*
* Computes and optionally graphs the estimated coherence and phase of a
* pair or series. series1 is treated as the "output" for the purposes of
* interpreting the phase, and series2 as the "input", so a positive
* value means 2 is that fraction of a cycle ahead of 1.
*
* Options:
* ORDINATES=Number of ordinates [depends upon length,seasonal]
* WINDOW=[FLAT]/TENT/QUADRATIC
* WIDTH=Window width [depends upon ordinates]
*
* [GRAPH]/NOGRAPH
* HEADER=Header for graph
* FOOTER=Footer for graph
*
* PHASE=series for [0,pi] phase lead (0 frequency at entry 1)
* COHERENCE=series for [0,pi] coherence (0 frequency at entry 1)
*
* Revision schedule
* 04/1995 Replaced SPGRAPH(TWOSCALE) with GRAPH(OVERLAY=LINE,...)
* 04/1995 COMPUTE HALF added
* 10/1999 Update to version 5.0 replacing GRAPH with SCATTER.
* 05/2005 Add calculation of the gain (from series2 to series1)
* 07/2007 Add FOOTER option and WINDOW=QUADRATIC
* 07/2015 Add COHERENCE and PHASE options
*
procedure crosspec series1 series2 start end
type series series1 series2
type integer start end
local integer i nobs startl endl freqords half
local series lcoherence lphase frequencies
local real scalefac
option int width
option int ordinate
option choice window 1 flat tent quadratic
option switch graph 1
option string header
option string footer
option series *phase
option series *coherence
*
if .not.%defined(series1).or..not.%defined(series2) {
display "Syntax: @crosspec series1 series2 start end"
return
}
*
* Set the range to the maximum allowed by the series pair
* if start and end aren't provided.
*
inquire(reglist) startl<