Compute Autoregressive Spectrum

DESCRIPTION:
Computes the spectrum of a time series using the results of an autoregression.

USAGE:
spec.ar(ar.list, n.freq=<<see below>>, frequency=<<see below>>, plot=F)

REQUIRED ARGUMENTS:
ar.list:
a list like the one returned by the function ar. It must have the components ar, var.pred and order. Component ar is an order by "nser" by "nser" array of autoregressive coefficients where order is the autoregressive order and "nser" is the number of components of the original multivariate series. Component var.pred is the prediction variance (the innovations variance) of the series.

OPTIONAL ARGUMENTS:
n.freq:
the number of frequencies between 0 and the Nyquist frequency (=frequency/2 cycles per unit time) at which to compute the spectrum. The default value is n.used/2+1, where n.used is the number of observations not missing in the original time series. This must be supplied if n.used is not a component of ar.list.
frequency:
the sampling frequency for the time series. The default is the frequency of the resid component of ar.list if present, and 1 otherwise.
plot:
if TRUE, a plot of the spectrum will be produced.

VALUE:
a list containing the following components:
freq:
the vector of frequencies between 0 and the Nyquist at which the spectrum estimate is computed.
spec:
a vector if a univariate series, and otherwise a matrix with columns representing univariate series and rows corresponding to the frequencies in freq. The spectrum estimate is in decibels (10 times log to base 10 transformation).
coh:
a matrix containing the squared coherencies between each pair of series. If j is less than k, then the pair (j,k) corresponds to column (k-1)(k-2)/2 + j. For univariate series this component is NULL.
phase:
a matrix like coh containing the phase differences between each pair of series (only for multivariate time series). The units are radians. These are made continuous by requiring that the first differences be less than pi. To put them back into the range [0, 2 pi) use the modulus operator %%: e.g. reducedphase <- phase%%(2*pi). For univariate series this component is NULL.
order:
the order of the autoregression in ar.list.
method:
a string describing the method used.
series:
a string containing the name of the time series, if available from ar.list.

SIDE EFFECTS:
If plot=TRUE, a plot of the spectrum is produced.

SEE ALSO:
ar , spec.pgram , spec.plot , spectrum .

EXAMPLES:
ll.ar <- ar(log(lynx))          # Fit an AR model to the log of the lynx data
spec <- spec.pgram(log(lynx))   # and superimpose the raw periodogram for this
ll.spec.ar <- spec.ar(ll.ar, plot=F)   # data and its autoregressive spectrum.
spec.plot(ll.spec.ar, add=T)