6
$\begingroup$

I'm interested in using the spectral density to determine the period of a time series $x_t$. According to Wikipedia, we can use the periodogram to estimate the spectral density. Going down the chain, Wikipedia says the periodogram is implemented using the FFT, but the details are not given. Is it literally the FFT on $x_t$?

Edit:

In R, there is a function spec.pgram that returns the raw periodogram. I tried to compare this to the FFT of the ACF, but I'm still not getting matching results (eventually I need to do this in Java, so I am trying to understand the implementation fully).

x = rep(c(5,1,5,10),4)
x.acf = acf(x)$acf[,,1]
Mod(fft(x.acf))^2

 [1]  0.3906250  0.4757183  0.9898323 15.5956432  2.5543312  0.3962321
 [7]  0.2068152  0.2068152  0.3962321  2.5543312 15.5956432  0.9898323
[13]  0.4757183

vs

x.pgram = spec.pgram(x, detrend=F)
x.pgram$freq

[1] 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000

x.pgram$spec

[1]  3.8819277  3.4948335  2.9155061 69.0892857  1.5487796  0.9694522  0.5823580
[8]  0.1607143
$\endgroup$
10
$\begingroup$

It is literally mostly implemented via the FFT, but it is usually derived with the aid of the DFT. The idea is that much of the statistical properties of the periodogram can be obtained in this way (e.g., you would like not only to know where the peak is but also the significance of that peak!). If it is or not directly the FFT depends on the algorithm; the "classical" periodogram is 'just" the FFT, but it is not only noisy, but also has other serious problems (see the paper from Scargle that I cite below).

The most used form of the periodogram is the Lomb-Scargle (LS) Periodogram (Scargle, 1989; in this paper in fact Scargle does a critique to the "classical" periodogram; it is a MUST READ if you are trying to detect the period of a time series!). You can look at a fast implementation of it in this paper of Press & Rybicki (1989) (if you get lost, you can also look at the explicit implementation in the Numerical Recipes).

I should also add that there are generalizations of the LS Periodogram that account for floating means of the sinusoid, or for unequal variances among the points. The implementation is straightforward once you read the papers that I just gave ;-).

$\endgroup$
  • $\begingroup$ Thanks for the papers. Seems like the modified periodogram (equation 10) boils down to the same FFT applied to the ACF if the data is evenly sampled. I tried this in R, but couldn't replicate the output of spec.pgram using the FFT on the ACF. Do you know why? $\endgroup$ – JCWong Aug 29 '12 at 5:16
  • $\begingroup$ It is maybe due to the smoothing. Did you read the documentation of spec.pgram? stat.ethz.ch/R-manual/R-patched/library/stats/html/… $\endgroup$ – Néstor Aug 29 '12 at 10:28
3
$\begingroup$

The spectral density is defined for stationary time series. It is the Fourier transform of the autocorrelation function. The periodogram is the Fourier transform of the sample autocorrelation function. The periodogram is discrete while the spectral density is continuous and is usually estimated by a kernel smoothing of the periodogram. The Fast Fourier Transform is a quick way to compute a Fourier transform due to the work of Tukey and Cooley.

$\endgroup$
  • $\begingroup$ Good comment, I at first missed the fact that the time series must be stationary. $\endgroup$ – JCWong Aug 29 '12 at 1:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.