NDK_ACF

int __stdcall NDK_ACF ( double *  X,
size_t  N,
size_t  K,
double *  retVal 
)

Calculates the sample autocorrelation function (ACF) of a stationary 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 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. k=0 (no lag), k=1 (1st lag), etc.).
[out] retVal is the calculated sample autocorrelation value.
Remarks
1. The time series is homogeneous or equally spaced.
2. The time series may include missing values (NaN) at either end.
3. The lag order (k) must be less than the time series size or else an error value NDK_FAILED is returned.
4. The ACF values are bound between -1 and 1, inclusive.
5. The sample autocorrelation is computed as:
  • \(\hat{\rho}(h)=\frac{\sum_{k=h}^T{(y_{k}-\bar y)(y_{k-h}-\bar y)}}{\sum_{k=h}^T(y_{k}-\bar y)^2} \)
    where:
    • \(y_{t}\)  is the value of the time series at time t.
    • \(h\) is the lag order.
    • \(T\) is the number of non-missing values in the time series data.
    • \(\bar y\) is the sample average/mean of the time series.
6. Special cases: By definition, \(\hat{\rho}(0) \equiv 1.0\)
Requirements
Header SFSDK.H
Library SFSDK.LIB
DLL SFSDK.DLL
Examples
#include "SFMacros.h"
#include "SFSDK.h"

// Input time series: 110 observation 
double data[110]={0.23, 0.24, 0.45, ..., 0.95}

int nRet = NDK_FAILED;
double retVal = -2.0f;
nRet = NDK_ACF(data, 110, 1, &retVal);
if( nRet < NDK_SUCCESS){
    // Error occured
    // Call NDK_MSG to retrieve description of the error, and write it to the log file
    ....
}
	
Namespace:  NumXLAPI
Class:  SFSDK
Scope:  Public
Lifetime:  Static
int NDK_ACF ( double[]  pData,
UIntPtr  nSize,
int  nLag,
out double  retVal 
)

Calculates the sample autocorrelation function (ACF) of a stationary 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] pData is the univariate time series data (a one dimensional array).
[in] nSize is the number of observations in pData.
[in] nLag is the lag order (e.g. k=0 (no lag), k=1 (1st lag), etc.).
[out] retVal is the calculated sample autocorrelation value.
Remarks
1. The time series is homogeneous or equally spaced.
2. The time series may include missing values (NaN) at either end.
3. The lag order (nLag) must be less than the time series size or else an error value NDK_FAILED is returned.
4. The ACF values are bound between -1 and 1, inclusive.
5. The sample autocorrelation is computed as:
  • \(\hat{\rho}(h)=\frac{\sum_{k=h}^T{(y_{k}-\bar y)(y_{k-h}-\bar y)}}{\sum_{k=h}^T(y_{k}-\bar y)^2} \)
    where:
    • \(y_{t}\)  is the value of the time series at time t.
    • \(h\) is the lag order.
    • \(T\) is the number of non-missing values in the time series data.
    • \(\bar y\) is the sample average/mean of the time series.
6. Special cases: By definition, \(\hat{\rho}(0) \equiv 1.0\)
Exceptions
Exception Type Condition
None N/A
Requirements
Namespace NumXLAPI
Class SFSDK
Scope Public
Lifetime Static
Package NumXLAPI.DLL
Examples

	
References
* Hamilton, J .D.; Time Series Analysis , Princeton University Press (1994), ISBN 0-691-04289-6
* Tsay, Ruey S.; Analysis of Financial Time Series John Wiley & SONS. (2005), ISBN 0-471-690740
* D. S.G. Pollock; Handbook of Time Series Analysis, Signal Processing, and Dynamics; Academic Press; Har/Cdr edition(Nov 17, 1999), ISBN: 125609906
* Box, Jenkins and Reisel; Time Series Analysis: Forecasting and Control; John Wiley & SONS.; 4th edition(Jun 30, 2008), ISBN: 470272848