Time Series Analysis

Chapter 12 · Spectral Analysis

The slide of the lecture is on the left, the same figure or table on the right, computed in the browser from the same data. The ▶ button moves the parameter step by step; the “Worked example” boxes redo the calculation with the numbers of the chapter.

Cycles and frequencies · The spectral density · The periodogram · Estimating the spectrum · Cycles in economic and energy data · Long memory: the pole at zero · Linear filters · Two series: coherence and phase · A pointer: wavelets

Cycles and frequencies

A cycle: amplitude, frequency, phase

Slide 6: A cycle: amplitude, frequency, phase
Slide 6

Worked example

\[\nu=\frac{1}{P},\qquad \omega=2\pi\nu,\qquad A\cos(2\pi\nu t+\varphi)=a\cos(2\pi\nu t)+b\sin(2\pi\nu t),\quad a=A\cos\varphi,\ b=-A\sin\varphi\]
      Question for the room Set φ = 1.5 radians, with A = 2. What are a and b?
      Answer

      a = 2 cos 1.5 = 0.14 and b = −2 sin 1.5 = −1.99: with a phase close to π/2 the cycle is almost a pure sine with a negative sign. Whatever the phase, a² + b² = 4 = A².

      Two cycles plus noise

      Slide 7: Two cycles plus noise
      Slide 7
        Question for the room Set the amplitude of the period-4 cycle to 2, as large as the annual cycle. How high is the spike at ν = 1/4 now?
        Answer

        119.2, four times higher than with amplitude 1 (29.6) and close to the theory A²T/4 = 4·120/4 = 120: the spike grows with the square of the amplitude. The spike at 1/12 stays at 139.7, above its theoretical 120, because the noise also contributes at that frequency; without noise the two spikes are exactly 120 and 30.

        Worked example: the DFT of four numbers

        Slide 11: Worked example: the DFT of four numbers
        Slide 11

        Worked example

        \[d(\nu_j)=T^{-1/2}\sum_{t=1}^{T}y_t\,e^{-2\pi i\nu_j t},\qquad y_t=x_t-\bar x,\qquad \sum_{t=1}^{T}y_t^2=\sum_{j=1}^{T-1}|d(\nu_j)|^2\]
            Question for the room ▶ moves x₃. With x = (4, 2, 4, 2), where does the variance sit?
            Answer

            All at ν = 1/2: the deviations (1, −1, 1, −1) alternate, so |d(1/2)|² = (−4)²/4 = 4 and |d(1/4)|² = |d(3/4)|² = 0; Parseval: 4 = 1 + 1 + 1 + 1. The series has period 2.

            Aliasing

            Slide 12: Aliasing
            Slide 12
              Question for the room ▶ changes the sampling interval. At Δ = 4 months (one observation per cycle), what do the observations show?
              Answer

              A constant: the cycle has 4/4 = 1 cycle per observation, which folds to |1 − 1| = 0, so every observation falls at the same point of the cycle and the 4-month cycle disappears from the data (an alias of infinite period). At Δ = 5 months the same cycle appears as a 20-month cycle.

              Interpreting aliasing

              Slide 13: Interpreting aliasing
              Slide 13

              Worked example

              \[\nu_{\text{obs}}=\Delta\,\nu,\qquad \nu_{\text{alias}}=\bigl|\nu_{\text{obs}}-\operatorname{round}(\nu_{\text{obs}})\bigr|\le\tfrac12,\qquad \text{period}=\frac{\Delta}{\nu_{\text{alias}}}\ \text{months}\]
                  Question for the room Set the period of the true cycle to 2.5 months, with quarterly observations (Δ = 3). What period does the cycle appear to have?
                  Answer

                  15 months: 3/2.5 = 1.2 cycles per quarter, which folds to |1.2 − 1| = 0.2, i.e. 5 quarters. A cycle faster than the observations appears as a slower, false cycle.

                  The spectral density

                  Worked example: AR(1) and MA(1) spectra

                  Slide 18: Worked example: AR(1) and MA(1) spectra
                  Slide 18

                  Worked example

                  \[f_{AR}(\nu)=\frac{\sigma^2}{1-2\phi\cos 2\pi\nu+\phi^2},\qquad f_{MA}(\nu)=\sigma^2(1+2\theta\cos 2\pi\nu+\theta^2),\qquad \int_{-1/2}^{1/2}f=\gamma(0)\]
                      Question for the room Set φ = −0.6. What are f(0) and f(1/2)?
                      Answer

                      f(0) = 1/1.6² = 0.39 and f(1/2) = 1/0.4² = 6.25: the mirror image of φ = 0.6. A negative φ makes the series alternate, so the power moves to the highest frequencies; the variance stays 1.5625.

                      Worked example: the peak of an AR(2) spectrum

                      Slide 20: Worked example: the peak of an AR(2) spectrum
                      Slide 20

                      Worked example

                      \[\cos(2\pi\nu^*)=\frac{\phi_1(\phi_2-1)}{4\phi_2},\qquad f(\nu)=\frac{\sigma^2}{|1-\phi_1e^{-2\pi i\nu}-\phi_2e^{-4\pi i\nu}|^2},\qquad f(0)=\frac{\sigma^2}{(1-\phi_1-\phi_2)^2}\]
                          Question for the room ▶ moves φ₂ towards −0.95, with φ₁ = 1.5. Does the peak move to a longer or a shorter period?
                          Answer

                          To a shorter one: 9.1 observations at φ₂ = −0.95 (12.4 at −0.75 and 20.2 at −0.65), and the peak becomes much higher (981 against 64). A more negative φ₂ brings the complex roots closer to the unit circle (their modulus is √−φ₂) and speeds up the oscillation of the ACF.

                          A gallery of spectral densities

                          Slide 21: A gallery of spectral densities
                          Slide 21
                            Question for the room Move the upper limit to ν = 0.1. What share of the variance of the AR(1) with φ = 0.6 lies at frequencies below 0.1 (periods longer than 10 observations)?
                            Answer

                            58%, against 20% for white noise, which spreads its variance evenly: the band [0, 0.1] is a fifth of [0, 0.5]. For the AR(2) the share is 81%, for the AR(1) with φ = −0.6 only 5%.

                            The periodogram

                            Sunspots and their periodogram

                            Slide 26: Sunspots and their periodogram
                            Slide 26
                              Question for the room ▶ shortens the sample. With 1700–1808 (109 years), at what period is the highest ordinate?
                              Answer

                              At 10.9 years (j = 10), close to the 11.0 years of the full sample: the cycle shows in a century of data, but the Fourier grid is coarser (periods 109/j: 12.1, 10.9, 9.9 years). Fisher’s test gives g = 0.222 and a p-value of 0.00009.

                              Interpreting the sunspot periodogram

                              Slide 27: Interpreting the sunspot periodogram
                              Slide 27
                                Question for the room Widen the band to 9–20 years. What share of the variance does it hold?
                                Answer

                                63%, against 60% for 9–13 years: the periods between 13 and 20 years add only 3 percentage points. Almost all the power of the solar cycle lies between 9 and 13 years; with the band 5–20 years the share reaches 73%, because the harmonic of about 5.5 years comes in as well.

                                Statistical properties of the periodogram

                                Slide 28: Statistical properties of the periodogram
                                Slide 28
                                  Question for the room Set c = 1 (the true value f itself). What share of the white-noise ordinates exceeds f?
                                  Answer

                                  37.6% for T = 2048, close to e−1 = 36.8%, not 50%: the exponential distribution has mean 1 but median ln 2 = 0.69, so most ordinates lie below f and a few large values pull the mean up. For c = 3 the share is 5.1% (theory 5.0%).

                                  The periodogram of white noise

                                  Slide 29: The periodogram of white noise
                                  Slide 29
                                    Question for the room ▶ raises the Daniell m. At m = 10 (L = 21), what is the standard deviation of the smoothed ordinates for T = 2048?
                                    Answer

                                    0.21, close to 1/√21 = 0.22: averaging L nearly independent ordinates divides the standard deviation by √L; for T = 128 it is 0.20. A longer sample alone did not achieve this: the raw periodograms have standard deviations 1.03 and 1.00.

                                    Estimating the spectrum

                                    Leakage: raw and tapered periodograms

                                    Slide 35: Leakage: raw and tapered periodograms
                                    Slide 35
                                      Question for the room Move the strong cycle to j = 26 (ν = 26/256, a Fourier frequency). How many times above the background does the weak cycle stand in the raw periodogram?
                                      Answer

                                      755 times, against 7.7 at j = 25.5: a cycle that fits a whole number of times in the sample does not leak, and the background falls to the level of the tiny noise. With the Hann taper the ratio is 4,176, almost the same for any j.

                                      Smoothing the periodogram (1/2): the Daniell estimator

                                      Slide 37: Smoothing the periodogram (1/2): the Daniell estimator
                                      Slide 37

                                      Worked example

                                      \[\hat f(\nu_j)=\frac1L\sum_{k=-m}^{m}I(\nu_{j+k}),\qquad L=2m+1,\qquad B=\frac{L}{T},\qquad \operatorname{Var}\hat f\approx\frac{f^2}{L}\]
                                          Question for the room Set m = 0. At what period is the peak?
                                          Answer

                                          At 11.0 years (j = 28), the highest raw ordinate; with m = 2 the smoothed peak moves to 10.3 years (j = 30), because the mean of the five ordinates around j = 30 is the largest. With m = 4 the peak returns to 11.0 years: the position of the smoothed peak varies by one or two Fourier frequencies.

                                          Smoothed estimates of an AR(2) spectrum

                                          Slide 39: Smoothed estimates of an AR(2) spectrum
                                          Slide 39
                                            Question for the room ▶ widens the second Daniell window. At m = 20 (L = 41), where is its peak and how high is it?
                                            Answer

                                            At ν = 0.0625 (period 16.0), height 36.1, against the true peak at ν = 0.080 with height 64: the window is 41/512 = 0.08 wide, as wide as the peak frequency, so it flattens and shifts the peak. The mean squared error of log f̂ rises again, to 0.11 (0.09 at m = 10 and at m = 15).

                                            Interpreting the smoothed estimates

                                            Slide 40: Interpreting the smoothed estimates
                                            Slide 40
                                              Question for the room ▶ steps through m = 0, 2, …, 30. At which m is the mean squared error of log f̂ smallest?
                                              Answer

                                              At m = 12 (0.089), very close to m = 10 (0.092); at m = 30 the error climbs to 0.22. Up to m = 12 the variance falls, then the bias dominates: the height of the peak drops from 64 to 44.7 at m = 12 and to 31.5 at m = 30.

                                              Worked example: a 95% band with L = 5

                                              Slide 42: Worked example: a 95% band with L = 5
                                              Slide 42

                                              Worked example

                                              \[\frac{2L\,\hat f(\nu)}{f(\nu)}\approx\chi^2_{2L},\qquad \left[\frac{df\,\hat f}{\chi^2_{df}(1-\alpha/2)},\ \frac{df\,\hat f}{\chi^2_{df}(\alpha/2)}\right],\quad df=2L\]
                                                  Question for the room Set L = 21. What is the upper multiplier of the 95% band?
                                                  Answer

                                                  1.62 (and the lower one 0.68), against 3.08 and 0.49 for L = 5: the band narrows roughly like 1/√L. It stays asymmetric, wider upwards, because the chi-square distribution has its tail to the right.

                                                  Sunspots: smoothed spectrum with a confidence band

                                                  Slide 43: Sunspots: smoothed spectrum with a confidence band
                                                  Slide 43
                                                    Question for the room Set m = 0 (the raw periodogram, df = 2). How many times f̂ is the upper bound of the 95% band at the peak?
                                                    Answer

                                                    39.5 times (2/χ²₂(0.025) = 2/0.0506), and the lower bound is 0.27 × f̂: a single ordinate says very little about the height of the spectrum. With m = 2 the multipliers are 0.49 and 3.08, with m = 8 they are 0.65 and 1.72.

                                                    Cycles in economic and energy data

                                                    GDP growth and HP cycles

                                                    Slide 47: GDP growth and HP cycles
                                                    Slide 47
                                                      Question for the room Set λ = 100. Does the standard deviation of the US HP cycle rise or fall from 1.58?
                                                      Answer

                                                      It falls, to 1.03: a smaller λ lets the trend follow the data more closely, so the cycle keeps only the faster fluctuations; with λ = 25,600 it rises to 2.23. The growth rates do not depend on λ (standard deviation 0.93).

                                                      Spectra of GDP growth and HP cycles

                                                      Slide 49: Spectra of GDP growth and HP cycles
                                                      Slide 49
                                                        Question for the room Set m = 0 (the raw periodograms). At what period is the highest ordinate of the US HP cycle?
                                                        Answer

                                                        At 26.5 quarters (6.6 years), against 24.3 with m = 2: a raw ordinate is noisy, and the smoothed peak can move by one Fourier frequency (T = 292: 292/11 = 26.5, 292/12 = 24.3). The peak of US growth stays at 8.8 quarters.

                                                        Interpreting the GDP spectra

                                                        Slide 50: Interpreting the GDP spectra
                                                        Slide 50
                                                          Question for the room Set the longest period of the band to 48 quarters. What share of the variance of the US HP cycle falls in the band?
                                                          Answer

                                                          90%, against 80% for 6–32 quarters: the US HP cycle still has much power between 8 and 12 years. For Romanian growth the share hardly changes (15.6% in both cases), because its variance sits at high frequencies.

                                                          Spectrum of the Romanian hourly electricity load

                                                          Slide 51: Spectrum of the Romanian hourly electricity load
                                                          Slide 51
                                                            Question for the room Choose 2026 (January–June, 4,344 hours). At what period is the highest Welch ordinate with 8-week segments?
                                                            Answer

                                                            At 12 hours, ahead of 24 hours (as in 2025); over 2022–2026 the 24-hour ordinate is the highest. The daily profile with two peaks, in the morning and in the evening, puts much power into the 12-hour harmonic, and the order of the two can change from one year to the next.

                                                            Interpreting the load spectrum

                                                            Slide 52: Interpreting the load spectrum
                                                            Slide 52
                                                              Question for the room Set the half-width to 1. How much does the share of the daily cycle and its harmonics fall?
                                                              Answer

                                                              Very little: from 33.7% to 33.4%. The daily cycle is almost perfectly periodic, so its power sits in a few very narrow ordinates at 24/k hours; the weekly cycle falls more, from 15.7% to 14.9%: its power is spread over more neighbouring ordinates.

                                                              Long memory: the pole at zero

                                                              The pole at zero in stock-market data

                                                              Slide 56: The pole at zero in stock-market data
                                                              Slide 56
                                                                Question for the room Set the exponent to 0.45 (m = 52 frequencies, periods above 129 days). What is d̂ for the absolute returns?
                                                                Answer

                                                                0.38, against 0.56 with m = 307, with standard error 0.089; with exponent 0.80 (m = 1,152) it is 0.41. The estimate depends on the bandwidth: few frequencies give a large standard error, many frequencies bring in short-memory effects. For the returns d̂ stays between −0.04 and 0.14.

                                                                Linear filters

                                                                Linear filters and their gain (2/2)

                                                                Slide 59: Linear filters and their gain (2/2)
                                                                Slide 59

                                                                Worked example

                                                                \[G(\nu)=\frac{4\lambda(1-\cos 2\pi\nu)^2}{1+4\lambda(1-\cos 2\pi\nu)^2},\qquad |H_{\text{cycle}}|^2=G^2,\quad |H_{\text{trend}}|^2=(1-G)^2,\quad |1-e^{-2\pi i\nu}|^2=4\sin^2(\pi\nu)\]
                                                                    Question for the room Choose λ = 6400. At what period does the HP cycle filter keep half of the power?
                                                                    Answer

                                                                    At 45.0 quarters (11.3 years), against 31.8 quarters for λ = 1600: a 4 times larger λ moves the cut-off to slower cycles, by a factor of about 41/4 = 1.41. At 32 quarters G² rises from 0.49 to 0.82.

                                                                    Squared gains of common filters

                                                                    Slide 60: Squared gains of common filters
                                                                    Slide 60
                                                                      Question for the room ▶ moves the marked period. At 4 quarters, what is the squared gain of the seasonal difference 1 − L⁴?
                                                                      Answer

                                                                      0: 4 sin²(4π/4) = 4 sin²(π) = 0. The seasonal difference removes the yearly cycle of quarterly data (and its 2-quarter harmonic), while the first difference amplifies it by 2. At 8 quarters the seasonal difference has its largest gain, 4.

                                                                      Interpreting the filter gains

                                                                      Slide 61: Interpreting the filter gains
                                                                      Slide 61
                                                                        Question for the room Choose λ = 100. What is the squared gain of the HP cycle filter at 32 quarters?
                                                                        Answer

                                                                        0.017, against 0.49 for λ = 1600: with λ = 100 the trend follows almost every 8-year cycle and the HP cycle keeps only the short periods (half power at 15.8 quarters). At 8 quarters the squared gain is still 0.94.

                                                                        Two series: coherence and phase

                                                                        Industrial production and unemployment

                                                                        Slide 63: Industrial production and unemployment
                                                                        Slide 63
                                                                          Question for the room Choose segments of 48 months (K = 17). What happens to the 5% significance threshold?
                                                                          Answer

                                                                          It falls from 0.35 to 0.17 (1 − 0.051/16): more segments make the smoothed coherence more precise, so a smaller value is already significant. The mean coherence in the 18–96-month band rises to 0.90, and the phase at the 48-month cycle gives a lag of 2.1 months. With 144-month segments (K = 5) the threshold is 0.53.

                                                                          A pointer: wavelets

                                                                          Wavelet power of the sunspots

                                                                          Slide 67: Wavelet power of the sunspots
                                                                          Slide 67
                                                                            Question for the room Choose ω₀ = 10 (more oscillations inside the wavelet). How does the mean 8–14-year power in 1795–1830 change?
                                                                            Answer

                                                                            It rises from 2.0 to 2.5, while the mean over the whole sample goes from 5.7 to 5.9: a longer wavelet averages over more years, so the weak minimum around 1800 is blurred with its neighbours. The year of the maximum stays around 1956.

                                                                            Simulations of the chapter (seed 2026): the Normal draws of the two-cycles example (T = 120), of the white-noise periodograms (T = 128 and T = 2048), of the leakage example (T = 256) and the simulated AR(2) of the smoothing example (T = 512). The yearly sunspots 1700–2008 (statsmodels), the hourly electricity load of Romania 1 January 2022 – 30 June 2026 (the ENTSO-E extract of Chapter 4, put on a regular hourly grid by the chapter’s loader) and the daily S&P 500 returns 2000–2026 (EODHD) are not revised and reproduce the numbers of the lecture exactly. US real GDP (FRED GDPC1) and US industrial production and unemployment (FRED INDPRO, UNRATE), read on 4 November 2026 and cut at 2019 as in the lecture, reproduce the numbers of the lecture exactly. Romanian real GDP (Eurostat namq_10_gdp) has been revised since the slides were made: the page uses the vintage of the slides, read from the vector chart charts/tsa_ch12_gdp_series.pdf, in which every one of the 99 quarterly growth rates (1995 Q2 – 2019 Q4) is a vertex of the line; they reproduce the numbers of the lecture to the sixth significant digit; the values with the Eurostat data of 4 November 2026 are given next to them. Variants that do not appear in the lecture (other amplitudes, samples, bandwidths, values of λ, segments, ω₀) are extra runs of the chapter’s code on the same data; the charts of “Interpreting aliasing”, “Interpreting the sunspot periodogram”, “Statistical properties of the periodogram”, “Interpreting the smoothed estimates”, “Interpreting the GDP spectra”, “Interpreting the load spectrum” and “Interpreting the filter gains” are extra charts for slides that give only numbers.