Statistics and time-series analytics API

Seasonal Autoregressive Integrated Moving Average (SARIMA) Model. More...

Functions

int __stdcall NDK_SARIMA_GOF (double *pData, size_t nSize, double mean, double sigma, WORD nIntegral, double *phis, size_t p, double *thetas, size_t q, WORD nSIntegral, WORD nSPeriod, double *sPhis, size_t sP, double *sThetas, size_t sQ, GOODNESS_OF_FIT_FUNC retType, double *retVal)
 
int __stdcall NDK_SARIMA_PARAM (double *pData, size_t nSize, double *mean, double *sigma, WORD nIntegral, double *phis, size_t p, double *thetas, size_t q, WORD nSIntegral, WORD nSPeriod, double *sPhis, size_t sP, double *sThetas, size_t sQ, MODEL_RETVAL_FUNC retType, size_t maxIter)
 
int __stdcall NDK_SARIMA_SIM (double mean, double sigma, WORD nIntegral, double *phis, size_t p, double *thetas, size_t q, WORD nSIntegral, WORD nSPeriod, double *sPhis, size_t sP, double *sThetas, size_t sQ, double *pData, size_t nSize, size_t nSeed, double *retVal, size_t nStep)
 
int __stdcall NDK_SARIMA_FORE (double *pData, size_t nSize, double mean, double sigma, WORD nIntegral, double *phis, size_t p, double *thetas, size_t q, WORD nSIntegral, WORD nSPeriod, double *sPhis, size_t sP, double *sThetas, size_t sQ, size_t nStep, FORECAST_RETVAL_FUNC retType, double alpha, double *retVal)
 
int __stdcall NDK_SARIMA_FITTED (double *pData, size_t nSize, double mean, double sigma, WORD nIntegral, double *phis, size_t p, double *thetas, size_t q, WORD nSIntegral, WORD nSPeriod, double *sPhis, size_t sP, double *sThetas, size_t sQ, FIT_RETVAL_FUNC retType)
 
int __stdcall NDK_SARIMA_VALIDATE (double mean, double sigma, WORD nIntegral, double *phis, size_t p, double *thetas, size_t q, WORD nSIntegral, WORD nSPeriod, double *sPhis, size_t sP, double *sThetas, size_t sQ)
 

Detailed Description

The SARIMA model is an extension of the ARIMA model, often used when we suspect a model may have a seasonal effect.

By definition, the seasonal auto-regressive integrated moving average - SARIMA(p, d, q)(P, D, Q)s - process is a multiplicative of two ARMA processes of the differenced time series.

\[(1-\sum_{i=1}^p {\phi_i L^i})(1-\sum_{j=1}^P {\Phi_j L^{j \times s}})(1-L)^d (1-L^s)^D x_t = (1+\sum_{i=1}^q {\theta_i L^i})(1+\sum_{j=1}^Q {\Theta_j L^{j \times s}}) a_t\]

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

Where:

Assuming \(y_t\) follows 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)(1-\Phi_1-\Phi_2-\cdots-\Phi_P)\]

Thus, the SARIMA(p, d, q)(P, D, Q)s process can now be expressed as:

\[(1-\sum_{i=1}^p {\phi_i L^i})(1-\sum_{j=1}^P {\Phi_j L^{j \times s}}) (y_t -\mu) = (1+\sum_{i=1}^q {\theta_i L^i})(1+\sum_{j=1}^Q {\Theta_j L^{j \times s}}) a_t\]

\[z_t=y_t-\mu \]

\[(1-\sum_{i=1}^p {\phi_i L^i})(1-\sum_{j=1}^P {\Phi_j L^{j \times s}}) z_t = (1+\sum_{i=1}^q {\theta_i L^i})(1+\sum_{j=1}^Q {\Theta_j L^{j \times s}}) a_t\]

In sum, \(z_t\) is the differenced signal after we subtract its long-run average.

Remarks
  1. The variance of the shocks is constant or time-invariant.
  2. The order of the seasonal or non-seasonal AR (or MA) component is solely determined by the order of the last lagged variable with a non-zero coefficient. In principle, you can have fewer parameters than the order of the component. Consider the following SARIMA(0,1,1) (0,1,1)12 process:

    \[(1-L)(1-L^{12})x_t-\mu = (1+\theta L)(1+\Theta L^{12})a_t \]

Note
This is the AIRLINE model, a special case of the SARIMA model.
Related Links
References

Function Documentation

◆ NDK_SARIMA_FITTED()

int __stdcall NDK_SARIMA_FITTED ( double * pData,
size_t nSize,
double mean,
double sigma,
WORD nIntegral,
double * phis,
size_t p,
double * thetas,
size_t q,
WORD nSIntegral,
WORD nSPeriod,
double * sPhis,
size_t sP,
double * sThetas,
size_t sQ,
FIT_RETVAL_FUNC retType )

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

Note
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 long-run mean argument (mean) can take any value or be omitted, in which case a zero value is assumed.
4. The residuals/innovations standard deviation (i.e. \(\sigma\)) should be greater than zero.
5. The non-seasonal integration order - d - is optional and can be omitted, in which case d is assumed to be zero.
6. The seasonal integration order - sD - is optional and can be omitted, in which case sD is assumed to be zero.
7. The season length - s - is optional and can be omitted, in which case s is assumed to be zero (i.e. plain ARIMA).
Returns
status code of the operation
Return values
NDK_SUCCESSoperation successful
NDK_FAILEDoperation is unsuccessful ( )
See also
NDK_SARIMA_GOF(), NDK_SARIMA_RESID(), NDK_SARIMA_PARAM(), NDK_SARIMA_FORE(), NDK_SARIMA_VALIDATE()
Parameters
pData[inout] is the univariate time series data (a one dimensional array).
[in]nSizeis the number of observations in X.
[in]meanis the model mean (i.e. mu).
[in]sigmais the standard deviation of the model's residuals/innovations.
[in]nIntegralis the non-seasonal difference order.
[in]phisare the coefficients's values of the non-seasonal AR component.
[in]pis the order of the non-seasonal AR component.
[in]thetasare the coefficients's values of the non-seasonal MA component.
[in]qis the order of the non-seasonal MA component.
[in]nSIntegralis the seasonal difference.
[in]nSPeriodis the number of observations per one period (e.g. 12=Annual, 4=Quarter).
[in]sPhisare the coefficients's values of the seasonal AR component.
[in]sPis the order of the seasonal AR component.
[in]sThetasare the coefficients's values of the seasonal MA component.
[in]sQis the order of the seasonal MA component.
[in]retTypeis a switch to select a output type ( see FIT_RETVAL_FUNC).

◆ NDK_SARIMA_FORE()

int __stdcall NDK_SARIMA_FORE ( double * pData,
size_t nSize,
double mean,
double sigma,
WORD nIntegral,
double * phis,
size_t p,
double * thetas,
size_t q,
WORD nSIntegral,
WORD nSPeriod,
double * sPhis,
size_t sP,
double * sThetas,
size_t sQ,
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).

Note
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 long-run mean argument (mean) can take any value or be omitted, in which case a zero value is assumed.
4. The residuals/innovations standard deviation (i.e. \(\sigma\)) should be greater than zero.
5. The non-seasonal integration order - d - is optional and can be omitted, in which case d is assumed to be zero.
6. The seasonal integration order - sD - is optional and can be omitted, in which case sD is assumed to be zero.
7. The season length - s - is optional and can be omitted, in which case s is assumed to be zero (i.e. plain ARIMA).
Returns
status code of the operation
Return values
NDK_SUCCESSoperation successful
NDK_FAILEDoperation is unsuccessful ( )
See also
NDK_SARIMA_GOF(), NDK_SARIMA_RESID(), NDK_SARIMA_PARAM(), NDK_SARIMA_FITTED(), NDK_SARIMA_VALIDATE()
Parameters
[in]pDatais the univariate time series data (a one dimensional array).
[in]nSizeis the number of observations in X.
[in]meanis the model mean (i.e. mu).
[in]sigmais the standard deviation of the model's residuals/innovations.
[in]nIntegralis the non-seasonal difference order.
[in]phisare the coefficients's values of the non-seasonal AR component.
[in]pis the order of the non-seasonal AR component.
[in]thetasare the coefficients's values of the non-seasonal MA component.
[in]qis the order of the non-seasonal MA component.
[in]nSIntegralis the seasonal difference.
[in]nSPeriodis the number of observations per one period (e.g. 12=Annual, 4=Quarter).
[in]sPhisare the coefficients's values of the seasonal AR component.
[in]sPis the order of the seasonal AR component.
[in]sThetasare the coefficients's values of the seasonal MA component.
[in]sQis the order of the seasonal MA component.
[in]nStepis the forecast time/horizon (expressed in terms of steps beyond end of the time series).
[in]retTypeis a switch to select the type of value returned (see FORECAST_RETVAL_FUNC).
[in]alphais the statistical significance level. If missing, a default of 5% is assumed.
[out]retValis the calculated forecast value.

◆ NDK_SARIMA_GOF()

int __stdcall NDK_SARIMA_GOF ( double * pData,
size_t nSize,
double mean,
double sigma,
WORD nIntegral,
double * phis,
size_t p,
double * thetas,
size_t q,
WORD nSIntegral,
WORD nSPeriod,
double * sPhis,
size_t sP,
double * sThetas,
size_t sQ,
GOODNESS_OF_FIT_FUNC retType,
double * retVal )

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

