Next: compza()
Up: Time Series Macros Help
Previous: complex_data
Contents
Keywords:
complex numbers, frequency domain, fourier transforms
Here is a brief summary of MacAnova functions and macros 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.
Fourier transforms
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.
Complex conjugation
hconj(hx) and cconj(cx) compute the complex conjugate of Hermitian
series or unrestricted complex series in hx or cx.
Real and imaginary parts
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).
Conversion to polar form
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.
Conversion from polar form
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'.
Converting to and from hermitian form
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.
Complex multiplication
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.
Complex division
hdivh(hx1, hx2) returns the Hermitian form of the elementwise complex
ratio of the Hermitian series in hx1 and hx2. hdivh(hx) returns
hdivh(hx,hx). When hx is a vector and no represented complex elements
are 0, cdivh(hx,hx) is the Hermitian form of rep(1,nrows(hx)).
hdivhj(hx1,hx2) and hdivhj(hx) are equivalent to hdivh(hx1,hconj(hx2))
and hdivh(hx,hconj(hx)), respectively.
cdivc(cx1, cx2) returns the unrestricted complex form of the elementwise
complex product of the complex series in cx1 and cx2. cdivc(cx) returns
cdivc(cx,cx). When cx has 1 or 2 columns, with no zero rows,
cdivc(cx,cx) is the fully complex form of rep(1,nrows(cx)).
cdivcj(cx1,cx2) and cdivcj(cx) are equivalent to cdivc(cx1,cconj(cx2))
and cdivc(cx,cconj(cx)), respectively.
Macros for complex matrices
In the following a and b are REAL vectors or matrices representing
complex matrices A and B in unrestricted complex form. All the macros
return their result in unrestricted complex form.
cmatmultc(a,b [,op:"%*%"), cmatmultc(a,b,op:"%c%") and cmatmultc(a,b,
op:"%C") return matrix products of A and B.
ctrace(a) returns the trace of A.
cdiag(a) returns the complex diagonal of square A.
ctranspose(a) returns the transpose of A.
cjtranspose(a) is equivalent to ctranspose(cconj(a)).
csubscr(A), csubscr(A,i), csubscr(A,i,j) simulate A[i], A{i,], and
A[i,j]. i and or j can be empty.
csolve(a) returns the inverse of non-singular square A.
ceigen(a) returns a structure containing the real eigenvalues and complex
eigenvectors of a Hermitian matrix A (ctranspose(a) = cconj(a)).
Additional functions useful in time series analysis
autoreg()
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()
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()
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'.
padto()
padto(x,n) returns matrix x padded with n additional rows of zeros. If
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()
phi_kk <- partacf(rho) computes the partial autocorrelations
corresponding to autocorrelations in the column or columns of REAL
vector or matrix rho.
rho <- partacf(phi_kk,reverse:T) computes the autocorrelations
corresponding to partial autocorrelations in the column or columns of
REAL or matrix vector phi_kk.
polyroot()
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.
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 and
is not affected by options 'masign' and 'arsign. See help topic
'MASIGN'.
reverse()
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()
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'.
yulewalker()
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
Cross reference
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(), cdivc(), cdivcj(),
hprdh(), hprdhj(), hdivh(), hdivhj(), autoreg(), movavg(), convolve(),
padto(), partacf(), polyroot(), reverse(), unwind() and yulewalker().
Gary Oehlert
2006-01-30