Perform Modified Daniell (Rectangular) Smoothing

DESCRIPTION:
Performs iterations of modified Daniell (rectangular) smoothing on x (usually a periodogram). The input x is by default assumed to be symmetric about its endpoints.

USAGE:
spec.smo(x, span=3, iter=1, symmetry="even")

REQUIRED ARGUMENTS:
x:
a univariate or multivariate time series, or a vector, or a matrix (with columns representing univariate series) to be smoothed. Missing values are not allowed.

OPTIONAL ARGUMENTS:
span:
integer or a vector of integers giving the length of the smoothing window for each series. These should be odd integers, even integers will be increased by 1. The default is to consider only the two neighboring values and x[i] in smoothing x[i]. This must be a single number in the univariate case. For multivariate time series, span can either be a scalar or a vector with as many elements as columns in the series. If a scalar, each column will be smoothed using the same value of span.
iter:
integer giving the number of smoothing passes. This can also be a vector with as many elements as columns in the time series if different number of passes are desired for different columns of x.
symmetry:
parameter defining the symmetry of x about its endpoints. If symmetry = "even", even symmetry is assumed: x(k) = x(-k); if symmetry = "odd", odd symmetry is assumed: x(k) = -x(-k); if symmetry = "zero", the values extended from the endpoints of x are 0. The default value of "even" is correct for smoothing periodograms and the real part of cross periodograms; symmetry = "odd" is needed for the imaginary part of cross periodograms.

VALUE:
an object like x containing the smoothed values.

DETAILS:
If span>1 and iter=1, x[i] is replaced by

(0.5 * x[i-(span-1)/2] + x[i-(span-1)/2+1] +...+ x[i+(span-1)/2-1] + 0.5 * x[i+(span-1)/2] ) / (span-1))

so the smoothing window or average actually includes span points with half-weights on the ends. In the multivariate case, the same process is repeated for each column of x. span must be greater than 1 for x to be smoothed.


REFERENCES:
Bloomfield, P. (1976). Fourier Analysis of Time Series: An Introduction. Wiley, New York.

The Time Series chapter of the S-PLUS User's Manual.


SEE ALSO:
spectrum , spec.pgram .

EXAMPLES:
spec.smo(x)
# returns vector with ith element 0.25x(i-1)+0.5x(i)+0.25x(i+1)
spec.smo(x, 3, 2)  # returns vector with ith element
# .0625x(i-2)+0.25x(i-1)+0.375x(i)+0.25x(i+1)+.0625x(i+2)