Note
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 residuals/innovations standard deviation (i.e. \(\sigma\)) should be greater than zero.
4. The maximum likelihood estimation (MLE) is a statistical method for fitting a model to the data and provides estimates for the model's parameters.
5. The long-run mean argument (mean) can take any value or be omitted, in which case a zero value is assumed.
6. The non-seasonal integration order - d - is optional and can be omitted, in which case d is assumed to be zero.
7. The seasonal integration order - sD - is optional and can be omitted, in which case sD is assumed to be zero.
8. The season length - s - is optional and can be omitted, in which case s is assumed to be zero (i.e. plain ARIMA).
Returns
status code of the operation
Return values
NDK_SUCCESSoperation successful
NDK_FAILEDoperation is unsuccessful ( )
See also
NDK_SARIMA_RESID(), NDK_SARIMA_PARAM(), NDK_SARIMA_FORE(), NDK_SARIMA_FITTED(), NDK_SARIMA_VALIDATE()
Parameters
[in]pDatais the univariate time series data (a one dimensional array).
[in]nSizeis the number of observations in X.
[in]meanis the model mean (i.e. mu).
[in]sigmais the standard deviation of the model's residuals/innovations.
[in]nIntegralis the non-seasonal difference order.
[in]phisare the coefficients's values of the non-seasonal AR component.
[in]pis the order of the non-seasonal AR component.
[in]thetasare the coefficients's values of the non-seasonal MA component.
[in]qis the order of the non-seasonal MA component.
[in]nSIntegralis the seasonal difference.
[in]nSPeriodis the number of observations per one period (e.g. 12=Annual, 4=Quarter).
[in]sPhisare the coefficients's values of the seasonal AR component.
[in]sPis the order of the seasonal AR component.
[in]sThetasare the coefficients's values of the seasonal MA component.
[in]sQis the order of the seasonal MA component.
[in]retTypeis a switch to select a fitness measure ( see GOODNESS_OF_FIT_FUNC).
[out]retValis the calculated goodness of fit value.

◆ NDK_SARIMA_PARAM()

int __stdcall NDK_SARIMA_PARAM ( double * pData,
size_t nSize,
double * mean,
double * sigma,
WORD nIntegral,
double * phis,
size_t p,
double * thetas,
size_t q,
WORD nSIntegral,
WORD nSPeriod,
double * sPhis,
size_t sP,
double * sThetas,
size_t sQ,
MODEL_RETVAL_FUNC retType,
size_t maxIter )

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

Note
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 long-run mean argument (mean) can take any value or be omitted, in which case a zero value is assumed.
4. The residuals/innovations standard deviation (i.e. \(\sigma\)) should be greater than zero.
5. The non-seasonal integration order - d - is optional and can be omitted, in which case d is assumed to be zero.
6. The seasonal integration order - sD - is optional and can be omitted, in which case sD is assumed to be zero.
7. The season length - s - is optional and can be omitted, in which case s is assumed to be zero (i.e. plain ARIMA).
Returns
status code of the operation
Return values
NDK_SUCCESSoperation successful
NDK_FAILEDoperation is unsuccessful ( )
See also
NDK_SARIMA_GOF(), NDK_SARIMA_RESID(), NDK_SARIMA_FORE(), NDK_SARIMA_FITTED(), NDK_SARIMA_VALIDATE()
Parameters
[in]pDatais the univariate time series data (a one dimensional array).
[in]nSizeis the number of observations in X.
mean[inout] is the mean of the ARMA process.
sigma[inout] is the standard deviation of the model's residuals/innovations.
[in]nIntegralis the non-seasonal difference order.
phis[inout] are the coefficients's values of the non-seasonal AR component.
[in]pis the order of the non-seasonal AR component.
thetas[inout] are the coefficients's values of the non-seasonal MA component.
[in]qis the order of the non-seasonal MA component.
[in]nSIntegralis the seasonal difference.
[in]nSPeriodis the number of observations per one period (e.g. 12=Annual, 4=Quarter).
sPhis[inout] are the coefficients's values of the seasonal AR component.
[in]sPis the order of the seasonal AR component.
sThetas[inout] are the coefficients's values of the seasonal MA component.
[in]sQis the order of the seasonal MA component.
[in]retTypeis a switch to select the type of value returned: 1= Quick Guess, 2=Calibrated, 3= Std. Errors ( see MODEL_RETVAL_FUNC).
[in]maxIteris the maximum number of iterations used to calibrate the model. If missing or less than 100, the default maximum of 100 is assumed.

