| GARCH Toolbox™ | ![]() |
crosscorr(Series1,Series2,nLags,nSTDs)
[XCF,Lags,Bounds] = crosscorr(Series1,Series2,nLags,nSTDs)
crosscorr(Series1,Series2,nLags,nSTDs) computes and plots the sample cross-correlation function (XCF) between two univariate, stochastic time series. To plot the XCF sequence without the confidence bounds, set nSTDs = 0.
[XCF,Lags,Bounds] = crosscorr(Series1,Series2,nLags,nSTDs) computes and returns the XCF sequence.
Column vector of observations of the first univariate time series for which crosscorr computes or plots the sample cross-correlation function (XCF). The last row of Series1 contains the most recent observation. | |
Column vector of observations of the second univariate time series for which crosscorr computes or plots the sample XCF. The last row of Series2 contains the most recent observation. | |
Positive scalar integer indicating the number of lags
of the XCF to compute. If nLags = [] or is unspecified, crosscorr computes
the XCF at lags
| |
Positive scalar indicating the number of standard deviations of the sample XCF estimation error to compute, if Series1 and Series2 are uncorrelated. If nSTDs = [] or is unspecified, the default is 2 (that is, approximate 95 percent confidence interval). |
Sample cross-correlation function between Series1 and Series2. XCF is a vector
of length 2(nLags)+1, which corresponds to lags
| |
Vector of lags corresponding to XCF(nLags, ..., +nLags). | |
Two-element vector indicating the approximate upper and lower confidence bounds, assuming that Series1 and Series2 are completely uncorrelated. |
Create a time-series column vector of 100 Gaussian deviates:
randn('state', 100) % Start from a known state
x = randn(100, 1); % 100 Gaussian deviates, N(0, 1)
Create a delayed version of the vector, lagged by four samples:
y = lagmatrix(x, 4); % Delay it by 4 samples
Compute the XCF, and then plot it to see the XCF peak at the fourth lag:
y(isnan(y)) = 0;
[XCF, Lags, Bounds] = crosscorr(x, y);
[Lags, XCF]
ans =
-20.0000 -0.0210
-19.0000 -0.0041
-18.0000 0.0661
-17.0000 0.0668
-16.0000 0.0380
-15.0000 -0.1060
-14.0000 0.0235
-13.0000 0.0240
-12.0000 0.0366
-11.0000 0.0505
-10.0000 0.0661
-9.0000 0.1072
-8.0000 -0.0893
-7.0000 -0.0018
-6.0000 0.0730
-5.0000 0.0204
-4.0000 0.0352
-3.0000 0.0792
-2.0000 0.0550
-1.0000 0.0004
0 -0.1556
1.0000 -0.0959
2.0000 -0.0479
3.0000 0.0361
4.0000 0.9802
5.0000 0.0304
6.0000 -0.0566
7.0000 -0.0793
8.0000 -0.1557
9.0000 -0.0128
10.0000 0.0623
11.0000 0.0625
12.0000 0.0268
13.0000 0.0158
14.0000 0.0709
15.0000 0.0102
16.0000 -0.0769
17.0000 0.1410
18.0000 0.0714
19.0000 0.0272
20.0000 0.0473
Bounds
Bounds =
0.2000
-0.2000
crosscorr(x, y) % Use the same example, but plot the XCF
% sequence. Note the peak at the 4th lag.

See Example: Analysis and Estimation Using the Default Model.
filter (MATLAB® function)
![]() | autocorr | dfARDTest | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |