Problem: Detecting cyclical patterns in daily data using periodogram and FFT.

The issue is how to code in R the periodogram to detect monthly, quarterly, semi-annual, annual..etc cyclical patterns in the data. In other words I need to detect the existence of cyclical patterns for low frequencies (i.e., 1 year => 2*pi/365, 6 months => 4*pi/365, etc.).

Reproducible Example:

w2009 = getWeatherForYear("sfo", 2009)
w2010 = getWeatherForYear("sfo", 2010)
w2011 = getWeatherForYear("sfo", 2011)
w2012 = getWeatherForYear("sfo", 2012)
w2013 = getWeatherForYear("sfo", 2013)
w2014 = getWeatherForYear("sfo", 2014)
w = rbind(w2009, w2010); w=rbind(w, w2011); w=rbind(w, w2012) 
w = rbind(w, w2013); w=rbind(w, w2014)

# Next we analyze the periodograms
# This is IMAGE 1
# Next: I dont really know to use this information

How do you interpret these images?

TSA Periodogram

Spectrum Periodogram

  • $\begingroup$ The part of your question concerning 'how do you interpret these images' is on-topic here, but the part asking 'how do you code...' is off-topic. Be aware that you may not get answers to that part. $\endgroup$ Mar 3, 2015 at 1:08
  • $\begingroup$ Of course, but I will be glad to at least have a partial answer than no answer ! Thank you $\endgroup$
    – Oniropolo
    Mar 3, 2015 at 2:15

1 Answer 1


The periodogram (a scaled squared FFT) shows strong concentrations of variance in frequencies close to zero --exactly which cannot be ascertained from your plots.

The periodogram is an inconsistent estimator of the spectrum of a stationary time series, hence the very erratic behaviour you see in your second plot. In order to gain a further insight in your series, you should either smooth the periodogram (look at argument spans= and taper= of spec.pgram()) or resort to a parametric estimate of the spectrum (look at spectrum(...,method="ar") and choose the autoregressive order using AIC for instance).


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.