Correlation and spectral analysis Objective: –investigation of correlation structure of time...

22
H Y D R O L O G Y P R O JE C T Technical Assistance Correlation and spectral analysis Objective: investigation of correlation structure of time series identification of major harmonic components in time series Tools: auto-covariance and auto-correlation function cross-covariance and cross-correlation function variance spectrum and spectral density function

Transcript of Correlation and spectral analysis Objective: –investigation of correlation structure of time...

Page 1: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Correlation and spectral analysis

• Objective:– investigation of correlation structure of time series– identification of major harmonic components in time

series

• Tools:– auto-covariance and auto-correlation function– cross-covariance and cross-correlation function– variance spectrum and spectral density function

Page 2: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Autocovariance and autocorrelation function

• Autocovariance function of series Y(t):

• Covariance at lag 0 = variance:

• To ensure comparibility scaling of autocovariance by variance:

• For a random series:

YY(k) = Cov[Y(t), Y(t+k)} = E[(Y(t) – Y)(Y(t+k) – Y)]

YY(0) = Y2

YY(k) = YY(k))/ YY(0) with –1 YY(k) 1

YY(k) = 0 for |k| > 0

Page 3: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Estimation of autocovariance and autocorrelation function

– Estimation of autocovariance:

– Estimation of autocorrelation function:

– Note that estimators are biased (division by n rather than by (n-k-1): gives smaller mean square error

– 95% confidence limits for zero correlation:

)my)(my(n

1)k(C yki

kn

1iyiYY

n

1i

2yi

kn

1iykiyi

YY

YYYY

)my(n

1

)my)(my(n

1

)0(C

)k(C)k(r

kn

1

)1kn(

)1kn(96.1

1kn

1)k(CL

Page 4: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Example autocorrelation function for monthly rainfall station PATAS (1979-1989)

MPS_PATAS

Time in months

19

90

19

89

19

88

19

87

19

86

19

85

19

84

19

83

19

82

19

81

19

80

19

79

19

78

19

77

19

76

19

75

19

74

19

73

19

72

19

71

19

70

Ra

infa

ll (m

m)

320

300

280

260

240

220

200

180

160

140

120

100

80

60

40

20

0

Page 5: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Example PATAS continued (1)

Series = PATAS MPS Date of first element = 1970 1 0 0 1 Date of last element = 1990 1 0 0 1

Confidence interval = 95%

COV = autocovariance function COR = autocorrelation function CLP = upper conf. limit zero correlation CLN = lower conf. limit zero correlation LAG COV COR CLP CLN 0 .3319E+04 1.0000 .1211 -.1294 1 .5779E+03 .1741 .1213 -.1296 2 .4315E+03 .1300 .1216 -.1299 3 .7955E+02 .0240 .1218 -.1302 4 -.3789E+03 -.1142 .1221 -.1305 5 -.7431E+03 -.2239 .1223 -.1308 6 -.7814E+03 -.2354 .1226 -.1310 7 -.7383E+03 -.2224 .1228 -.1313 8 -.1996E+03 -.0601 .1231 -.1316 9 .2174E+03 .0655 .1233 -.1319 10 .3428E+03 .1033 .1236 -.1322 11 .1119E+04 .3371 .1238 -.1325 12 .1254E+04 .3779 .1241 -.1328 13 .6556E+03 .1975 .1243 -.1331 14 .1103E+03 .0332 .1246 -.1334 15 .2240E+03 .0675 .1248 -.1337 16 -.3054E+03 -.0920 .1251 -.1340 17 -.7494E+03 -.2258 .1254 -.1343 18 -.7914E+03 -.2385 .1256 -.1346 19 -.7762E+03 -.2339 .1259 -.1349 20 -.2796E+03 -.0842 .1262 -.1352 21 .3819E+03 .1151 .1264 -.1355 22 .3259E+03 .0982 .1267 -.1358 23 .7051E+03 .2125 .1270 -.1361 24 .1203E+04 .3624 .1273 -.1364

Page 6: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Example PATAS continued (2)

autocorrelation function upper conf. limit zero correlation lower conf. limit zero correlation

Time lag (months)95908580757065605550454035302520151050

au

toc

orr

ela

tio

n

1

0.8

0.6

0.4

0.2

0

-0.2

-0.4

-0.6

-0.8

-1

Periodicity with T = 12 months due to fixed occurrence of monsoon rainfall

Periodicity with T = 12 months due to fixed occurrence of monsoon rainfall

Page 7: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Autocorrelogram of daily rainfall at PATAS

autocorrelation function upper conf. limit zero correlation lower conf. limit zero correlation

time lag (days)3029282726252423222120191817161514131211109876543210

auto

co

rrel

atio

n

1

0.8

0.6

0.4

0.2

0

-0.2

-0.4

-0.6

-0.8

-1

Lag = 1 monthLag = 1 month

Page 8: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Autocorrelation function of harmonic

• it follows:– covariance of harmonic remains a harmonic of the same

frequency f, so it preserves frequency information– information on phase shift vanishes– amplitude of covariance is equal to variance of Y(t)

)T

t2sin(A)ft2sin(A)t(Y

:T

1fandf2:withor)tsin(A)t(Y

22YYY

2YY

2YY

YYYY

A2

1)0(C:so)f2cos(A

2

1)(C

)2)2(ft2cos(E)f2cos(EA2

1)(C

:followsit)bacos()bacos(2

1)bsin().asin(:withor

))t(f2sin(A).ft2sin(AE))t(Y)()t(Y(E)(C

Page 9: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Y(t) = harmonic series

Page 10: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Autocovariance and autocorrelation of harmonic

Page 11: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Cross-covariance and cross-correlation function

• Cross-covariance:

X(t)

Y(t+k)

Lag = k

X

Y

Time t

Time t

Page 12: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Cross-covariance and cross-correlation function

• Definition cross-covariance function:

• Definition of cross-correlation function:

• Note:

– for lag 0: XY(0) < 1 unless perfect correlation

– maximum may occur at lag 0

– for two water level stations along river, maximum correlation will be equal to k = distance / celerity

– hence upstream station X(t) will give maximum correlation with Y(t+k) at downstream site

– or downstream site Y(t) will give maximum correlation with X(t-k) at upstream site

XY(k) = Cov[X(t), Y(t+k)} = E[(X(t) – X)(Y(t+k) – Y)]

XY(k) = XY(k))/X Y with –1 XY(k) 1

Page 13: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Estimation of cross-covariance and cross-correlation function

• Estimation of cross-covariance:

• Estimation of cross-correlation:

• Note that estimators are biased since n rather than (n-k-1) is used in divider, but estimator provides smaller mean square error

)my)(mx(n

1)k(C yki

kn

1ixiXY

n

1i

2yi

n

1i

2xi

kn

1iykixi

YYXX

XYXY

)my(n

1)mx(

n

1

)my)(mx(n

1

)0(C)0(C

)k(C)k(r

Page 14: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Variance spectrum and spectral density function

• Plot of variance of harmonics versus their frequencies is called power or variance spectrum– If Sp(f) is the ordinate of continuous spectrum then the

variance contributed by all frequencies in the frequency interval f, f+df is given by Sp(f).df. Hence:

– Hydrological processes can be considered to be frequency limited, hence harmonics with f > fc do not significantly contribute to variance of the process. Then:

– fc = Nyquist or cut-off frequency

0

2Yp df).f(S

cf

0

2Yp df).f(S

Page 15: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Spectrum (2)

• Scaling of variance spectrum by variance (to make them comparable) gives the spectral density function:

• spectral density function is Fourier transform of auto-correlation function

1df).f(S:hence)f(S

)f(Scf

0

d2Y

pd

1kYYd )fk2cos()k(212)f(S

Page 16: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Estimation of spectrum

• Replace YY(k) by rYY(k) for k=0,1,2,…,M

• M = maximum lag for which acf is estimated• M is to be carefully selected• To reduce sampling variance in estimate a smoothing

function is applied: the spectral density at fk is estimated as weighted average of density at fk-1 ,fk ,fk+1

• Smoothing function is spectral window• Spectral window has to be carefully designed • Appropriate window is Tukey window:

• In frequency domain it implies fk is weighted average according to: 1/4fk-1 ,1/2fk ,1/4fk+1

Mk:for0)k(T

Mk:for)M

kcos(1

2

1)k(T

w

w

M3

N8n:and

tM3

4B

Bandwidth

Number of degrees of freedom

Page 17: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Estimation of spectrum (2)

• Spectral estimator s(f) for Sd(f) becomes:

• To be estimated at:

• According to Jenkins and Watts number of frequency points should be 2 to 3 times (M+1)

• (1-)100% confidence limits:

2

1,....,0f:for)fk2cos()k(r)k(T212)f(s

1M

1kYYw

M,......,1,0k:forM

kff ck

)2

(

)f(s.n)f(S

)2

1(

)f(s.n

2n

d2n

fc = 1/(2t)

Page 18: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Confidence limits for white noise (s(f) =2)

Variance reduces with decreasing M; for n > 25 variance reduces only slowly

Page 19: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Estimation of spectrum (3)

• To reduce sampling variance, M should be taken small, say M = 10 to 15 % of N (= series length)

• However, small M leads to large bandwidth B• Large B gives smoothing over large frequency range • E.g. if one expects significant harmonics with periods 16

and 24 hours in hourly series:– frequency difference is 1/16 - 1/24 = 1/48

– hence: B < 1/48

– so: M > 4x48/3 = 64

– by choosing M = 10% of N, then N > 640 data points or about one month

• Since it is not known in advance which harmonics are significant, estimation is to be repeated for different M

• White noise: YY(k) = 0 for k > 0 it follows since 0 f1/2, for white noise s(f) 2

Page 20: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Example of spectrum of monthly rainfall data for station PATAS

Series =PATAS MPS Date of first element = 1970 1 0 0 1 Date of last element = 1989 12 0 0 1

Truncation lag = 72 Number of frequency points = 72

Bandwith = .0185 Degr.frdom = 8

upper conf. limit white noise = .9125 lower conf. limit white noise = 7.3402

ASPEC = variance spectrum LOG SPEC = logarithm of ASPEC DSPEC = spectral density

Page 21: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Example of spectrum of monthly rainfall data for station PATAS (2)

NR FREQUENCY ASPEC LOGSPEC DSPEC 0 .0000 .8379E+04 3.9232 2.5174 1 .0069 .9706E+04 3.9870 2.9162 2 .0139 .8942E+04 3.9514 2.6866 3 .0208 .4188E+04 3.6220 1.2583 4 .0278 .1125E+04 3.0511 .3380 5 .0347 .1776E+04 3.2495 .5337 6 .0417 .3632E+04 3.5601 1.0912 7 .0486 .3158E+04 3.4993 .9487 8 .0556 .1659E+04 3.2199 .4984 9 .0625 .1861E+04 3.2698 .5592 10 .0694 .4128E+04 3.6157 1.2401 11 .0764 .3419E+05 4.5339 10.2732 12 .0833 .6287E+05 4.7985 18.8906 13 .0903 .3767E+05 4.5759 11.3166 14 .0972 .1104E+05 4.0430 3.3173 15 .1042 .7031E+04 3.8470 2.1124 16 .1111 .2293E+04 3.3604 .6890 17 .1181 .2650E+04 3.4233 .7962 18 .1250 .5415E+04 3.7336 1.6269 19 .1319 .4855E+04 3.6862 1.4587 20 .1389 .2575E+04 3.4108 .7737

Page 22: Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.

HYDROLOGY PROJECTTechnical Assistance

Example of spectrum of monthly rainfall data for station PATAS (3)

spectral density upper conf. limit white noise lower conf. limit white noise

frequency (cycles per month)0.50.480.460.440.420.40.380.360.340.320.30.280.260.240.220.20.180.160.140.120.10.080.060.040.020

spec

tral

den

sity

20

19

18

17

16

15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

0

Variance is maximum at f = 0.0833 = 1/12Variance is maximum at f = 0.0833 = 1/12