Next: complex_data Up: Time Series Macros Help Previous: compfa()   Contents

# complex_fun

Keywords: complex numbers, frequency domain, fourier transforms
```Here is a brief summary of MacAnova functions for working with complex
data.

Notational conventions:
rx is a REAL vector or matrix whose columns represent real series
hx is a REAL vector or matrix whose columns represent complex series
with Hermitian symmetry (see topics 'hermitian' and 'complex_data')
cx is a REAL matrix with successive pairs of columns representing
unrestricted complex series.  If ncols(cx) is odd, the last column
represents a real series.

rft(rx) returns in Hermitian form the DFT of real series in the columns
of rx.

hft(hx) returns as real series the DFT of Hermitian complex series in
hx.

cft(cx) returns as unrestricted complex series the DFT of unrestricted
complex series in cx.

hconj(hx) and cconj(cx) compute the complex conjugate of Hermitian
series or unrestricted complex series in hx or cx.

hreal(hx) and creal(cx) return the complete real parts of Hermitian
series or unrestricted complex series in hx or cx.

himag(hx) and cimag(cx) return the complete imaginary parts of Hermitian
series or unrestricted complex series in hx or cx.

The results of hreal(), creal(), himag() and cimag() are all
unretricted Real series.

cmplx(rx1,rx2) returns the unrestricted complex form of the series
rx1+i*rx2, where i = sqrt(-1).

hpolar(hx) and cpolar(cx) return the polar forms of Hermitian series or
unrestricted complex series in hx or cx.  The amplitudes (moduli) are
returned in the real parts and the phases (arguments) are returned in
the imaginary parts.

The output of hpolar() is in Hermitian form.  The phases are in radians,
cycles, or degrees depending on the value of option 'angles'.  See
regular topic setoptions() for details.  By default, the phases are
"unwound" to minimize discontinuities if they wrap around the circle.

hrect(hx) and crect(cx) return the usual representation in terms of real
and imaginary parts of the polar forms of Hermitian series or
unrestricted complex series in hx or cx.  The phases of the polar form
are assumed to be in radians, cycles or degrees depending on the value
of option 'angles'.

htoc(hx) returns the unrestricted complex form of the Hermitian series
in hx.

ctoh(cx) returns the Hermitian symmetrization of the unrestricted
complex series in cx.  If cx has Hermitian symmetry, then htoc(ctoh(cx))
returns cx.

hprdh(hx1, hx2) returns the Hermitian form of the elementwise complex
product of the Hermitian series in hx1 and hx2.  hprdh(hx) returns
hprdh(hx,hx).

hprdhj(hx1,hx2) and hprdhj(hx) are equivalent to hprdh(hx1,hconj(hx2))
and hprdh(hx,hconj(hx)), respectively.

cprdc(cx1, cx2) returns the unrestricted complex form of the elementwise
complex product of the complex series in cx1 and cx2.  cprdc(cx) returns
cprdc(cx,cx).

cprdcj(cx1,cx2) and cprdcj(cx) are equivalent to cprdc(cx1,cconj(cx2))
and cprdc(cx,cconj(cx)), respectively.

Additional functions useful in time series analysis

autoreg(phi,x) applies an autoregressive operator specified by REAL
vector phi of length p to the columns of REAL matrix x.  Keywords
'reverse', 'limits' and 'start' allow for reversing the direction,
operating on a subset of rows and providing starting values.

Uses for autoreg() include generation of autoregressive (AR(p)) time
series (x random), computing residuals from a moving average (MA(p)
time series with coefficients phi, computing cumulative sums (phi = 1)
and solving difference equations.

The sign convention used corresponds to ARSIGN = -1.  See arimahelp
topic 'MASIGN'.

convolve(wts,x) returns the circular convolutions of REAL vector wts and
the columns of REAL matrix x.

convolve(wts,x,reverse:T) returns the sums of circularly lagged products
of wts with the columns of x.  With keyword phrase 'decimate:n' as an
argument it returns only rows 1, n+1, 2*n+1, ... of the convolutions.

movavg(theta,x) applies an moving average operator specified by REAL
vector theta of length q to the columns of REAL matrix x.  Keywords
'reverse', 'limits' and 'start' allow for reversing the direction,
operating on a subset of rows and providing starting values.

Uses for movavg() include generation of moving average (MA(q)) time
series (x random), computing residuals from a autoregressive (AR(q))
time series with coefficients theta, computing first differences (theta
= 1), and computing non-circular convolution.

The sign convention used corresponds to MASIGN = -1.  See arimahelp
topic 'MASIGN'.

n < nrows(x), the result consists of the first n rows of x.

padto() is useful in computing Fourier transforms at Nfreq frequencies
where Nfreq > nrows(x), for example, rft(padto(x,2*nrows)) computes the
Fourier transforms of the columns of x at Nfreq = 2*nrows equally spaced
frequencies.

partacf(rho) returns the partial autocorrelations corresponding the
autocorrelations in REAL vector rho.

partacf(phi,reverse:T) returns the autocorrelations corresponding the
partial autocorrelations in REAL vector phi.

polyroot(coefs) returns a REAL matrix with 2*ncols(coefs) columns
containing the complex zeros of real polynomials whose coefficients are
specified by the columns of REAL vector or matrix coefs.

polyroot() is useful in determining whether a MA operator is invertible
or a AR operator is stationary.  REAL vector theta defines an
invertible MA operator if and only if
max(creal(cpolar(polyroot(theta)))) < 1 and REAL vector phi defines a
stationary AR operator if and only if max(creal(cpolar(polyroot(phi))))
< 1.

The sign convention used corrsponds to MASIGN = -1 and ARSIGN = -1.
See arimahelp topic 'MASIGN'.

reverse(x) returns a vector or matrix whose rows are the same as those
of REAL or LOGICAL vector or matrix x but in reverse order.

unwind(theta) returns a vector or matrix derived from the columns of
REAL vector or matrix theta interpreted as angles in units of radians,
cycles or degrees depending on option 'angles'.  Multiples of 2*PI
radians, 1 cycle or 360 degrees are added or subtracted to remove large
row to row jumps.  You can specify the size of jumps using keyword
'crit'.

phi <- yulewalker(rho) computes a vector or matrix whose columns are the
autoregression coefficients that solve the Yule-Walker equations based
on autocorrelations in the corresponding column of REAL vector or matrix
rho.

rho <- yulewalker(phi,reverse:T) computes a vector or matrix
autocorrelations that satisfies phi = yulewalker(rho).

Informational Topics
See topic 'hermitian' for the definition of Hermitian symmetry.

See topic 'fourier' for information on Fourier transforms.

See topic 'complex_data; for information on representing complex data.

See regular MacAnova help topics for full information on cft(), hft(),
rft(), creal(), hreal(), cimag(), himag(), cmplx(), cpolar(), hpolar(),
crect(), hrect(), ctoh(), htoc(), cprdc(), cprdcj(), hprdh(), hprdhj(),
autoreg(), movavg(), convolve(), padto(), partacf(), polyroot(),
reverse(), unwind() and yulewalker().
```

Gary Oehlert 2003-01-15