Next: autocor() Up: Time Series Macros Help Previous: Time Series Macros Help   Contents

arspectrum()

Usage:
arspectrum(Y,P [,nfreq:nfreq] [,nospec:T]), Y a REAL vector, integer P >
  0, integer nfreq > 0.



Keywords: spectrum analysis, frequency domain, arima models
arspectrum(Y,P) estimates the spectrum of Y considered as a discrete
parameter AR(P) (order P autoregressive) time series.  Y must be a REAL
vector with no MISSING elements and P > 0 an integer.

The value returned is a structure(phi:Phi,var:Var, spectrum:Sy)
   Phi    REAL vector of length P containing estimated AR coefficients
   V      REAL scalar containing the estimated variance of the residuals
          (innovations)
   Sy     REAL vector of length Nfreq (see below) containing the
          estimated spectrum computed at frequencies 0, 1/Nfreq,
          2/Nfreq, ..., (Nfreq-1)/Nfreq cycles per Delta_t, the
          interval between observations.

The default value for Nfreq is determined as follows:
  1.  If variable S is defined and is an integer > 2, Nfreq = S.  It is
  an error if S has a prime factor > 29.

  2.  Otherwise, Nfreq is the smallest integer >= 2*nrows(y) which has
  no prime factor > 29, that is Nfreq = goodfactors(2*nrows(y))

arspectrum(Y,P,nfreq:Nfreq) or arspectrum(Y,P,Nfreq), where Nfreq > 0 is
an integer, does the same, computing the spectrum at Nfreq frequencies.
It is an error if Nfreq has a prime factor > 29.

arspectrum(Y,P,nospec:T) computes phi and var but not spectrum,
returning structure(phi,var).

Estimated AR coefficients Phi are computed from the first P sample
autocorrelations by solving the Yule-Walker equations.  See
yulewalker().  The variance V = gammahat(0)*prod(1 - pacf^2),
where gammahat(0) = sum((y - ybar)^2)/n and pacf is the vector of
P partial autocorrelations associated with Phi.

See also burg(), yulewalker().


Gary Oehlert 2003-01-15