| Contents | Index |
autocorr(Series,nLags,M,nSTDs)
[ACF,lags,bounds] = autocorr(Series,nLags,M,nSTDs)
autocorr(Series,nLags,M,nSTDs) computes and plots the sample autocorrelation function (ACF) of a univariate, stochastic time series with confidence bounds (also known as the correlogram). To plot the ACF sequence without the confidence bounds, set nSTDs = 0.
[ACF,lags,bounds] = autocorr(Series,nLags,M,nSTDs) computes and returns the ACF sequence.
Column vector of observations of a univariate time series for which autocorr computes or plots the sample ACF. The last row of Series contains the most recent observation of the time series. | |
Positive scalar integer indicating the number of lags of the ACF to compute. If nLags = [] or is unspecified, the default is to compute the ACF at lags 0, 1, 2, ..., T, where T = min([20,length(Series)-1]). | |
Nonnegative integer scalar indicating the number of lags
beyond which the theoretical ACF is effectively 0. autocorr assumes
the underlying Series is an MA(M) process, and
uses Bartlett's approximation to compute the large-lag standard error
for lags greater than M. If M = [] or is unspecified, the default is 0,
and autocorr assumes that Series is
Gaussian white noise. If Series is a Gaussian white
noise process of length N, the standard error is
approximately
| |
Positive scalar indicating the number of standard deviations
of the sample ACF estimation error to compute. autocorr assumes
the theoretical ACF of Series is 0 beyond
lag M. When M = 0 and Series is
a Gaussian white noise process of length N, specifying nSTDs results
in confidence bounds at
|
Sample autocorrelation function of Series. ACF is a vector of length nLags+1 corresponding to lags 0, 1, 2, ..., nLags. The first element of ACF is unity, that is, ACF(1) = 1 = lag 0 correlation. | |
Vector of lags corresponding to ACF(0,1,2,...,nLags). Since an ACF is symmetric about 0 lag, autocorr ignores negative lags. | |
Two-element vector indicating the approximate upper and lower confidence bounds, assuming that Series is an MA(M) process. Values of ACF beyond lag M that are effectively 0 lie within these bounds. autocorr computes bounds only for lags greater than M. |
Create an MA(2) time series from a column vector of 1000 Gaussian deviates. Then, assess whether the ACF is effectively zero for lags greater than 2:
rng('default') % make output reproducible
x = randn(1000, 1); % 1000 Gaussian deviates ~ N(0, 1).
y = filter([1 -1 1], 1, x); % Create an MA(2) process.
% Compute the ACF with 95 percent confidence.
[ACF, lags, bounds] = autocorr(y, [], 2)
ACF =
1.0000
-0.6682
0.3618
-0.0208
0.0146
-0.0311
0.0611
-0.0828
0.0772
-0.0493
0.0323
-0.0294
0.0576
-0.0633
0.0500
-0.0129
-0.0180
0.0368
-0.0459
0.0439
-0.0318
lags =
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
bounds =
0.0928
-0.0928
autocorr(y, [], 2) % Use the same example, but plot the ACF
% sequence with confidence bounds.

Although various estimates of the sample autocorrelation function exist, the form adopted here follows that of Box, Jenkins, and Reinsel, specifically:
|
| (11-1) |
![]() | (11-2) |
The autocorr function computes the sample ACF by removing the sample mean of the input Series, then normalizing the sequence such that the ACF at lag zero is unity. In certain applications, it is useful to rescale the resulting normalized ACF by the sample variance. In this case, the correct scale factor to use is var(Series,1).
The following commands simulate 1000 standard Gaussian random numbers, then compares the first 10 lags of the sample ACF with and without normalization:
rng('default') % make output reproducible
y = randn(1000, 1);
[ACF, lags] = autocorr(y, 10);
[lags ACF ACF*var(y,1)]
ans =
0 1.0000 0.9969
1.0000 0.0360 0.0359
2.0000 0.0441 0.0439
3.0000 -0.0271 -0.0271
4.0000 -0.0452 -0.0451
5.0000 -0.0173 -0.0172
6.0000 0.0456 0.0454
7.0000 -0.0136 -0.0135
8.0000 0.0332 0.0331
9.0000 -0.0356 -0.0355
10.0000 -0.0115 -0.0115[1] Box, G. E. P., G. M. Jenkins, and G. C. Reinsel. Time Series Analysis: Forecasting and Control. 3rd ed. Upper Saddle River, NJ: Prentice-Hall, 1994.
[2] Hamilton, J. D. Time Series Analysis. Princeton, NJ: Princeton University Press, 1994.
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-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |