Top Banner
Environmental Data Analysis with MatLab Lecture 18: Cross-correlation
46

Environmental Data Analysis with MatLab

Oct 21, 2015

Download

Documents

Anouar Attn

Environmental Data Analysis with MatLab,Cross-correlation.generalize the idea of autocorrelation

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Environmental Data Analysis with MatLab

Environmental Data Analysis with MatLab

Lecture 18:

Cross-correlation

Page 2: Environmental Data Analysis with MatLab

Lecture 01 Using MatLabLecture 02 Looking At DataLecture 03 Probability and Measurement Error Lecture 04 Multivariate DistributionsLecture 05 Linear ModelsLecture 06 The Principle of Least SquaresLecture 07 Prior InformationLecture 08 Solving Generalized Least Squares ProblemsLecture 09 Fourier SeriesLecture 10 Complex Fourier SeriesLecture 11 Lessons Learned from the Fourier TransformLecture 12 Power Spectral DensityLecture 13 Filter Theory Lecture 14 Applications of Filters Lecture 15 Factor Analysis Lecture 16 Orthogonal functions Lecture 17 Covariance and AutocorrelationLecture 18 Cross-correlationLecture 19 Smoothing, Correlation and SpectraLecture 20 Coherence; Tapering and Spectral Analysis Lecture 21 InterpolationLecture 22 Hypothesis testing Lecture 23 Hypothesis Testing continued; F-TestsLecture 24 Confidence Limits of Spectra, Bootstraps

SYLLABUS

Page 3: Environmental Data Analysis with MatLab

purpose of the lecture

generalize the idea of autocorrelation

to multiple time series

Page 4: Environmental Data Analysis with MatLab

Review of last lecture

autocorrelationcorrelations between samples within a

time series

Page 5: Environmental Data Analysis with MatLab

high degree of short-term correlation

what ever the river was doing yesterday, its probably doing today, too

because water takes time to drain away

Page 6: Environmental Data Analysis with MatLab

0 500 1000 1500 2000 2500 3000 3500 40000

1

2

x 104

time, days

disc

harg

e, c

fs

0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0.04 0.045 0.050

2

4

6

8

x 109

frequency, cycles per dayPS

D,

(cfs

)2 per

cyc

le/d

ay

A) time series, d(t)

time t, days

d(t)

, cfs

Neuse River Hydrograph

Page 7: Environmental Data Analysis with MatLab

low degree of intermediate-term correlation

what ever the river was doing last month, today it could be doing something completely different

because storms are so unpredictable

Page 8: Environmental Data Analysis with MatLab

0 500 1000 1500 2000 2500 3000 3500 40000

1

2

x 104

time, days

disc

harg

e, c

fs

0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0.04 0.045 0.050

2

4

6

8

x 109

frequency, cycles per dayPS

D,

(cfs

)2 per

cyc

le/d

ay

A) time series, d(t)

time t, days

d(t)

, cfs

Neuse River Hydrograph

Page 9: Environmental Data Analysis with MatLab

moderate degree of long-term correlation

what ever the river was doing this time last year, its probably doing today, too

because seasons repeat

Page 10: Environmental Data Analysis with MatLab

0 500 1000 1500 2000 2500 3000 3500 40000

1

2

x 104

time, days

disc

harg

e, c

fs

0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0.04 0.045 0.050

2

4

6

8

x 109

frequency, cycles per dayPS

D,

(cfs

)2 per

cyc

le/d

ay

A) time series, d(t)

time t, days

d(t)

, cfs

Neuse River Hydrograph

Page 11: Environmental Data Analysis with MatLab

0 0.5 1 1.5 2 2.5

x 104

0

0.5

1

1.5

2

2.5x 10

4

discharge

disc

harg

e la

gged

by

1 da

ys

0 0.5 1 1.5 2 2.5

x 104

0

0.5

1

1.5

2

2.5x 10

4

discharge

disc

harg

e la

gged

by

3 da

ys

0 0.5 1 1.5 2 2.5

x 104

0

0.5

1

1.5

2

2.5x 10

4

discharge

disc

harg

e la

gged

by

30 d

ays

1 day 3 days 30 days

Page 12: Environmental Data Analysis with MatLab

-30 -20 -10 0 10 20 300

5

x 106

lag, days

auto

corr

elat

ion

-3000 -2000 -1000 0 1000 2000 3000

-505

x 106

lag, days

auto

corr

elat

ion

Autocorrelation Function

31 30

Page 13: Environmental Data Analysis with MatLab

formula for covariance

Page 14: Environmental Data Analysis with MatLab

formula for autocorrelation

autocorrelationat lag (k-1)Δt

Page 15: Environmental Data Analysis with MatLab

autocorrelation similar to convolution

Page 16: Environmental Data Analysis with MatLab

autocorrelation similar to convolution

note difference in sign

Page 17: Environmental Data Analysis with MatLab

autocorrelation in MatLab

