Module 6 — Spectral Analysis, Cycles, and Filters

Translate autocovariance into frequency, estimate spectra, diagnose cycles, and avoid aliasing and filtering leakage.

Module 6 — Spectral Analysis, Cycles, and Filters

Core question

Which frequencies account for variation in a stationary series, and can we separate persistent, seasonal, and high-frequency movements without inventing cycles?

Learning outcomes

You will be able to:

  • convert among period, frequency, and angular frequency;
  • explain the Fourier relation between autocovariance and spectral density;
  • construct a finite Fourier matrix and interpret the periodogram as squared transformed coordinates;
  • calculate and interpret a periodogram;
  • explain smoothing, leakage, tapering, and aliasing;
  • interpret cross-spectrum, coherence, and phase without causal overreach;
  • distinguish a descriptive two-sided filter from a real-time forecasting filter.

1. Period and frequency are reciprocals

For a component

xt=Acos(ωt+φ),x_t=A\cos(\omega t+\varphi),

the angular frequency is ω\omega radians per observation, frequency is f=ω/(2π)f=\omega/(2\pi) cycles per observation, and period is P=1/f=2π/ωP=1/f=2\pi/\omega observations.

PatternFrequency ffAngular frequency ω\omegaPeriod
annual cycle in monthly data1/121/12π/6\pi/612 months
weekly cycle in daily data1/71/72π/72\pi/77 days
alternating observations1/21/2π\pi2 observations

Always state the sampling interval. “Frequency 0.1” means ten observations per cycle, not automatically ten days or years.

2. Spectrum and autocovariance contain the same second-order information

For a weakly stationary process with suitable regularity,

f(ω)=12πh=γ(h)eiωh,f(\omega)=\frac{1}{2\pi}\sum_{h=-\infty}^{\infty} \gamma(h)e^{-i\omega h},

and

γ(h)=ππeiωhf(ω)dω.\gamma(h)=\int_{-\pi}^{\pi}e^{i\omega h}f(\omega)\,d\omega.

The time domain asks how observations hh lags apart co-move. The frequency domain asks how variance is distributed across slow and fast oscillations. The total area is variance:

ππf(ω)dω=γ(0).\int_{-\pi}^{\pi}f(\omega)\,d\omega=\gamma(0).

Finite Fourier matrix

For x=(x0,,xn1)\mathbf x=(x_0,\ldots,x_{n-1})^\top, define

(Fn)jt=n1/2exp(2πijt/n),j,t=0,,n1.(F_n)_{jt} =n^{-1/2}\exp\left(-2\pi ijt/n\right), \qquad j,t=0,\ldots,n-1.

Then

d=Fn(xxˉ1)\mathbf d=F_n(\mathbf x-\bar x\mathbf1)

contains discrete Fourier coefficients. The matrix is unitary,

FnFn=In,F_nF_n^*=I_n,

so it rotates the centred data into orthogonal frequency coordinates without changing total squared length. At Fourier frequency ωj=2πj/n\omega_j=2\pi j/n,

I(ωj)=dj22π.I(\omega_j)=\frac{|d_j|^2}{2\pi}.

3. Familiar models have readable spectra

ProcessSpectral shape
white noiseflat: no frequency dominates
AR(1), ϕ>0\phi>0high power near zero: persistent slow movement
AR(1), ϕ<0\phi<0high power near π\pi: alternating movement
seasonal processpeak near seasonal frequency and possibly harmonics

For AR(1),

f(ω)=σε22π112ϕcosω+ϕ2.f(\omega)=\frac{\sigma_\varepsilon^2}{2\pi} \frac{1}{1-2\phi\cos\omega+\phi^2}.

As ϕ\phi approaches one, power concentrates near zero. That resemblance to trend is why low-frequency peaks should not be interpreted before stationarity and breaks are considered.

4. The periodogram is informative and noisy

At Fourier frequencies ωj=2πj/n\omega_j=2\pi j/n, the periodogram is

I(ωj)=12πnt=1n(xtxˉ)eiωjt2.I(\omega_j)=\frac{1}{2\pi n} \left|\sum_{t=1}^{n}(x_t-\bar x)e^{-i\omega_jt}\right|^2.

A high ordinate indicates that a sinusoid at that frequency explains substantial sample variation. But the raw periodogram is not a consistent pointwise estimator: as nn grows, its variance does not vanish. Smoothing trades resolution for stability.

ChoiceGainCost
narrow smoothing windowresolves close peaksnoisy estimate
wide smoothing windowstable broad shapemerges nearby cycles
taper endpointsreduces leakage from boundary mismatchwidens peaks and loses some information

5. Recover two known cycles

The cell generates periods 12 and 4. Change n from 120 to 118: incomplete cycles spread power across neighbouring frequencies, demonstrating spectral leakage.

R

Build a Fourier matrix and recover two periods

Idle

The periodogram detects repetitive structure; it does not tell whether the cycle is stable, caused by a calendar mechanism, or useful for future prediction.

6. Aliasing: sampling can create the wrong frequency

With one observation per hour, the Nyquist frequency is 0.5 cycles/hour. A true signal at 0.6 cycles/hour is indistinguishable from an alias at

0.61=0.4 cycles/hour.|0.6-1|=0.4\ \text{cycles/hour}.

No post-processing can recover frequencies that the sampling design made indistinguishable. Sample faster, use an anti-alias filter before sampling, or restrict claims to the observable band.

7. Cross-spectra describe frequency-specific association

For two stationary series, the cross-spectrum is the Fourier transform of cross-covariances. Squared coherence,

Kxy2(ω)=fxy(ω)2fx(ω)fy(ω),K^2_{xy}(\omega)= \frac{|f_{xy}(\omega)|^2}{f_x(\omega)f_y(\omega)},

lies between 0 and 1 and measures linear association at frequency ω\omega. Phase describes a frequency-specific lead or lag.

High coherence at the annual frequency may simply reflect a shared calendar. It is not proof that one series causes the other; common forcing and filtering can create the same pattern.

For a kk-variate process, collect all auto- and cross-spectra in

f(ω)=[f11(ω)f1k(ω)fk1(ω)fkk(ω)].f(\omega)= \begin{bmatrix} f_{11}(\omega)&\cdots&f_{1k}(\omega)\\ \vdots&\ddots&\vdots\\ f_{k1}(\omega)&\cdots&f_{kk}(\omega) \end{bmatrix}.

At every frequency, f(ω)f(\omega) is Hermitian and positive semidefinite. This is the frequency-domain analogue of a covariance matrix: for any complex vector a\mathbf a, the scalar spectrum of aXt\mathbf a^*\mathbf X_t is af(ω)a0\mathbf a^*f(\omega)\mathbf a\ge0.

8. Filters can leak the future

A centred moving average

mt=xt1+xt+xt+13m_t=\frac{x_{t-1}+x_t+x_{t+1}}{3}

uses xt+1x_{t+1}. It is legitimate for retrospective description but unavailable for a real-time forecast made at tt. Every filter should be labelled:

Filter useAllowed data
retrospective decompositionpast and future observations, if stated
real-time monitoringcurrent and past only
forecasting backtestexactly what was available at each historical origin

Frequency response describes what a filter attenuates or passes; it does not excuse information leakage.

9. Spectral audit

  1. State sampling interval, units, and missing-data treatment.
  2. Remove or model mean, trend, seasonality, and breaks deliberately.
  3. Name candidate periods before interpreting peaks when domain knowledge exists.
  4. Report taper and smoothing choices.
  5. Check peak stability across windows and subsamples.
  6. Compare the frequency-domain story with ACF and a time-domain model.
  7. For cross-spectra, state alignment, common seasonal drivers, and phase uncertainty.
  8. For forecasts, ensure all filters are one-sided at each origin.

Practice

  1. Convert a frequency of 0.2 cycles/day to period and angular frequency.
  2. Where does an hourly signal at 0.75 cycles/hour alias when sampled hourly?
  3. Explain why a periodogram peak near zero may reflect a break rather than a genuine long cycle.
  4. Why does smoothing reduce variance but blur nearby frequencies?
Answers
  1. Period 5 days; angular frequency 0.4π0.4\pi radians/day.
  2. 0.751=0.25|0.75-1|=0.25 cycles/hour.
  3. A sudden level shift contributes strong low-frequency variation; stationarity is violated.
  4. Averaging neighbouring ordinates stabilises random variation but combines signals that are close in frequency.

Takeaway

Spectral analysis is a unitary change of coordinates for second-order structure. Sampling, stationarity, smoothing, and phase assumptions determine whether that change of coordinates is meaningful. Consolidate the matrix computations in the R laboratory; the Python laboratory is an optional implementation contrast.

Copyright © 2026