Statistics and time-series analytics API

Generalized Autoregressive Conditional Heteroskedasticity (GARCH) Model. More...

Functions

int __stdcall NDK_GARCH_GOF (double *pData, size_t nSize, double mu, const double *Alphas, size_t p, const double *Betas, size_t q, WORD nInnovationType, double nu, WORD retType, double *retVal)
 Computes the log-likelihood (LLF), Akaike Information Criterion (AIC) or other goodness of fit functions of the ARMA model.
 
int __stdcall NDK_GARCH_RESID (double *pData, size_t nSize, double mu, const double *Alphas, size_t p, const double *Betas, size_t q, WORD nInnovationType, double nu, WORD retType)
 Returns an array of cells for the standardized residuals of a given GARCH model.
 
int __stdcall NDK_GARCH_PARAM (double *pData, size_t nSize, double *mu, double *Alphas, size_t p, double *Betas, size_t q, WORD nInnovationType, double *nu, WORD retType, size_t maxIter)
 Returns an array of cells for the initial (non-optimal), optimal or standard errors of the model's parameters.
 
int __stdcall NDK_GARCH_SIM (double mu, const double *Alphas, size_t p, const double *Betas, size_t q, WORD nInnovationType, double nu, double *pData, size_t nSize, double *pSigmas, size_t nSigmaSize, UINT nSeed, double *retArray, size_t nSteps)
 Returns a simulated data series the underlying GARCH process.
 
int __stdcall NDK_GARCH_FORE (double *pData, size_t nSize, double *pVols, size_t nVolSize, double mu, const double *Alphas, size_t p, const double *Betas, size_t q, WORD nInnovationType, double nu, size_t nSteps, WORD retType, double alpha, double *retVal)
 Calculates the out-of-sample forecast statistics.
 
int __stdcall NDK_GARCH_FITTED (double *pData, size_t nSize, double mu, const double *Alphas, size_t p, const double *Betas, size_t q, WORD nInnovationType, double nu, WORD retType)
 Returns an array of cells for the fitted values (i.e. mean, volatility and residuals).
 
int __stdcall NDK_GARCH_LRVAR (double mu, const double *Alphas, size_t p, const double *Betas, size_t q, WORD nInnovationType, double nu, double *retVal)
 Calculates the long-run average volatility for the given GARCH model.
 
int __stdcall NDK_GARCH_VALIDATE (double mu, const double *Alphas, size_t p, const double *Betas, size_t q, WORD nInnovationType, double nu)
 Examines the model's parameters for stability constraints (e.g. variance stationary, positive variance, etc.).
 

Detailed Description

If an autoregressive moving average model (ARMA model) is assumed for the error variance, the model is a generalized autoregressive conditional heteroskedasticity (GARCH, Bollerslev(1986)) model.

\[x_t = \mu + a_t \]

\[\sigma_t^2 = \alpha_o + \sum_{i=1}^p {\alpha_i a_{t-i}^2}+\sum_{j=1}^q{\beta_j \sigma_{t-j}^2} \]

\[a_t = \sigma_t \times \epsilon_t \]

\[\epsilon_t \sim P_{\nu}(0,1) \]

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 number of parameters in the input argument - alpha - determines the order of the ARCH component model.
  4. The number of parameters in the input argument - beta - determines the order of the GARCH component model.
  5. Clustering: a large \(a_{t-1}^2\) or \(\sigma_{t-1}^2\) gives rise to a large \(\sigma_t^2\). This means a large \(a_{t-1}^2\) tends to be followed by another large \(a_{t}^2\), generating the well-known behavior of volatility clustering in financial time series.
  6. Fat-tails: The tail distribution of a GARCH(p, q) process is heavier than that of a normal distribution.
  7. Mean-reversion: GARCH provides a simple parametric function that can be used to describe the volatility evolution. The model converges to the unconditional variance of \(a_t\).
  8. In financial markets, negative returns have a higher influence on volatility levels than positive ones do. The GARCH model does not have different treatments based on shock/error term direction.
  9. GARCH(p, q) model with normal-distributed innovation has p+q+2 estimated parameters.
  10. GARCH(p, q) model with GED or student's t-distributed innovation has p+q+3 estimated parameters.
Related Links
References

Function Documentation

◆ NDK_GARCH_FITTED()

int __stdcall NDK_GARCH_FITTED ( double * pData,
size_t nSize,
double mu,
const double * Alphas,
size_t p,
const double * Betas,
size_t q,
WORD nInnovationType,
double nu,
WORD retType )

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

Parameters
[in,out]pData(Required) The univariate time series data.
[in]nSize(Required) The number of observations in pData.
[in]mu(Optional) The GARCH model conditional mean (i.e. mu).
[in]Alphas(Optional) The parameters of the ARCH(p) component model (starting with the lowest lag).
[in]p(Optional) The number of elements in Alphas array.
[in]Betas(Optional) The parameters of the GARCH(q) component model (starting with the lowest lag).
[in]q(Optional) The number of elements in Betas array.
[in]nInnovationType(Optional) is the probability distribution function of the innovations/residuals (see INNOVATION_TYPE)
Value Distribution
1 Gaussian Distribution (default)
2 Student's T-Distribution
3 Generalized Error Distribution (GED)
[in]nu(Optional) the shape factor (or degrees of freedom) of the innovations/residuals probability distribution function.
[in]retType(Required) A switch to select the desired 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 underlying model is described here.
  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. 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_GARCH_FORE()

int __stdcall NDK_GARCH_FORE ( double * pData,
size_t nSize,
double * pVols,
size_t nVolSize,
double mu,
const double * Alphas,
size_t p,
const double * Betas,
size_t q,
WORD nInnovationType,
double nu,
size_t nSteps,
WORD retType,
double alpha,
double * retVal )

Calculates the out-of-sample forecast statistics.

