fourier analysis of stationary and non-stationary time series · 2019-12-05 · time series basics...

27
Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra SLEX Fourier Analysis of Stationary and Non-Stationary Time Series Jo Evans, Tim Park September 6, 2012 Jo Evans, Tim Park Fourier Domain Analysis

Upload: others

Post on 27-Apr-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

Fourier Analysis of Stationary and Non-StationaryTime Series

Jo Evans, Tim Park

September 6, 2012

Jo Evans, Tim Park Fourier Domain Analysis

Page 2: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

A time series is a stochastic process indexed at discrete points intime i.e Xt for t = 0, 1, 2, 3, ... The mean is defined as

µt = E[Xt ]

and the autocovariance function is defined as

γ(t, s) = E[(Xt − µt)(Xs − µs)].

A weakly-stationary (or just stationary) process is one in whichµt ≡ µ where µ is constant in time and γ(t, s) only depends onh = |t − s| called lag.Stationary time series describe processes whose behavior does notchange over time. White noise series are stationary. Often seriescan be transformed into roughly stationary series.

Jo Evans, Tim Park Fourier Domain Analysis

Page 3: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

If autocovariance function is absolutely summable

Xt =

∫ 1/2

−1/2A(ω)e2πiωtdZ (ω).

Here dZ (ω) is an independent mean zero stochastic process withE[|dZ (ω)|2] = 1 and A(ω) is called the transfer function and

|A(ω)|2 = f (ω).

f (ω) or spectral density is the proportion of the varianceconcentrated at a component oscillating with frequency ω. This iscalled the Cramer model.

Jo Evans, Tim Park Fourier Domain Analysis

Page 4: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

Why estimate f (ω):

Some series (e.g. the sum of an AR(0.9) and AR(-0.9)) maybe difficult to show simply in the time domain but easy in theFourier domain. The example series will give two broad peaksat low and high frequencies.

Sometimes the underlying process is periodic in nature (e.gspeech) and f (ω) might reveal this.

Jo Evans, Tim Park Fourier Domain Analysis

Page 5: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

I have been trying to estimate f (ω). We do this using aperiodogram. If we have T realizations of a stationary time series.We can fit the model

Xt =T−1∑k=0

(ak cos (2πωkt) + bk sin (2πωkt)).

This model has no error terms as we are using T values toestimate T parameters. The ak , bk can be calculated using a fastfourier transform. We then define the periodogram by

I (ωk) = (a2k + b2k)/4πT .

Where ωk = kT and k = 0, 1, . . . ,T − 1. It can be shown that if

ωk → ω then as T →∞ then I (ωk) is an asymptotically unbiasedestimator of f (ω).

Jo Evans, Tim Park Fourier Domain Analysis

Page 6: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

Timew

hite

noi

se

0 200 400 600 800 1000

−3

−1

13

Time

nois

y si

ne s

erie

s

0 200 400 600 800 1000

−1.

50.

01.

0

Time

AR

(0.9

)

0 200 400 600 800 1000

−5

05

Time

AR

(−0.

9)

0 200 400 600 800 1000

−6

−2

26

Figure: 4 simulated series all of length 1000Jo Evans, Tim Park Fourier Domain Analysis

Page 7: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

0.0 0.1 0.2 0.3 0.4 0.5

0.00

00.

002

0.00

4

frequency

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5

0.00

0.02

frequency

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5

0.00

0.10

0.20

frequency

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.50.

000.

100.

200.

30

frequency

perio

dogr

am

Figure: Periodograms of Series 1-4

Jo Evans, Tim Park Fourier Domain Analysis

Page 8: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

However as a point estimator of f (ωk) the periodogram is notconsistent (i.e. the variance does not tend to zero as T isincreased).To deal with this we have to smooth the periodogram.

Box Kernel Smoother

P(ωk) =1

2m + 1

k+m∑j=k−m

I (ωj)

Jo Evans, Tim Park Fourier Domain Analysis

Page 9: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

I have data showing the activity of the FTSE100 for 7101 dailytime steps. This time series is clearly neither mean zero notstationary. The standard transform to improve this is to takelogarithmic returns.

Time

0 1000 2000 3000 4000 5000 6000 7000

1000

3000

5000

7000

−0.

100.

000.

100.

20

Figure: FTSE100 time series with logarithmic returns shown below

Jo Evans, Tim Park Fourier Domain Analysis

Page 10: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

Figure: Periodogram of FTSE100 ts with bandwidth=0.168.

0.0 0.1 0.2 0.3 0.4 0.5

5.5e

−08

6.5e

−08

7.5e

−08

frequency

perio

dogr

am

This periodograms appear to show that most of the variance isconcentrated at periodic components with high frequencies withlarger peaks at 0.27 and 0.48.

Jo Evans, Tim Park Fourier Domain Analysis

Page 11: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

Many time series that people want to study are non-stationary.EEGs will exhibit different behavior before, after and during aseizure. Earthquakes and Explosion detection may show verydifferent behavior.

Jo Evans, Tim Park Fourier Domain Analysis

Page 12: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

I generated a series using the R code:

Code

y1 = arima.sim(n=1024,model=list(ar=0.9))y2 = arima.sim(n=1024,model=list(ar=-0.9))y = c(y1,y2)

Time

y

0 500 1000 1500 2000

−5

05

Jo Evans, Tim Park Fourier Domain Analysis

Page 13: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

Here is the resulting stationary periodogram:

0.0 0.1 0.2 0.3 0.4 0.5

0.00

00.

005

0.01

00.

015

0.02

00.

025

0.03

0

frequency

perio

dogr

am

Jo Evans, Tim Park Fourier Domain Analysis

Page 14: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

In ... Priestley introduced the idea of a smoothly time varyingspectral density function. This changed the Cramer model to oneof the form

