NDK_XCF

 int __stdcall NDK_XCF ( double * X, double * Y, size_t N, size_t K, WORD method, WORD retType, double * retVal )

Calculates the cross-correlation function between two time series.

Returns
status code of the operation
Return values
 NDK_SUCCESS Operation successful NDK_FAILED Operation unsuccessful. See Macros for full list.
Parameters
 [in] X is the first univariate time series data (a one dimensional array). [in] Y is the second univariate time series data (a one dimensional array). [in] N is the number of observations in X. [in] K is the lag order (e.g. 0=no lag, 1=1st lag, etc.) to use with the second time series input (X). If missing, a default lag order of zero (i.e. no-lag) is assumed. [in] method is the algorithm/method to use for calculating the correlation (see notes below) [in] retType is a switch to select the return output (1 = correlation value(default), 2 = std error). [out] retVal is the calculated value of this function.
Remarks
1. The time series is homogeneous or equally spaced.
2. The two time series must be identical in size.
3. The NDK_XCF functions supports the following methods:
Method Value Description
XCF_PEARSON 1 Pearson
XCF_SPEARMAN 2 Spearman
XCF_KENDALL 3 Kendall
3. The Pearson correlation, $$r_{xy}$$, is defined as follows:
$r_{xy}= \frac{\sum_{i=1}^N(x_i-\bar{x})(y_i-\bar{y})}{\sqrt{\sum_{i=1}^N(x_i-\bar{x})^2\times\sum_{i=1}^N(y_i-\bar{y})^2}}$,
where:
• $$\bar{x}$$ is the sample average of time series X.
• $$\bar{y}$$ is the sample average of time series Y.
• $$x_i \in X$$ is a value from the first input time series data.
• $$y_i \in Y$$ is a value from the second input time series data.
• $$N$$ is the number of pairs $$\left ( x_i,y_i \right )$$ that do not contain a missing observation.
Requirements
Examples

 Namespace: NumXLAPI Class: SFSDK Scope: Public Lifetime: Static
 int NDK_XCF ( double[] pData1, double[] pData2, UIntPtr nSize, UIntPtr nLag, short nMethod, short retType, ref double retVal )

Calculates the cross-correlation function between two time series.

Return Value

a value from NDK_RETCODE enumeration for the status of the call.

 NDK_SUCCESS operation successful Error Error Code
Parameters
 [in] pData1 is the first univariate time series data (a one dimensional array). [in] pData2 is the second univariate time series data (a one dimensional array). [in] nSize is the number of observations in pData1. [in] nLag is the lag order (e.g. 0=no lag, 1=1st lag, etc.) to use with the second time series input (X). If missing, a default lag order of zero (i.e. no-lag) is assumed. [in] nMethod is the algorithm/method to use for calculating the correlation (see notes below) [in] retType is a switch to select the return output (1 = correlation value(default), 2 = std error). [out] retVal is the calculated value of this function.
Remarks
1. The time series is homogeneous or equally spaced.
2. The two time series must be identical in size.
3. The NDK_XCF functions supports the following methods:
Method Value Description
XCF_PEARSON 1 Pearson
XCF_SPEARMAN 2 Spearman
XCF_KENDALL 3 Kendall
3. The Pearson correlation, $$r_{xy}$$, is defined as follows:
$r_{xy}= \frac{\sum_{i=1}^N(x_i-\bar{x})(y_i-\bar{y})}{\sqrt{\sum_{i=1}^N(x_i-\bar{x})^2\times\sum_{i=1}^N(y_i-\bar{y})^2}}$,
where:
• $$\bar{x}$$ is the sample average of time series X.
• $$\bar{y}$$ is the sample average of time series Y.
• $$x_i \in X$$ is a value from the first input time series data.
• $$y_i \in Y$$ is a value from the second input time series data.
• $$N$$ is the number of pairs $$\left ( x_i,y_i \right )$$ that do not contain a missing observation.
Examples

References
Hull, John C.; Options, Futures and Other DerivativesFinancial Times/ Prentice Hall (2011), ISBN 978-0132777421