The type double function is imsls_d_autocorrelation.
Required Arguments
intn_observations (Input) Number of observations in the time series x. n_observations must be greater than or equal to 2.
float x[] (Input) Array of length n_observations containing the time series.
int lagmax (Input) Maximum lag of autocovariance, autocorrelations, and standard errors of autocorrelations to be computed. lagmax must be greater than or equal to 1 and less than n_observations.
Return Value
Pointer to an array of length lagmax + 1 containing the autocorrelations of the time series x. The 0-th element of this array is 1. The k-th element of this array contains the autocorrelation of lag k where k = 1, ..., lagmax.
Prints the mean, variance, autocovariances, autocorrelations, and standard errors of autocorrelations.
Default = 0.
IMSLS_X_MEAN_IN, floatx_mean_in (Input) User input estimate of the mean of the time series x.
IMSLS_X_MEAN_OUT, float*x_mean_out (Output) If specified, x_mean_out is the computed arithmetic mean of the time series x.
IMSLS_ACV, float**autocovariances (Output) Address of a pointer to an array of length lagmax + 1 containing the variance and autocovariances of the time series x. The 0-th element of this array is the variance of the time series x. The k-th element contains the autocovariance of lag k where k = 1, ..., lagmax.
IMSLS_ACV_USER, floatautocovariances[] (Output) If specified, autocovariances is an array of length lagmax + 1 containing the variance and autocovariances of the time series x.
See IMSLS_ACV.
IMSLS_SEAC, float**standard_errors, intse_option (Output) Address of a pointer to an array of length lagmax containing the standard errors of the autocorrelations of the time series x.
Method of computation for standard errors of the autocorrelations is chosen by se_option.
se_option
Action
1
Compute the standard errors of autocorrelations using Barlett’s formula.
2
Compute the standard errors of autocorrelations using Moran’s formula.
IMSLS_SEAC_USER, floatstandard_errors[], intse_option (Output) If specified, autocovariances is an array of length lagmax containing the standard errors of the autocorrelations of the time series x. See IMSLS_SEAC.
IMSLS_RETURN_USER, floatautocorrelations[] (Output) If specified, autocorrelations is an array of length lagmax + 1 containing the autocorrelations of the time series x. The 0-th element of this array is 1. The k-th element of this array contains the autocorrelation of lag k where k = 1, …, lagmax.
Description
Function imsls_f_autocorrelation estimates the autocorrelation function of a stationary time series given a sample of n = n_observations observations {Xt} for t = 1, 2, …, n.
Let be the estimate of the mean μ of the time series {Xt} where
The autocovariance function σ(k) is estimated by
where K = lagmax. Note that
is an estimate of the sample variance. The autocorrelation function ρ(k) is estimated by
Note that
by definition.
The standard errors of the sample autocorrelations may be optionally computed according to argument se_option for the optional argument IMSLS_SEAC. One method (Bartlett 1946) is based on a general asymptotic expression for the variance of the sample autocorrelation coefficient of a stationary time series with independent, identically distributed normal errors. The theoretical formula is
where
assumes μ is unknown. For computational purposes, the autocorrelations r(k) are replaced by their estimates
for |k| ≤ K, and the limits of summation are bounded because of the assumption that r(k) = 0 for all k such that |k| > K.
A second method (Moran 1947) utilizes an exact formula for the variance of the sample autocorrelation coefficient of a random process with independent, identically distributed normal errors. The theoretical formula is
where μ is assumed to be equal to zero. Note that this formula does not depend on the autocorrelation function.
Example
Consider the Wolfer Sunspot Data (Anderson 1971, page 660) consisting of the number of sunspots observed each year from 1749 through 1924. The data set for this example consists of the number of sunspots observed from 1770 through 1869. Function imsls_f_autocorrelation with optional arguments computes the estimated autocovariances, estimated autocorrelations, and estimated standard errors of the autocorrelations.