Page 18: Environmental Data Analysis with MatLab

Important Relation #1autocorrelation is the convolution of a time series with its time-reversed self

Page 19: Environmental Data Analysis with MatLab

Important Relationship #2Fourier Transform of an autocorrelation

is proportional to thePower Spectral Density of time series

Page 20: Environmental Data Analysis with MatLab

End of Review

Page 21: Environmental Data Analysis with MatLab

Part 1

correlations between time-series

Page 22: Environmental Data Analysis with MatLab

scenario

discharge correlated with rain

but discharge is delayed behind rain

because rain takes time to drain from the land

Page 23: Environmental Data Analysis with MatLab

time, days

time, days

rain

, mm

/day

disc

hagr

e, m

3 /s

Page 24: Environmental Data Analysis with MatLab

time, days

time, days

rain

, mm

/day

disc

hagr

e, m

3 /s

rain ahead ofdischarge

Page 25: Environmental Data Analysis with MatLab

time, days

time, days

rain

, mm

/day

disc

hagr

e, m

3 /s

shape not exactly the same, either

Page 26: Environmental Data Analysis with MatLab

treat two time series u and v probabilistically

p.d.f. p(ui, vi+k-1)with elements lagged by time(k-1)Δtand compute its covariance

Page 27: Environmental Data Analysis with MatLab

this defines the cross-correlation

Page 28: Environmental Data Analysis with MatLab

just a generalization of the auto-correlation

different times in the same time series

different times in different time series

Page 29: Environmental Data Analysis with MatLab

like autocorrelation, similar to convolution

Page 30: Environmental Data Analysis with MatLab

As with auto-correlationtwo important properties

#1: relationship to convolution

#2: relationship to Fourier Transform

Page 31: Environmental Data Analysis with MatLab

As with auto-correlationtwo important properties

#1: relationship to convolution

#2: relationship to Fourier Transform

cross-spectral density

Page 32: Environmental Data Analysis with MatLab

cross-correlation in MatLab

Page 33: Environmental Data Analysis with MatLab

Part 2

aligning time-seriesa simple application of cross-correlation

Page 34: Environmental Data Analysis with MatLab

central idea

two time series are best alignedat the lag at which they are most correlated,

which is

the lag at which their cross-correlation is maximum

Page 35: Environmental Data Analysis with MatLab

10 20 30 40 50 60 70 80 90 100-1

0

1

10 20 30 40 50 60 70 80 90 100-1

0

1

u(t)

v(t)

two similar time-series, with a time shift

(this is simple “test” or “synthetic” dataset)

Page 36: Environmental Data Analysis with MatLab

-20 -10 0 10 20

-5

0

5

time

cros

s-co

rrel

atio

n

cross-correlate

Page 37: Environmental Data Analysis with MatLab

-20 -10 0 10 20

-5

0

5

time

cros

s-co

rrel

atio

n

maximum

time lag

find maximum

Page 38: Environmental Data Analysis with MatLab

In MatLab

Page 39: Environmental Data Analysis with MatLab

In MatLab

compute cross-correlation

Page 40: Environmental Data Analysis with MatLab

In MatLab

compute cross-correlation

find maximum

Page 41: Environmental Data Analysis with MatLab

In MatLab

compute cross-correlation

find maximum

compute time lag

Page 42: Environmental Data Analysis with MatLab

10 20 30 40 50 60 70 80 90 100-1

0

1

10 20 30 40 50 60 70 80 90 100-1

0

1

u(t)

v(t+tlag)

align time series with measured lag

Page 43: Environmental Data Analysis with MatLab

A)

B)

2 4 6 8 10 12 140

500

time, days

solar

, W/m

2

2 4 6 8 10 12 140

50

100

time, days

ozon

e, p

pb

2 4 6 8 10 12 140

500

time, days

solar

, W/m

2

2 4 6 8 10 12 140

50

100

time, days

ozon

e, p

pbsolar insolation and ground level ozone(this is a real dataset from West Point NY)

Page 44: Environmental Data Analysis with MatLab

B)

2 4 6 8 10 12 140

500

time, days

solar

, W/m

2

2 4 6 8 10 12 140

50

100

time, days

ozon

e, p

pb

2 4 6 8 10 12 140

500

time, days

solar

, W/m

2

2 4 6 8 10 12 140

50

100

time, days

ozon

e, p

pbsolar insolation and ground level ozone

note time lag

Page 45: Environmental Data Analysis with MatLab

-10 -5 0 5 100

1

2

3

4x 10

6

time, hours

cros

s-co

rrel

atio

n

C)maximum

time lag3 hours

Page 46: Environmental Data Analysis with MatLab

0.5 1 1.5 2 2.5 3 3.5 4 4.5 50

500

time, days

sola

r rad

iatio

n, W

/m2

0.5 1 1.5 2 2.5 3 3.5 4 4.5 50

50

100

3.00 hour lag

time, days

ozon

e, p

pb

A)

B) originaldelagged