Solved – Estimating the spectral density

signal processingtime series

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

Best Answer

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 ;-).