X (t) =

∫ 1/2

−1/2At(ω)e2πiωtdZ (ω)

where At(ω) is the time varying transfer function.

γ(s, t) =

∫ 1/2

−1/2A∗s (ω)At(ω)e2πiω(t−s)dµ(ω)

Jo Evans, Tim Park Fourier Domain Analysis

Page 15: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

I decided to assume that my spectrum was changing slowly withtime and that the series would be approximately stationary in smalltime blocks. With the FTSE series I analyzed the first 4096 timesteps by splitting it into 16 blocks and doing stationary fourieranalysis on each of these blocks.

Figure: A Slowly Changing Sloth

Jo Evans, Tim Park Fourier Domain Analysis

Page 16: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

0.0 0.2 0.4

frequency

0.0 0.2 0.4

frequency

perio

dogr

am

0.0 0.2 0.4

frequency

perio

dogr

am

0.0 0.2 0.4

frequency

perio

dogr

am

0.0 0.2 0.4

frequency

0.0 0.2 0.4

frequency

perio

dogr

am

0.0 0.2 0.4

frequency

perio

dogr

am

0.0 0.2 0.4

frequency

perio

dogr

am

0.0 0.2 0.4

frequency

0.0 0.2 0.4

frequency

perio

dogr

am

0.0 0.2 0.4

frequency

perio

dogr

am

0.0 0.2 0.4

frequency

perio

dogr

am

0.0 0.2 0.4 0.0 0.2 0.4

perio

dogr

am

0.0 0.2 0.4

perio

dogr

am

0.0 0.2 0.4

perio

dogr

am

Figure: Periodograms for each of the smaller time series

Jo Evans, Tim Park Fourier Domain Analysis

Page 17: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

Here are 8 peridograms produced by splitting the half and half ARnon-stationary series:

0.0 0.1 0.2 0.3 0.4 0.5

frequency

0.0 0.1 0.2 0.3 0.4 0.5

frequency

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5

frequency

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5

frequency

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5 0.0 0.1 0.2 0.3 0.4 0.5

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5

perio

dogr

am

Jo Evans, Tim Park Fourier Domain Analysis

Page 18: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

Issues with the Priestley-Dahlhause method.

I know no way of selecting or justifying the blocks in which toregard the series as stationary.

Choosing blocks which are all the same size can missinformation when ft(ω) is changing quickly or use a lot ofcomputational power and produce greater error bands whenft(ω) is changing slowly.

Jo Evans, Tim Park Fourier Domain Analysis

Page 19: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

The last model I looked at was SLEX. This model also incorporatesthe idea of a time variable spectrum which is constant in timeblocks. SLEX fits the time series in each block to a set of SLEX(Smooth Localized EXponential) vectors which allows the blocksto overlap without producing a bias.

Figure: A SLEX vector

Jo Evans, Tim Park Fourier Domain Analysis

Page 20: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

The SLEX algorithm uses a Fourier transform so can becomputed using a fast fourier transform making it as efficientas earlier methods.

The SLEX procedure uses the Best Basis Algorithm developedby Coifman and Wickerhauser to automatically select theblocks.

The SLEX procedure minimizes a generalized cross validationdeviance function to calculate the smoothing bandwidth

Jo Evans, Tim Park Fourier Domain Analysis

Page 21: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

The SLEX algorithm:

Split the series dyadically into 2j blocks for j = 1, . . . , J.

Compute the raw SLEXgrams in each of these blocks

Select the optimal bandwidth and smooth the SLEXgrams ineach block

Select the best blocks to model the series using BBA

Jo Evans, Tim Park Fourier Domain Analysis

Page 22: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

1.000000 7.888889 14.777778 21.666667 28.555556

65

43

21

Segmentation

Position

Leve

l

Figure: Segmentation chosen by the BBA for the FTSE100 time series

The BBA computes the cost associated with selecting each block.It then compares the cost of each bigger block to the two halfblocks beneath it and will reject the bigger block if the cost isgreater.

Jo Evans, Tim Park Fourier Domain Analysis

Page 23: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

Time

logr

etur

ns[1

:409

6]

0 1000 2000 3000 4000

−0.

10−

0.05

0.00

0.05

0.10

Figure: SLEX blocks shown on the log returns time series

Jo Evans, Tim Park Fourier Domain Analysis

Page 24: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

0.0 0.1 0.2 0.3 0.4 0.5

frequency

0.0 0.1 0.2 0.3 0.4 0.5

frequency

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5

frequency

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5

frequency

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5

frequency

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5

frequency

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5

frequency

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5 0.0 0.1 0.2 0.3 0.4 0.5

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5

perio

dogr

am

Figure: SLEXgrams

Jo Evans, Tim Park Fourier Domain Analysis

Page 25: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

Performing SLEX on the half and half series gives thesegmentation:

1.000000 4.333333 7.666667 11.000000 14.333333

54

32

1

Segmentation

Position

Leve

l

Jo Evans, Tim Park Fourier Domain Analysis

Page 26: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

Here are the resulting SLEX periodograms:

0.0 0.1 0.2 0.3 0.4 0.5

frequency

perio

dogr

am

0.0 0.1 0.2 0.3 0.4 0.5

frequency

perio

dogr

am

Jo Evans, Tim Park Fourier Domain Analysis

Page 27: Fourier Analysis of Stationary and Non-Stationary Time Series · 2019-12-05 · Time Series Basics Estimating Spectral Density Stationary Analysis of FTSE100 data Evolutionary Spectra

Time Series BasicsEstimating Spectral Density

Stationary Analysis of FTSE100 dataEvolutionary Spectra

SLEX

Figure: Any Questions?

Jo Evans, Tim Park Fourier Domain Analysis