roderick garton >
Statistics-Autocorrelation-0.02 >
Statistics::Autocorrelation

Module Version: 0.02
Statistics-Autocorrelation - Coefficients for any lag

Version 0.02

use Statistics::Autocorrelation; $acorr = Statistics::Autocorrelation->new(); $coeff = $acorr->coefficient(data => \@data, lag => integer (from 1 to N-1), exact => 0, simple => 1);

Calculates autocorrelation coefficients for a single series of numerical data, for any valid length of *lag*.

$acorr = Statistics::Autocorrelation->new();

Return a new class object for accessing its methods.

$autocorr->coefficient(data => \@data, lag => integer (from 1 to N-1), exact => 0|1, simple => 1|0);

*Alias*: `coeff`

Corporate stats programs (e.g., SPSS/PASW), and examples of autocorrelation on the web (e.g., http://www.itl.nist.gov/div898/handbook/eda/section3/eda35c.htm), often yield/demonstrate a value of the autocorrelation coefficient that assumes that the underlying series is stationary (has no linear or curvilinear trend, no periodicity), and so can be calculated as the population autocorrelation coefficient, the ratio of the autocovariance to the overall variance. To be a valid estimate of the sample autocorrelation coefficient, it is assumed that the number of observations, *N*, in the sample is "reasonably large" - so that all the observations in each summation in the numerator are taken relative to the mean of the whole series, rather than the exact value at lag *k*, and also that the variance used in the denominator can be that of the whole series - instead of using completely pairwise products, i.e., making the coefficient dependent on the values of *u1*, ..., *un-k*, and *ui+k*, ..., *un* at each summation. Additionally, these sources also commonly drop the factor *I*/(*N* - 1), assuming that the value is close enough to 1 for large *N*.

By default, then, this method returns an estimate of the population autocorrelation coefficient, and the divisor factors are dropped; i.e., the default values of the options `exact`

= 0, and `simple`

= 1. The default value returned from this method, then, is equivalent to those returned from such corporate software, and demonstrated via such URLs, as cited; and this is also the default form of calculating the coefficient as used in texts such as Chatfield (1975). If you want, however, to keep these divisors, you need to specify `simple`

= 0; and if you want, furthermore, the exact sample autocorrelation coefficient, then specify `exact`

= 1; then you get the coefficient as calculated by Kendall's (1973) Eq. 3.35.

A croak will be heard if no value is given for `data`

(expects an array reference), or if the array is empty. A value for `data`

is the only one for which there is no default value and must be given.

If a value is not given for `lag`

, or it equals zero, it is set to the value of 1 by default.

Chatfield, C. (1975). *The analysis of time series: Theory and practice*. London, UK: Chapman and Hall.

Kendall, M. G. (1973). *Time-series*. London, UK: Griffin.

Roderick Garton, `<rgarton at cpan.org>`

Please report any bugs or feature requests to `bug-statistics-autocorrelation-0.02 at rt.cpan.org`

, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Statistics-Autocorrelation-0.02. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

You can find documentation for this module with the perldoc command.

perldoc Statistics::Autocorrelation

You can also look for information at:

- RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Statistics-Autocorrelation-0.02

- AnnoCPAN: Annotated CPAN documentation
- CPAN Ratings
http://cpanratings.perl.org/d/Statistics-Autocorrelation-0.02

- Search CPAN
http://search.cpan.org/dist/Statistics-Autocorrelation-0.02/

Copyright 2011 Roderick Garton.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

syntax highlighting: