Next: costaper() Up: Time Series Macros Help Previous: complex_fun   Contents

compza()

Usage:
compza(y [,degree:D, alpha:A, nfreq:Nfreq]), y a REAL vector or matrix,
  D and Nfreq != 0 integers, 0 <= A <= .5



Keywords: frequency domain, spectrum analysis
                                  Usage
compza(y,nfreq:Nfreq,degree:D,alpha:A) computes scaled Fourier
transforms of the columns of REAL matrix y after detrending and
tapering them.  They are scaled by dividing by sqrt(Ka) where Ka =
sum(taper^2).

The number of frequencies at which the Fourier transform is computed is
abs(Nfreq).  It is an error if Nfreq > 0 and has a prime factor > 29.

Integer D = degree of polynomial used to detrend the columns of y.  D <
0 means no detrending, not even subtracting a mean.

Scalar A >= 0 is the proportion of tapering on each end of the time
series.

See below for defaults for Nfreq, A and Nfreq.

The value is structure(za:Za, n:nrows(y), ka:Ka, alpha:A, degree:D)
  Za        The Nfreq by ncols(y) matrix of Fourier transforms of the
            detrended and then tapered columns of y, in Hermitian form
  Ka        sum(W^2), where vector W are the tapering factors

                         Default keyword values
The values of the optional keyword phrase arguments are REAL scalars
with the following restrictions and default values.
 Keyword  Value     Default Value      Restrictions
 degree     D             0            Integer
 alpha      A             0            0 <= A <= .5.
 nfreq      Nfreq      See below       Integer != 0 with abs(Nfreq)
                                       not having prime factors > 29

When nfreq:Nfreq is not an argument and positive integer variable S
does not exist, Nfreq is the smallest integer >= 2*nrows(y) with no
prime factor > 29, that is Nfreq = goodfactors(2*nrows(y)).

When S does exist and is a positive integer, nFreq = S.  It is an error
if S has a prime factor > 29.

                               Detrending
When D > 0, the columns of y are detrended with a polynomial in time of
degree D fit by least squares, that is the residuals from the polynomial
are tapered and analyzed.  When D = 0, the sample mean is subtracted.
When D < 0, no detrending is done, not even subtraction of the mean.

                                Tapering
When A = 0, no tapering is done.

When A > 0, after detrending, each column of y will be multiplied by a
cosine taper which modifies approximately A*nrows(y) values on each end
of the series, approximately 2*A*nrows(y) values in all.  Thus alpha:.5,
say, means that the all the observations, except the middle one, when N
is odd, are tapered.  Similarly, alpha:.1 directs that 10% of the
observations at the start and 10% at the end, or 20% in all, will be
tapered.

NOTE: The interpretation of tapering proportion A differs from that
used by some practitioners, for whom the tapering proportion is the
proportion of the entire series modified that is tapered.  To modify
100*P percent of the entire series, use alpha:P/2.

See topic costaper() for an exact definition of the taper used.

                                 Method
After detrending followed by tapering, enough zero rows are added to the
end to bring the total number of rows to Nfreq and then rft() is used to
compute the Hermitian form of the Fourier transforms of each column.
These are sometimes known as "modified Fourier transforms".  Finally
they are divided by sqrt(Ka), where Ka = sum(taper^2); see above.

                            Other macros used
compza() uses macros detrend() and costaper().  If they have not
previously been loaded, they are read from file tser.mac.

                             Cross reference
See also detrend(), costaper(), 'hermitian', 'complex_fun',
'complex_data', rft(), 'complex'.


Gary Oehlert 2005-08-12