| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Econometrics Toolbox |
| Contents | Index |
| Learn more about Econometrics 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:
strm = RandStream('mt19937ar'); % reproducible
RandStream.setDefaultStream(strm);
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.1553
-19.0000 -0.0342
-18.0000 0.0850
-17.0000 -0.0260
-16.0000 -0.1304
-15.0000 0.0498
-14.0000 -0.0234
-13.0000 -0.1033
-12.0000 0.0227
-11.0000 -0.0422
-10.0000 0.0294
-9.0000 -0.0099
-8.0000 -0.0296
-7.0000 -0.0094
-6.0000 0.1510
-5.0000 -0.0911
-4.0000 0.2235
-3.0000 0.0065
-2.0000 -0.0452
-1.0000 0.0792
0 -0.1901
1.0000 0.0321
2.0000 0.0240
3.0000 -0.0073
4.0000 0.9675
5.0000 -0.0069
6.0000 0.0248
7.0000 0.0232
8.0000 -0.1529
9.0000 0.0870
10.0000 -0.0131
11.0000 -0.0095
12.0000 0.1941
13.0000 -0.1149
14.0000 0.1319
15.0000 0.0063
16.0000 -0.0184
17.0000 -0.0068
18.0000 0.0562
19.0000 -0.0466
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: Using the Default Model.
filter (MATLAB function)
View demos and recorded presentations led by industry experts.
Now On Demand
Network with industry peers and learn the latest applications of the leading software product for computational finance.
| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |