It depends on where you apply the window function. If you do it in the time domain, it's because you only want to analyze the periodic behavior of the function in a short duration. You do this when you don't believe that your data is from a stationary process.
If you do it in the frequency domain, then you do it to isolate a specific set of frequencies for further analysis; you do this when you believe that (for instance) high-frequency components are spurious.
The first three chapters of "A Wavelet Tour of Signal Processing" by Stephane Mallat have an excellent introduction to signal processing in general, and chapter 4 goes into a very good discussion of windowing and time-frequency representations in both continuous and discrete time, along with a few worked-out examples.
You should be aware that estimating power spectra using a periodogram is not recommended, and in fact has been bad practice since ~ 1896. It is an inconsistent estimator for anything less than millions of data samples (and even then ...), and generally biased. The exact same thing applies to using standard estimates of autocorrelations (i.e. Bartlett), as they are Fourier transform pairs. Provided you are using a consistent estimator, there are some options available to you.
The best of these is a multiple window (or taper) estimate of the power spectra. In this case, by using the coefficients of each window at a frequency of interest, you can compute a Harmonic F Statistic against a null hypothesis of white noise. This is an excellent tool for detection of line components in noise, and is highly recommended. It is the default choice in the signal-processing community for detection of periodicities in noise under assumption of stationarity.
You can access both the multitaper method of spectrum estimation and the associated F-test via the multitaper
package in R (available via CRAN). The documentation that comes with the package should be enough to get you going; the F-test is a simple option in the function call for spec.mtm
.
The original reference that defines both of these techniques and gives the algorithms for them is Spectrum Estimation and Harmonic Analysis, D.J. Thomson, Proceedings of the IEEE, vol. 70, pg. 1055-1096, 1982.
Here is an example using the included data set with the multitaper
package.
require(multitaper);
data(willamette);
resSpec <- spec.mtm(willamette, k=10, nw=5.0, nFFT = "default",
centreWithSlepians = TRUE, Ftest = TRUE,
jackknife = FALSE, maxAdaptiveIterations = 100,
plot = TRUE, na.action = na.fail)
The parameters you should be aware of are k and nw: these are the number of windows (set to 10 above) and the time-bandwidth product (5.0 above). You can easily leave these at these quasi-default values for most applications. The centreWithSlepians command removes a robust estimate of the mean of the time series using a projection onto Slepian windows -- this is also recommended, as leaving the mean in produces a lot of power at the low frequencies.
I would also recommend plotting the spectrum output from 'spec.mtm' on a log scale, as it cleans things up significantly. If you need more information, just post and I'm happy to provide it.
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 ;-).