| 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 |
autocorr(Series,nLags,M,nSTDs)
[ACF,Lags,Bounds] = autocorr(Series,nLags,M,nSTDs)
autocorr(Series,nLags,M,nSTDs) computes and plots the sample ACF of a univariate, stochastic time series with confidence bounds. 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 autocorrelation function (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:
strm = RandStream('mt19937ar'); % reproducible
RandStream.setDefaultStream(strm);
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);
[Lags, ACF]
ans =
0 1.0000
1.0000 -0.6682
2.0000 0.3618
3.0000 -0.0208
4.0000 0.0146
5.0000 -0.0311
6.0000 0.0611
7.0000 -0.0828
8.0000 0.0772
9.0000 -0.0493
10.0000 0.0323
11.0000 -0.0294
12.0000 0.0576
13.0000 -0.0633
14.0000 0.0500
15.0000 -0.0129
16.0000 -0.0180
17.0000 0.0368
18.0000 -0.0459
19.0000 0.0439
20.0000 -0.0318
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:
strm = RandStream('mt19937ar'); % reproducible
RandStream.setDefaultStream(strm);
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.0115See Example: Using the Default Model.
[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.
filter (MATLAB function)
![]() | archtest | bm | ![]() |
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-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |