Module 6 — Spectral Analysis, Cycles, and Filters
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
the angular frequency is radians per observation, frequency is cycles per observation, and period is observations.
| Pattern | Frequency | Angular frequency | Period |
|---|---|---|---|
| annual cycle in monthly data | 12 months | ||
| weekly cycle in daily data | 7 days | ||
| alternating observations | 2 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,
and
The time domain asks how observations lags apart co-move. The frequency domain asks how variance is distributed across slow and fast oscillations. The total area is variance:
Finite Fourier matrix
For , define
Then
contains discrete Fourier coefficients. The matrix is unitary,
so it rotates the centred data into orthogonal frequency coordinates without changing total squared length. At Fourier frequency ,
3. Familiar models have readable spectra
| Process | Spectral shape |
|---|---|
| white noise | flat: no frequency dominates |
| AR(1), | high power near zero: persistent slow movement |
| AR(1), | high power near : alternating movement |
| seasonal process | peak near seasonal frequency and possibly harmonics |
For AR(1),
As 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 , the periodogram is
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 grows, its variance does not vanish. Smoothing trades resolution for stability.
| Choice | Gain | Cost |
|---|---|---|
| narrow smoothing window | resolves close peaks | noisy estimate |
| wide smoothing window | stable broad shape | merges nearby cycles |
| taper endpoints | reduces leakage from boundary mismatch | widens 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.
Build a Fourier matrix and recover two periods
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
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,
lies between 0 and 1 and measures linear association at frequency . 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 -variate process, collect all auto- and cross-spectra in
At every frequency, is Hermitian and positive semidefinite. This is the frequency-domain analogue of a covariance matrix: for any complex vector , the scalar spectrum of is .
8. Filters can leak the future
A centred moving average
uses . It is legitimate for retrospective description but unavailable for a real-time forecast made at . Every filter should be labelled:
| Filter use | Allowed data |
|---|---|
| retrospective decomposition | past and future observations, if stated |
| real-time monitoring | current and past only |
| forecasting backtest | exactly 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
- State sampling interval, units, and missing-data treatment.
- Remove or model mean, trend, seasonality, and breaks deliberately.
- Name candidate periods before interpreting peaks when domain knowledge exists.
- Report taper and smoothing choices.
- Check peak stability across windows and subsamples.
- Compare the frequency-domain story with ACF and a time-domain model.
- For cross-spectra, state alignment, common seasonal drivers, and phase uncertainty.
- For forecasts, ensure all filters are one-sided at each origin.
Practice
- Convert a frequency of 0.2 cycles/day to period and angular frequency.
- Where does an hourly signal at 0.75 cycles/hour alias when sampled hourly?
- Explain why a periodogram peak near zero may reflect a break rather than a genuine long cycle.
- Why does smoothing reduce variance but blur nearby frequencies?
Answers
- Period 5 days; angular frequency radians/day.
- cycles/hour.
- A sudden level shift contributes strong low-frequency variation; stationarity is violated.
- 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.
Module 5 — Systems, Seasonality, and Cointegration
Express vector autoregressions, seasonal operators, cointegration, and forecast constraints with block matrices and stable linear systems.
R Matrix Laboratory
Four browser-based base R laboratories for covariance matrices, AR recursions, linear prediction, likelihood, and state space.