NAG Library Function Document
nag_tsa_multi_cross_corr (g13dmc) calculates the sample cross-correlation (or cross-covariance) matrices of a multivariate time series.
||nag_tsa_multi_cross_corr (Nag_CovOrCorr matrix,
const double w,
observations of a vector of
time series. The sample cross-covariance matrix at lag
is defined to be the
, whose (
)th element is given by
denote the sample means for the
th series respectively. The sample cross-correlation matrix at lag
is defined to be the
th element is given by
The number of lags, , is usually taken to be at most .
follows a vector moving average model of order
, then it can be shown that the theoretical cross-correlation matrices
are zero beyond lag
. In order to help spot a possible cut-off point, the elements of
are usually compared to their approximate standard error of 1/
. For further details see, for example, Wei (1990)
The function uses a single pass through the data to compute the means and the cross-covariance matrix at lag zero. The cross-covariance matrices at further lags are then computed on a second pass through the data.
Wei W W S (1990) Time Series Analysis: Univariate and Multivariate Methods Addison–Wesley
West D H D (1979) Updating mean and variance estimates: An improved method Comm. ACM 22 532–555
matrix – Nag_CovOrCorrInput
: indicates whether the cross-covariance or cross-correlation matrices are to be computed.
- The cross-covariance matrices are computed.
- The cross-correlation matrices are computed.
k – IntegerInput
On entry: , the dimension of the multivariate time series.
n – IntegerInput
On entry: , the number of observations in the series.
m – IntegerInput
, the number of cross-correlation (or cross-covariance) matrices to be computed. If in doubt set
. However it should be noted that m
is usually taken to be at most
w – const doubleInput
On entry: must contain the value for series at time , for and .
wmean[k] – doubleOutput
On exit: the means,
, for .
r0 – doubleOutput
th element of the sample cross-covariance matrix.
If , , contains the th element of the sample cross-correlation matrix and contains the standard deviation of the th series.
r – doubleOutput
th element of the sample cross-covariance matrix at lag
If , then it contains the
th element of the sample cross-correlation matrix lag , for , and .
fail – NagError *Input/Output
The NAG error argument (see Section 3.6
in the Essential Introduction).
6 Error Indicators and Warnings
On entry, argument had an illegal value.
On entry, .
On entry, .
On entry, and .
Constraint: and .
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG
On entry, at least one of the series is such that all its elements are practically identical giving zero (or near zero) variance.
For a discussion of the accuracy of the one-pass algorithm used to compute the sample cross-covariances at lag zero see West (1979)
. For the other lags a two-pass algorithm is used to compute the cross-covariances; the accuracy of this algorithm is also discussed in West (1979)
. The accuracy of the cross-correlations will depend on the accuracy of the computed cross-covariances.
8 Parallelism and Performance
nag_tsa_multi_cross_corr (g13dmc) is not threaded by NAG in any implementation.
nag_tsa_multi_cross_corr (g13dmc) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the Users' Note
for your implementation for any additional implementation-specific information.
The time taken is roughly proportional to .
This program computes the sample cross-correlation matrices of two time series of length , up to lag . It also prints the cross-correlation matrices together with plots of symbols indicating which elements of the correlation matrices are significant. Three * represent significance at the % level, two * represent significance at the 1% level and a single * represents significance at the 5% level. The * are plotted above or below the line depending on whether the elements are significant in the positive or negative direction.
10.1 Program Text
Program Text (g13dmce.c)
10.2 Program Data
Program Data (g13dmce.d)
10.3 Program Results
Program Results (g13dmce.r)