Statistics and time-series analytics API

Autoregressive Integrated Moving Average (ARIMA) Model. More...

Functions

int __stdcall NDK_ARIMA_VALIDATE (double mean, double sigma, WORD, double *phis, size_t p, double *thetas, size_t q)
 Examines the model's parameters for stability constraints (e.g. stationarity, invertibility, causality, etc.).
 
int __stdcall NDK_ARIMA_GOF (double *pData, size_t nSize, double mean, double sigma, WORD 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_ARIMA_PARAM (double *pData, size_t nSize, double *mean, double *sigma, WORD nIntegral, double *phis, size_t p, double *thetas, size_t q, MODEL_RETVAL_FUNC retType, size_t maxIter)
 Returns values for the quick guess, optimal (calibrated), or standard errors of the values of the model's parameters.
 
int __stdcall NDK_ARIMA_SIM (double mean, double sigma, WORD nIntegral, double *phis, size_t p, double *thetas, size_t q, double *pData, size_t nSize, UINT nSeed, double *retVal, size_t nSteps)
 Calculates the out-of-sample simulated values.
 
int __stdcall NDK_ARIMA_FORE (double *pData, size_t nSize, double mean, double sigma, WORD 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 conditional forecast (i.e. mean, error, and confidence interval).
 
int __stdcall NDK_ARIMA_FITTED (double *pData, size_t nSize, double mean, double sigma, WORD nIntegral, double *phis, size_t p, double *thetas, size_t q, FIT_RETVAL_FUNC retType)
 Returns the in-sample model fitted values of the conditional mean, volatility or 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 variance of the shocks is constant or time-invariant.
  2. 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\]

  3. 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}\]

  4. In sum, $z_t$ is the differenced signal after we subtract its long-run average.
  5. 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_ARIMA_FITTED()

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

Returns the in-sample model fitted values of the conditional mean, volatility or residuals.

Parameters
[in,out]pData(Required) is the univariate time series data (a one dimensional array).
[in]nSize(Required) iis the number of observations in pData.
[in]mean(Optional) is the ARMA model mean (i.e. mu).
[in]sigma(Optional) iis the standard deviation of the model's residuals/innovations.
[in]nIntegral(Optional) is the integration order.
[in]phis(Optional) are the parameters of the AR(p) component model (starting with the lowest lag).
[in]p(Optional) is the number of elements in phis (order of AR component).
[in]thetas(Optional) are the parameters of the MA(q) component model (starting with the lowest lag).
[in]q(Optional) 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 positive integer.
  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
Since
v1.63
See also

◆ NDK_ARIMA_FORE()

int __stdcall NDK_ARIMA_FORE ( double * pData,
size_t nSize,
double mean,
double sigma,
WORD 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 conditional forecast (i.e. mean, error, and confidence interval).

Parameters
[in]pData(Required) is the univariate time series data.
[in]nSize(Required) iis the number of observations in pData.
[in]mean(Optional) is the ARMA model mean (i.e. mu).
[in]sigma(Optional) iis the standard deviation of the model's residuals/innovations.
[in]nIntegral(Optional) is the integration order.
[in]phis(Optional) are the parameters of the AR(p) component model (starting with the lowest lag).
[in]p(Optional) is the number of elements in phis (order of AR component).
[in]thetas(Optional) are the parameters of the MA(q) component model (starting with the lowest lag).
[in]q(Optional) is the number of elements in thetas (order of MA component).
[in]nStep(Optional) 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 (FORECAST_MEAN, FORECAST_STDEV , ..). (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 or confidence level (i.e. alpha). If missing or omitted, an alpha value of 5% is assumed.
[out]retVal(Required) is a pointer to a variable to hold the calculated forecast 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 positive integer.
  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
Since
v1.63
See also

◆ NDK_ARIMA_GOF()

int __stdcall NDK_ARIMA_GOF ( double * pData,
size_t nSize,
double mean,
double sigma,
WORD 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 functions of the ARMA model.

Parameters
[in]pData(Required) is the univariate time series data.
[in]nSize(Required) iis the number of observations in pData.
[in]mean(Optional) is the ARMA model mean (i.e. mu).
[in]sigma(Optional) iis the standard deviation of the model's residuals/innovations.
[in]nIntegral(Optional) is the integration order.
[in]phis(Optional) are the parameters of the AR(p) component model (starting with the lowest lag).
[in]p(Optional) is the number of elements in phis (order of AR component).
[in]thetas(Optional) are the parameters of the MA(q) component model (starting with the lowest lag).
[in]q(Optional) is the number of elements in thetas (order of MA component).
[in]retType(Required) is a switch to select the return output (1 = Mean Value (default), 2 = Std Error, 3 = Test Score, 4 = P-Value, 5 = Upper Value, 6 = Lower Value). ( see GOODNESS_OF_FIT_FUNC)
Value Return
1 Mean Value (default)
2 Standard Error.
3 Upper Limit.
4 Lower Limit.
[out]retVal(Required) is a pointer to a variable to hold the calculated test 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 positive integer.
  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
Since
v1.63
See also

◆ NDK_ARIMA_PARAM()

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

Returns values for the quick guess, optimal (calibrated), or standard errors of the values of the model's parameters.

Parameters
[in]pData(Required) is the univariate time series data.
[in]nSize(Required) iis the number of observations in pData.
[in,out]mean(Optional) is the ARMA model mean (i.e. mu).
[in,out]sigma(Optional) iis the standard deviation of the model's residuals/innovations.
[in]nIntegral(Optional) is the integration order.
[in,out]phis(Optional) are the parameters of the AR(p) component model (starting with the lowest lag).
[in]p(Optional) is the number of elements in phis (order of AR component).
[in,out]thetas(Optional) are the parameters of the MA(q) component model (starting with the lowest lag).
[in]q(Optional) 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 none (i.e., 0), 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 positive integer.
  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
Since
v1.63
See also

◆ NDK_ARIMA_SIM()

int __stdcall NDK_ARIMA_SIM ( double mean,
double sigma,
WORD nIntegral,
double * phis,
size_t p,
double * thetas,
size_t q,
double * pData,
size_t nSize,
UINT nSeed,
double * retVal,
size_t nSteps )

Calculates the out-of-sample simulated values.

Parameters
[in]mean(Optional) is the ARMA model mean (i.e. mu).
[in]sigma(Optional) is the standard deviation of the model's residuals/innovations.
[in]nIntegral(Optional) is the integration order.
[in]phis(Optional) are the parameters of the AR(p) component model (starting with the lowest lag).
[in]p(Optional) is the number of elements in phis (order of AR component).
[in]thetas(Optional) are the parameters of the MA(q) component model (starting with the lowest lag).
[in]q(Optional) is the number of elements in thetas (order of MA component).
[in]pData(Required) The values of the latest (most recent) observations.
[in]nSize(Required) is the number of observations in pData.
[in]nSeed(Required) is an unsigned integer to initialize the psuedorandom number generator.
[out]retVal(Required) is the output array to hold nSteps future simulations.
[in]nSteps(Required) is the number of future steps to simulate for.
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 positive integer.
  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
Since
v1.63
See also

◆ NDK_ARIMA_VALIDATE()

int __stdcall NDK_ARIMA_VALIDATE ( double mean,
double sigma,
WORD nIntegral,
double * phis,
size_t p,
double * thetas,
size_t q )

Examines the model's parameters for stability constraints (e.g. stationarity, invertibility, causality, etc.).

Parameters
[in]mean(Optional) is the ARMA model mean (i.e. mu).
[in]sigma(Optional) is the standard deviation of the model's residuals/innovations.
[in]nIntegral(Optional) is the integration order.
[in]phis(Optional) are the parameters of the AR(p) component model (starting with the lowest lag).
[in]p(Optional) is the number of elements in phis (order of AR component).
[in]thetas(Optional) are the parameters of the MA(q) component model (starting with the lowest lag).
[in]q(Optional) is the number of elements in thetas (order of MA component).
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_TRUEmodel is stable
NDK_FALSEmodel is instable
NDK_INVALID_ARGfailed (see remarks)
NDK_FAILEDfailed
Remarks
  1. The long-run mean can take any value or be omitted, in which a zero value is assumed.
  2. The integration order argument (d) must be a positive integer.
  3. 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).
  4. 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).
  5. Missing parameter values reduce the model's actual number of overall parameters, thus improving the AIC, BIC, and HQC statistics.
Requirements
Requirement Value
Target Platform Windows
Header SFSDK.h (include Windows.h)
Library SFSDK.lib
DLL SFSDK.dll
Since
v1.63
See also