Parameters
[in]pData(Required) The univariate time series data.
[in]nSize(Required) The number of observations in pData.
[in]pVols(Required) the univariate time series data (a one dimensional array of cells (e.g. rows or columns)) of the last q realized volatilities.
[in]nVolSize(Required) the number of elements in sigmas. Only the latest q observations are used.
[in]mu(Optional) The GARCH model conditional mean (i.e. mu).
[in]Alphas(Optional) The parameters of the ARCH(p) component model (starting with the lowest lag).
[in]p(Optional) The number of elements in Alphas array.
[in]Betas(Optional) The parameters of the GARCH(q) component model (starting with the lowest lag).
[in]q(Optional) The number of elements in Betas array.
[in]nInnovationType(Optional) is the probability distribution function of the innovations/residuals (see INNOVATION_TYPE)
Value Distribution
1 Gaussian Distribution (default)
2 Student's T-Distribution
3 Generalized Error Distribution (GED)
[in]nu(Optional) the shape factor (or degrees of freedom) of the innovations/residuals probability distribution function.
[in]nSteps(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 underlying model is described here.
  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. 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_GARCH_GOF()

int __stdcall NDK_GARCH_GOF ( double * pData,
size_t nSize,
double mu,
const double * Alphas,
size_t p,
const double * Betas,
size_t q,
WORD nInnovationType,
double nu,
WORD 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) The univariate time series data.
[in]nSize(Required) The number of observations in pData.
[in]mu(Optional) The GARCH model conditional mean (i.e. mu).
[in]Alphas(Optional) The parameters of the ARCH(p) component model (starting with the lowest lag).
[in]p(Optional) The number of elements in Alphas array.
[in]Betas(Optional) The parameters of the GARCH(q) component model (starting with the lowest lag).
[in]q(Optional) The number of elements in Betas array.
[in]nInnovationType(Optional) is the probability distribution function of the innovations/residuals (see INNOVATION_TYPE)
Value Distribution
1 Gaussian Distribution (default)
2 Student's T-Distribution
3 Generalized Error Distribution (GED)
[in]nu(Optional) the shape factor (or degrees of freedom) of the innovations/residuals probability distribution function.
[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 underlying model is described here.
  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 maximum likelihood estimation (MLE) is a statistical method for fitting a model to the data and provides estimates for the model's parameters.
  7. 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_GARCH_LRVAR()

int __stdcall NDK_GARCH_LRVAR ( double mu,
const double * Alphas,
size_t p,
const double * Betas,
size_t q,
WORD nInnovationType,
double nu,
double * retVal )

Calculates the long-run average volatility for the given GARCH model

Parameters
[in]mu(Optional) The GARCH model conditional mean (i.e. mu).
[in]Alphas(Optional) The parameters of the ARCH(p) component model (starting with the lowest lag).
[in]p(Optional) The number of elements in Alphas array.
[in]Betas(Optional) The parameters of the GARCH(q) component model (starting with the lowest lag).
[in]q(Optional) The number of elements in Betas array.
[in]nInnovationType(Optional) is the probability distribution function of the innovations/residuals (see INNOVATION_TYPE)
Value Distribution
1 Gaussian Distribution (default)
2 Student's T-Distribution
3 Generalized Error Distribution (GED)
[in]nu(Optional) the shape factor (or degrees of freedom) of the innovations/residuals probability distribution function.
[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 underlying model is described here.
  2. If the value of the retVal argument is NULL, the function will fails and return NDK_INVALID_ARG.
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_GARCH_PARAM()

int __stdcall NDK_GARCH_PARAM ( double * pData,
size_t nSize,
double * mu,
double * Alphas,
size_t p,
double * Betas,
size_t q,
WORD nInnovationType,
double * nu,
WORD retType,
size_t maxIter )

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

Parameters
[in,out]pData(Required) The univariate time series data.
[in]nSize(Required) The number of observations in pData.
[in,out]mu(Optional) The GARCH model conditional mean (i.e. mu).
[in,out]Alphas(Optional) The parameters of the ARCH(p) component model (starting with the lowest lag).
[in]p(Optional) The number of elements in Alphas array.
[in,out]Betas(Optional) The parameters of the GARCH(q) component model (starting with the lowest lag).
[in]q(Optional) The number of elements in Betas array.
[in]nInnovationType(Optional) is the probability distribution function of the innovations/residuals (see INNOVATION_TYPE)
Value Distribution
1 Gaussian Distribution (default)
2 Student's T-Distribution
3 Generalized Error Distribution (GED)
[in,out]nu(Optional) the shape factor (or degrees of freedom) of the innovations/residuals probability distribution function.
[in]retType(Required) 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 underlying model is described here.
  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. 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_GARCH_RESID()

int __stdcall NDK_GARCH_RESID ( double * pData,
size_t nSize,
double mu,
const double * Alphas,
size_t p,
const double * Betas,
size_t q,
WORD nInnovationType,
double nu,
WORD retType )

Returns an array of cells for the standardized residuals of a given GARCH model .

Parameters
[in,out]pData(Required) The univariate time series data.
[in]nSize(Required) The number of observations in pData.
[in]mu(Optional) The GARCH model conditional mean (i.e. mu).
[in]Alphas(Optional) The parameters of the ARCH(p) component model (starting with the lowest lag).
[in]p(Optional) The number of elements in Alphas array.
[in]Betas(Optional) The parameters of the GARCH(q) component model (starting with the lowest lag).
[in]q(Optional) The number of elements in Betas array.
[in]nInnovationType(Optional) is the probability distribution function of the innovations/residuals (see INNOVATION_TYPE)
Value Distribution
1 Gaussian Distribution (default)
2 Student's T-Distribution
3 Generalized Error Distribution (GED)
[in]nu(Optional) the shape factor (or degrees of freedom) of the innovations/residuals probability distribution function.
[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 underlying model is described here.
  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. 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_GARCH_SIM()

int __stdcall NDK_GARCH_SIM ( double mu,
const double * Alphas,
size_t p,
const double * Betas,
size_t q,
WORD nInnovationType,
double nu,
double * pData,
size_t nSize,
double * pSigmas,
size_t nSigmaSize,
UINT nSeed,
double * retArray,
size_t nSteps )

Returns a simulated data series the underlying GARCH process.

Parameters
[in]mu(Optional) The GARCH model conditional mean (i.e. mu).
[in]Alphas(Optional) The parameters of the ARCH(p) component model (starting with the lowest lag).
[in]p(Optional) The number of elements in Alphas array.
[in]Betas(Optional) The parameters of the GARCH(q) component model (starting with the lowest lag).
[in]q(Optional) The number of elements in Betas array.
[in]nInnovationType(Optional) is the probability distribution function of the innovations/residuals (see INNOVATION_TYPE)
Value Distribution
1 Gaussian Distribution (default)
2 Student's T-Distribution
3 Generalized Error Distribution (GED)
[in]nu(Optional) the shape factor (or degrees of freedom) of the innovations/residuals probability distribution function.
[in]pData(Optional) he univariate time series of the latest observations (a one dimensional array).
[in]nSize(Required) The number of observations in pData.
[in]pSigmas(Optional) The univariate time series of the latest observations (a one dimensional array).
[in]nSigmaSize(Required) The number of observations in pSigmas.
[in]nSeed(Required) is an unsigned integer for setting up the random number generators.
[out]retArray(Required) is the calculated simulation value.
[in]nSteps(Required) is the simulation time/horizon (expressed in terms of steps beyond end of the time series).
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 underlying model is described here.
  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. 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_GARCH_VALIDATE()

int __stdcall NDK_GARCH_VALIDATE ( double mu,
const double * Alphas,
size_t p,
const double * Betas,
size_t q,
WORD nInnovationType,
double nu )

Examines the model's parameters for stability constraints (e.g. variance stationary, positive variance, etc.).

Parameters
[in]mu(Optional) The GARCH model conditional mean (i.e. mu).
[in]Alphas(Optional) The parameters of the ARCH(p) component model (starting with the lowest lag).
[in]p(Optional) The number of elements in Alphas array.
[in]Betas(Optional) The parameters of the GARCH(q) component model (starting with the lowest lag).
[in]q(Optional) The number of elements in Betas array.
[in]nInnovationType(Optional) is the probability distribution function of the innovations/residuals (see INNOVATION_TYPE)
Value Distribution
1 Gaussian Distribution (default)
2 Student's T-Distribution
3 Generalized Error Distribution (GED)
[in]nu(Optional) the shape factor (or degrees of freedom) of the innovations/residuals probability distribution function.
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 underlying model is described here.
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