◆ NDK_SARIMA_SIM()

int __stdcall NDK_SARIMA_SIM ( double mean,
double sigma,
WORD nIntegral,
double * phis,
size_t p,
double * thetas,
size_t q,
WORD nSIntegral,
WORD nSPeriod,
double * sPhis,
size_t sP,
double * sThetas,
size_t sQ,
double * pData,
size_t nSize,
size_t nSeed,
double * retVal,
size_t nStep )

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

Note
1. The time series is homogeneous or equally spaced.
2. SARIMA_SIM returns an array of one simulation path starting from the end of the input data.
3. The time series may include missing values (e.g. NaN) at either end.
4. The residuals/innovations standard deviation (i.e. \(\sigma\)) should be greater than zero.
5. The input data argument (i.e. latest observations) is optional. If omitted, an array of zeroes is assumed.
6. The long-run mean argument (mean) can take any value or be omitted, in which case a zero value is assumed.
7. The non-seasonal integration order - d - is optional and can be omitted, in which case d is assumed to be zero.
8. The seasonal integration order - sD - is optional and can be omitted, in which case sD is assumed to be zero.
9. The season length - s - is optional and can be omitted, in which case s is assumed to be zero (i.e. Plain ARIMA).
Returns
status code of the operation
Return values
NDK_SUCCESSoperation successful
NDK_FAILEDoperation is unsuccessful ( )
See also
NDK_SARIMA_GOF(), NDK_SARIMA_RESID(), NDK_SARIMA_FORE(), NDK_SARIMA_FITTED(), NDK_SARIMA_VALIDATE()
Parameters
[in]meanis the model mean (i.e. mu).
[in]sigmais the standard deviation of the model's residuals/innovations.
[in]nIntegralis the non-seasonal difference order.
[in]phisare the coefficients's values of the non-seasonal AR component.
[in]pis the order of the non-seasonal AR component.
[in]thetasare the coefficients's values of the non-seasonal MA component.
[in]qis the order of the non-seasonal MA component.
[in]nSIntegralis the seasonal difference.
[in]nSPeriodis the number of observations per one period (e.g. 12=Annual, 4=Quarter).
[in]sPhisare the coefficients's values of the seasonal AR component.
[in]sPis the order of the seasonal AR component.
[in]sThetasare the coefficients's values of the seasonal MA component.
[in]sQis the order of the seasonal MA component.
[in]pDatais the univariate time series data (a one dimensional array).
[in]nSizeis the number of observations in X.
[in]nSeedis an unsigned integer for setting up the random number generators.
[out]retValis the simulated value.
[in]nStepis the simulation time/horizon (expressed in terms of steps beyond end of the time series).

◆ NDK_SARIMA_VALIDATE()

int __stdcall NDK_SARIMA_VALIDATE ( double mean,
double sigma,
WORD nIntegral,
double * phis,
size_t p,
double * thetas,
size_t q,
WORD nSIntegral,
WORD nSPeriod,
double * sPhis,
size_t sP,
double * sThetas,
size_t sQ )

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

Note
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 residuals/innovations standard deviation (i.e. \(\sigma\)) should be greater than zero.
4. The long-run mean argument (mean) can take any value or be omitted, in which case a zero value is assumed.
5. The non-seasonal integration order - d - is optional and can be omitted, in which case d is assumed to be zero.
6. The seasonal integration order - sD - is optional and can be omitted, in which case sD is assumed to be zero.
7. The season length - s - is optional and can be omitted, in which case s is assumed to be zero (i.e. plain ARIMA).
Returns
status code of the operation
Return values
NDK_SUCCESSoperation successful
NDK_FAILEDoperation is unsuccessful ( )
See also
NDK_SARIMA_GOF(), NDK_SARIMA_RESID(), NDK_SARIMA_PARAM(), NDK_SARIMA_FORE(), NDK_SARIMA_FITTED()
Parameters
[in]meanis the model mean (i.e. mu).
[in]sigmais the standard deviation of the model's residuals/innovations.
[in]nIntegralis the non-seasonal difference order.
[in]phisare the coefficients's values of the non-seasonal AR component.
[in]pis the order of the non-seasonal AR component.
[in]thetasare the coefficients's values of the non-seasonal MA component.
[in]qis the order of the non-seasonal MA component.
[in]nSIntegralis the seasonal difference.
[in]nSPeriodis the number of observations per one period (e.g. 12=Annual, 4=Quarter).
[in]sPhisare the coefficients's values of the seasonal AR component.
[in]sPis the order of the seasonal AR component.
[in]sThetasare the coefficients's values of the seasonal MA component.
[in]sQis the order of the seasonal MA component.