Statistics and time-series analytics API

Fractional Autoregressive Integrated Moving Average (FARIMA) Model. More...

Functions

int __stdcall NDK_FARIMA_GOF (double *pData, size_t nSize, double mean, double sigma, double nIntegral, double *phis, size_t p, double *thetas, size_t q, GOODNESS_OF_FIT_FUNC retType, double *retVal)
 Computes the goodness of fit measure (e.g., log-likelihood function (LLF), AIC, etc.) of the estimated ARIMA model.
 
int __stdcall NDK_FARIMA_RESID (double *pData, size_t nSize, double mean, double sigma, double nIntegral, double *phis, size_t p, double *thetas, size_t q, WORD retType)
 CReturns the standardized residuals of a given FARIMA model.
 
int __stdcall NDK_FARIMA_PARAM (double *pData, size_t nSize, double *mean, double *sigma, double nIntegral, double *phis, size_t p, double *thetas, size_t q, MODEL_RETVAL_FUNC retType, size_t maxIter)
 Returns the initial (non-optimal), optimal or standard errors of the model's parameters.
 
int __stdcall NDK_FARIMA_SIM (double *pData, size_t nSize, double mean, double sigma, double nIntegral, double *phis, size_t p, double *thetas, size_t q, size_t nStep, size_t nSeed, double *retVal)
 Returns a simulated data series the underlying FARIMA process.
 
int __stdcall NDK_FARIMA_FORE (double *pData, size_t nSize, double mean, double sigma, double nIntegral, double *phis, size_t p, double *thetas, size_t q, size_t nStep, FORECAST_RETVAL_FUNC retType, double alpha, double *retVal)
 Calculates the out-of-sample forecast statistics.
 
int __stdcall NDK_FARIMA_FITTED (double *pData, size_t nSize, double mean, double sigma, double nIntegral, double *phis, size_t p, double *thetas, size_t q, FIT_RETVAL_FUNC retType)
 Returns an array of cells for the fitted values (i.e. mean, volatility and residuals)
 

Detailed Description

The ARIMA model is an extension of the ARMA model that applies to non-stationary time series (the kind of time series with one or more integrated unit roots). By definition, the auto-regressive integrated moving average (ARIMA) process is an ARMA process for the differenced time series:

\[(1-\phi_1 L - \phi_2 L^2 -\cdots - \phi_p L^p)(1-L)^d x_t - \phi_o= (1+\theta_1 L+\theta_2 L^2 + \cdots + \theta_q L^q)a_t \]

\[y_t = (1-L)^d x_t \]

Where:

Remarks
  1. The time series is homogeneous or equally spaced.
  2. The time series may include missing values (e.g. NaN) at either end.
  3. The variance of the shocks is constant or time-invariant.
  4. Assuming (i.e., \((1-L)^d x_t\)) is a stationary process with a long-run mean of \(\mu\), then taking the expectation from both sides, we can express \(\phi_o\) as follows:

    \[\phi_o = (1-\phi_1-\phi_2-\cdots -\phi_p)\mu\]

  5. Thus, the ARIMA (p, d, q) process can now be expressed as:

    \[\eqalign{ & (1 - {\phi _1}L - {\phi _2}{L^2} - \cdots - {\phi _p}{L^p})({y_t} - \mu ) \cr & = (1 + {\theta _1}L + {\theta _2}{L^2} + \cdots + {\theta _q}{L^q}){a_t}{z_t} \cr & = {y_t} - \mu (1 - {\phi _1}L - {\phi _2}{L^2} - \cdots - {\phi _p}{L^p}){z_t} \cr & = (1 + {\theta _1}L + {\theta _2}{L^2} + \cdots + {\theta _q}{L^q}){a_t} \cr}\]

  6. In sum, $z_t$ is the differenced signal after we subtract its long-run average.
  7. The order of an ARIMA process is solely determined by the order of the last lagged variable with a non-zero coefficient. In principle, you can have a fewer number of parameters than the order of the model. Consider the following ARIMA (12, 2) process:

    \[(1-\phi_1 L -\phi_{12} L^{12} ) (y_t-\mu) = (1+\theta_2 L^2 ) a_t\]

Related Links
References

Function Documentation

◆ NDK_FARIMA_FITTED()

int __stdcall NDK_FARIMA_FITTED ( double * pData,
size_t nSize,
double mean,
double sigma,
double nIntegral,
double * phis,
size_t p,
double * thetas,
size_t q,
FIT_RETVAL_FUNC retType )

Returns an array of cells for the fitted values (i.e. mean, volatility and residuals)

Parameters
[in,out]pData(Required) is the univariate time series data (a one dimensional array).
[in]nSize(Required) is the number of observations in pData.
[in]mean(Required) is the ARMA model mean (i.e. mu).
[in]sigma(Required) is the standard deviation of the model's residuals/innovations..
[in]nIntegral(Required) is the model's integration (fractional) order.
[in]phis(Required) are the parameters of the AR(p) component model (starting with the lowest lag).
[in]p(Required) is the number of elements in phis (order of AR component).
[in]thetas(Required) are the parameters of the MA(q) component model (starting with the lowest lag).
[in]q(Required) is the number of elements in thetas (order of MA component).
[in]retType(Required) s a switch to select a output type ( see FIT_RETVAL_FUNC).
Value Output Type
1 Fitted conditional mean
2 Fitted conditional volatility or standard deviation
3 Raw residuals (actual - fitted mean)
4 Standardized residuals - (actual - fitted mean)/fitted volatility.
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_SUCCESSsuccess
NDK_INVALID_ARGfailed (see remarks)
NDK_LOW_LICENSE_ARG_LIMITfailed (see remarks)
NDK_FAILEDfailed
Remarks
  1. The time series is homogeneous or equally spaced.
  2. The data sample may include one or more observation with missing values (i.e., NaN) at either end (not intermediary).
  3. The function removes any observations with missing values from the dataset before calculating.
  4. If the value of the nSize is zero, the function will fail and return NDK_INVALID_ARG.
  5. If the value of the retVal argument is NULL, the function will fails and return NDK_INVALID_ARG.
  6. The long-run mean can take any value or be omitted, in which a zero value is assumed.
  7. The integration order argument (d) must be a fractional number (between -1 and 1 (exclusive)).
  8. The residuals/innovations standard deviation ( \(\sigma\)) must be greater than zero.
  9. For the input argument - (phis):
    • The input argument is optional and can be omitted, so no AR component is included.
    • The order of the parameters starts with the lowest lag.
    • One or more parameters may have missing values (i.e., NaN).
    • The order of the last value solely determines the order of the AR component model in the array with a numeric value (vs. missing or error).
  10. For the input argument - (thetas):
    • The input argument is optional and can be omitted, so no MA component is included.
    • The order of the parameters starts with the lowest lag.
    • One or more values in the input argument can be missing (i.e., NaN).
    • The order of the last value solely determines the order of the MA component model in the array with a numeric value (vs. missing or error).
  11. Missing parameter values reduce the model's actual number of overall parameters, thus improving the AIC, BIC, and HQC statistics.
  12. In lite-license mode (e.g., expired license key), the size of the input data set is limited to a maximum of 25. If this limit is exceeded, the function will fail and return NDK_LOW_LICENSE_ARG_LIMIT.
Requirements
Requirement Value
Target Platform Windows
Header SFSDK.h (include Windows.h)
Library SFSDK.lib
DLL SFSDK.dll
SFLUC.dll
SFLOG.dll
Since
v1.63
See also

◆ NDK_FARIMA_FORE()

int __stdcall NDK_FARIMA_FORE ( double * pData,
size_t nSize,
double mean,
double sigma,
double nIntegral,
double * phis,
size_t p,
double * thetas,
size_t q,
size_t nStep,
FORECAST_RETVAL_FUNC retType,
double alpha,
double * retVal )

Calculates the out-of-sample forecast statistics.

Parameters
[in]pData(Required) is the univariate time series data (a one dimensional array).
[in]nSize(Required) is the number of observations in pData.
[in]mean(Required) is the ARMA model mean (i.e. mu).
[in]sigma(Required) is the standard deviation of the model's residuals/innovations..
[in]nIntegral(Required) is the model's integration (fractional) order.
[in]phis(Required) are the parameters of the AR(p) component model (starting with the lowest lag).
[in]p(Required) is the number of elements in phis (order of AR component).
[in]thetas(Required) are the parameters of the MA(q) component model (starting with the lowest lag).
[in]q(Required) is the number of elements in thetas (order of MA component).
[in]nStep(Required) is the forecast time/horizon (expressed in terms of steps beyond end of the time series).
[in]retType(Required) is a switch to select the type of value returned. (see FORECAST_RETVAL_FUNC).
Value Return
1 Mean Value (default)
2 Forecast standard error (aka local volatility)
2 Volatility term structure.
3 Lower limit of the forecast confidence interval.
4 Upper limit of the forecast confidence interval.
[in]alpha(Required) is the statistical significance level. If missing, a default of 5% is assumed.
[out]retVal(Required) is the calculated forecast value.
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_SUCCESSsuccess
NDK_INVALID_ARGfailed (see remarks)
NDK_LOW_LICENSE_ARG_LIMITfailed (see remarks)
NDK_FAILEDfailed
Remarks
  1. The time series is homogeneous or equally spaced.
  2. The data sample may include one or more observation with missing values (i.e., NaN) at either end (not intermediary).
  3. The function removes any observations with missing values from the dataset before calculating.
  4. If the value of the nSize is zero, the function will fail and return NDK_INVALID_ARG.
  5. If the value of the retVal argument is NULL, the function will fails and return NDK_INVALID_ARG.
  6. The long-run mean can take any value or be omitted, in which a zero value is assumed.
  7. The integration order argument (d) must be a fractional number (between -1 and 1 (exclusive)).
  8. The residuals/innovations standard deviation ( \(\sigma\)) must be greater than zero.
  9. For the input argument - (phis):
    • The input argument is optional and can be omitted, so no AR component is included.
    • The order of the parameters starts with the lowest lag.
    • One or more parameters may have missing values (i.e., NaN).
    • The order of the last value solely determines the order of the AR component model in the array with a numeric value (vs. missing or error).
  10. For the input argument - (thetas):
    • The input argument is optional and can be omitted, so no MA component is included.
    • The order of the parameters starts with the lowest lag.
    • One or more values in the input argument can be missing (i.e., NaN).
    • The order of the last value solely determines the order of the MA component model in the array with a numeric value (vs. missing or error).
  11. Missing parameter values reduce the model's actual number of overall parameters, thus improving the AIC, BIC, and HQC statistics.
  12. In lite-license mode (e.g., expired license key), the size of the input data set is limited to a maximum of 25. If this limit is exceeded, the function will fail and return NDK_LOW_LICENSE_ARG_LIMIT.
Since
v1.63
See also

◆ NDK_FARIMA_GOF()

int __stdcall NDK_FARIMA_GOF ( double * pData,
size_t nSize,
double mean,
double sigma,
double nIntegral,
double * phis,
size_t p,
double * thetas,
size_t q,
GOODNESS_OF_FIT_FUNC retType,
double * retVal )

Computes the log-likelihood ((LLF), Akaike Information Criterion (AIC) or other goodness of fit function of the FARIMA model.

Parameters
[in]pData(Required) is the univariate time series data (a one dimensional array).
[in]nSize(Required) is the number of observations in pData.
[in]mean(Required) is the ARMA model mean (i.e. mu).
[in]sigma(Required) is the standard deviation of the model's residuals/innovations..
[in]nIntegral(Required) is the model's integration (fractional) order.
[in]phis(Required) are the parameters of the AR(p) component model (starting with the lowest lag).
[in]p(Required) is the number of elements in phis (order of AR component).
[in]thetas(Required) are the parameters of the MA(q) component model (starting with the lowest lag).
[in]q(Required) is the number of elements in thetas (order of MA component).
[in]retType(Required) a switch to select a fitness measure ( see GOODNESS_OF_FIT_FUNC).
Value Return
1 Log-likelihood goodness of fit measure (LLF)
2 Akaike information criterion goodness of fit measure (AIC)
3 Bayesian or Schwartz information criterion goodness of fit measure (BIC)
4 Hannan-Quinn information criterion goodness of fit measure. (HQC)
5 R-squared goodness of fit measure (R^2)
6 Adjusted R-squared goodness of fit measure (Adj. R^2)
[out]retVal(Required) is a pointer to a variable to hold the calculated GOF statistics.
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_SUCCESSsuccess
NDK_INVALID_ARGfailed (see remarks)
NDK_LOW_LICENSE_ARG_LIMITfailed (see remarks)
NDK_FAILEDfailed
Remarks
  1. The time series is homogeneous or equally spaced.
  2. The data sample may include one or more observation with missing values (i.e., NaN) at either end (not intermediary).
  3. The function removes any observations with missing values from the dataset before calculating.
  4. If the value of the nSize is zero, the function will fail and return NDK_INVALID_ARG.
  5. If the value of the retVal argument is NULL, the function will fails and return NDK_INVALID_ARG.
  6. The long-run mean can take any value or be omitted, in which a zero value is assumed.
  7. The integration order argument (d) must be a fractional number (between -1 and 1 (exclusive)).
  8. The residuals/innovations standard deviation ( \(\sigma\)) must be greater than zero.
  9. For the input argument - (phis):
    • The input argument is optional and can be omitted, so no AR component is included.
    • The order of the parameters starts with the lowest lag.
    • One or more parameters may have missing values (i.e., NaN).
    • The order of the last value solely determines the order of the AR component model in the array with a numeric value (vs. missing or error).
  10. For the input argument - (thetas):
    • The input argument is optional and can be omitted, so no MA component is included.
    • The order of the parameters starts with the lowest lag.
    • One or more values in the input argument can be missing (i.e., NaN).
    • The order of the last value solely determines the order of the MA component model in the array with a numeric value (vs. missing or error).
  11. Missing parameter values reduce the model's actual number of overall parameters, thus improving the AIC, BIC, and HQC statistics.
  12. In lite-license mode (e.g., expired license key), the size of the input data set is limited to a maximum of 25. If this limit is exceeded, the function will fail and return NDK_LOW_LICENSE_ARG_LIMIT.
Requirements
Requirement Value
Target Platform Windows
Header SFSDK.h (include Windows.h)
Library SFSDK.lib
DLL SFSDK.dll
SFLUC.dll
SFLOG.dll
Since
v1.63
See also

◆ NDK_FARIMA_PARAM()

int __stdcall NDK_FARIMA_PARAM ( double * pData,
size_t nSize,
double * mean,
double * sigma,
double nIntegral,
double * phis,
size_t p,
double * thetas,
size_t q,
MODEL_RETVAL_FUNC retType,
size_t maxIter )

Returns the initial (non-optimal), optimal or standard errors of the model's parameters.

Parameters
[in,out]pData(Required) is the univariate time series data (a one dimensional array).
[in]nSize(Required) is the number of observations in pData.
[in,out]mean(Required) is the ARMA model mean (i.e. mu).
[in,out]sigma(Required) is the standard deviation of the model's residuals/innovations..
[in]nIntegral(Required) is the model's integration (fractional) order.
[in,out]phis(Required) are the parameters of the AR(p) component model (starting with the lowest lag).
[in]p(Required) is the number of elements in phis (order of AR component).
[in,out]thetas(Required) are the parameters of the MA(q) component model (starting with the lowest lag).
[in]q(Required) is the number of elements in thetas (order of MA component).
[in]retType(Required) is a switch to select the type of value returned: 1= Quick Guess, 2=Calibrated, 3= Std. Errors ( see MODEL_RETVAL_FUNC).
Value Type
1 Quick guess (non-optimal) of parameters values
2 Run a calibration process to find optimal values for the model's parameters
3 Compute the standard error of the parameters' values
[in]maxIter(Required) is the maximum number of iterations used to calibrate the model. If missing or less than 100, the default maximum of 100 is assumed.
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_SUCCESSsuccess
NDK_INVALID_ARGfailed (see remarks)
NDK_LOW_LICENSE_ARG_LIMITfailed (see remarks)
NDK_FAILEDfailed
Remarks
  1. The time series is homogeneous or equally spaced.
  2. The data sample may include one or more observation with missing values (i.e., NaN) at either end (not intermediary).
  3. The function removes any observations with missing values from the dataset before calculating.
  4. If the value of the nSize is zero, the function will fail and return NDK_INVALID_ARG.
  5. If the value of the retVal argument is NULL, the function will fails and return NDK_INVALID_ARG.
  6. The long-run mean can take any value or be omitted, in which a zero value is assumed.
  7. The integration order argument (d) must be a fractional number (between -1 and 1 (exclusive)).
  8. The residuals/innovations standard deviation ( \(\sigma\)) must be greater than zero.
  9. For the input argument - (phis):
    • The input argument is optional and can be omitted, so no AR component is included.
    • The order of the parameters starts with the lowest lag.
    • One or more parameters may have missing values (i.e., NaN).
    • The order of the last value solely determines the order of the AR component model in the array with a numeric value (vs. missing or error).
  10. For the input argument - (thetas):
    • The input argument is optional and can be omitted, so no MA component is included.
    • The order of the parameters starts with the lowest lag.
    • One or more values in the input argument can be missing (i.e., NaN).
    • The order of the last value solely determines the order of the MA component model in the array with a numeric value (vs. missing or error).
  11. Missing parameter values reduce the model's actual number of overall parameters, thus improving the AIC, BIC, and HQC statistics.
  12. In lite-license mode (e.g., expired license key), the size of the input data set is limited to a maximum of 25. If this limit is exceeded, the function will fail and return NDK_LOW_LICENSE_ARG_LIMIT.
Requirements
Requirement Value
Target Platform Windows
Header SFSDK.h (include Windows.h)
Library SFSDK.lib
DLL SFSDK.dll
SFLUC.dll
SFLOG.dll
Since
v1.63
See also

◆ NDK_FARIMA_RESID()

int __stdcall NDK_FARIMA_RESID ( double * pData,
size_t nSize,
double mean,
double sigma,
double nIntegral,
double * phis,
size_t p,
double * thetas,
size_t q,
WORD retType )

Returns the standardized residuals of a given FARIMA model

Parameters
[in,out]pData(Required) is the univariate time series data (a one dimensional array).
[in]nSize(Required) is the number of observations in pData.
[in]mean(Required) is the ARMA model mean (i.e. mu).
[in]sigma(Required) is the standard deviation of the model's residuals/innovations..
[in]nIntegral(Required) is the model's integration (fractional) order.
[in]phis(Required) are the parameters of the AR(p) component model (starting with the lowest lag).
[in]p(Required) is the number of elements in phis (order of AR component).
[in]thetas(Required) are the parameters of the MA(q) component model (starting with the lowest lag).
[in]q(Required) is the number of elements in thetas (order of MA component).
[in]retType(Required) is a switch to select a residuals-type:raw or standardized. see RESID_RETVAL_FUNC
Value Residuals Type
0 Standardized residuals
1 Raw Residuals
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_SUCCESSsuccess
NDK_INVALID_ARGfailed (see remarks)
NDK_LOW_LICENSE_ARG_LIMITfailed (see remarks)
NDK_FAILEDfailed
Remarks
  1. The time series is homogeneous or equally spaced.
  2. The data sample may include one or more observation with missing values (i.e., NaN) at either end (not intermediary).
  3. The function removes any observations with missing values from the dataset before calculating.
  4. If the value of the nSize is zero, the function will fail and return NDK_INVALID_ARG.
  5. If the value of the retVal argument is NULL, the function will fails and return NDK_INVALID_ARG.
  6. The long-run mean can take any value or be omitted, in which a zero value is assumed.
  7. The integration order argument (d) must be a fractional number (between -1 and 1 (exclusive)).
  8. The residuals/innovations standard deviation ( \(\sigma\)) must be greater than zero.
  9. For the input argument - (phis):
    • The input argument is optional and can be omitted, so no AR component is included.
    • The order of the parameters starts with the lowest lag.
    • One or more parameters may have missing values (i.e., NaN).
    • The order of the last value solely determines the order of the AR component model in the array with a numeric value (vs. missing or error).
  10. For the input argument - (thetas):
    • The input argument is optional and can be omitted, so no MA component is included.
    • The order of the parameters starts with the lowest lag.
    • One or more values in the input argument can be missing (i.e., NaN).
    • The order of the last value solely determines the order of the MA component model in the array with a numeric value (vs. missing or error).
  11. Missing parameter values reduce the model's actual number of overall parameters, thus improving the AIC, BIC, and HQC statistics.
  12. In lite-license mode (e.g., expired license key), the size of the input data set is limited to a maximum of 25. If this limit is exceeded, the function will fail and return NDK_LOW_LICENSE_ARG_LIMIT.
Requirements
Requirement Value
Target Platform Windows
Header SFSDK.h (include Windows.h)
Library SFSDK.lib
DLL SFSDK.dll
SFLUC.dll
SFLOG.dll
Since
v1.63
See also

◆ NDK_FARIMA_SIM()

int __stdcall NDK_FARIMA_SIM ( double * pData,
size_t nSize,
double mean,
double sigma,
double nIntegral,
double * phis,
size_t p,
double * thetas,
size_t q,
size_t nStep,
size_t nSeed,
double * retVal )

Returns a simulated data series the underlying FARIMA process.

Parameters
[in]pData(Required) is the univariate time series data (a one dimensional array).
[in]nSize(Required) is the number of observations in pData.
[in]mean(Required) is the ARMA model mean (i.e. mu).
[in]sigma(Required) is the standard deviation of the model's residuals/innovations..
[in]nIntegral(Required) is the model's integration (fractional) order.
[in]phis(Required) are the parameters of the AR(p) component model (starting with the lowest lag).
[in]p(Required) is the number of elements in phis (order of AR component).
[in]thetas(Required) are the parameters of the MA(q) component model (starting with the lowest lag).
[in]q(Required) is the number of elements in thetas (order of MA component).
[in]nStep(Required) is the number of future steps to simulate for.
[in]nSeed(Required) is an unsigned integer for setting up the random number generators.
[out]retVal(Required) is the calculated simulation value.
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_SUCCESSsuccess
NDK_INVALID_ARGfailed (see remarks)
NDK_LOW_LICENSE_ARG_LIMITfailed (see remarks)
NDK_FAILEDfailed
Remarks
  1. The time series is homogeneous or equally spaced.
  2. The data sample may include one or more observation with missing values (i.e., NaN) at either end (not intermediary).
  3. The function removes any observations with missing values from the dataset before calculating.
  4. If the value of the nSize is zero, the function will fail and return NDK_INVALID_ARG.
  5. If the value of the retVal argument is NULL, the function will fails and return NDK_INVALID_ARG.
  6. The long-run mean can take any value or be omitted, in which a zero value is assumed.
  7. The integration order argument (d) must be a fractional number (between -1 and 1 (exclusive)).
  8. The residuals/innovations standard deviation ( \(\sigma\)) must be greater than zero.
  9. For the input argument - (phis):
    • The input argument is optional and can be omitted, so no AR component is included.
    • The order of the parameters starts with the lowest lag.
    • One or more parameters may have missing values (i.e., NaN).
    • The order of the last value solely determines the order of the AR component model in the array with a numeric value (vs. missing or error).
  10. For the input argument - (thetas):
    • The input argument is optional and can be omitted, so no MA component is included.
    • The order of the parameters starts with the lowest lag.
    • One or more values in the input argument can be missing (i.e., NaN).
    • The order of the last value solely determines the order of the MA component model in the array with a numeric value (vs. missing or error).
  11. Missing parameter values reduce the model's actual number of overall parameters, thus improving the AIC, BIC, and HQC statistics.
  12. In lite-license mode (e.g., expired license key), the size of the input data set is limited to a maximum of 25. If this limit is exceeded, the function will fail and return NDK_LOW_LICENSE_ARG_LIMIT.
Requirements
Requirement Value
Target Platform Windows
Header SFSDK.h (include Windows.h)
Library SFSDK.lib
DLL SFSDK.dll
SFLUC.dll
SFLOG.dll
Since
v1.63
See also