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) |
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.
\[(1-L)(1-L^{12})x_t-\mu = (1+\theta L)(1+\Theta L^{12})a_t \]
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.
NDK_SUCCESS | operation successful |
NDK_FAILED | operation is unsuccessful ( ) |
pData | [inout] is the univariate time series data (a one dimensional array). | |
[in] | nSize | is the number of observations in X. |
[in] | mean | is the model mean (i.e. mu). |
[in] | sigma | is the standard deviation of the model's residuals/innovations. |
[in] | nIntegral | is the non-seasonal difference order. |
[in] | phis | are the coefficients's values of the non-seasonal AR component. |
[in] | p | is the order of the non-seasonal AR component. |
[in] | thetas | are the coefficients's values of the non-seasonal MA component. |
[in] | q | is the order of the non-seasonal MA component. |
[in] | nSIntegral | is the seasonal difference. |
[in] | nSPeriod | is the number of observations per one period (e.g. 12=Annual, 4=Quarter). |
[in] | sPhis | are the coefficients's values of the seasonal AR component. |
[in] | sP | is the order of the seasonal AR component. |
[in] | sThetas | are the coefficients's values of the seasonal MA component. |
[in] | sQ | is the order of the seasonal MA component. |
[in] | retType | is a switch to select a output type ( see FIT_RETVAL_FUNC). |
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).
NDK_SUCCESS | operation successful |
NDK_FAILED | operation is unsuccessful ( ) |
[in] | pData | is the univariate time series data (a one dimensional array). |
[in] | nSize | is the number of observations in X. |
[in] | mean | is the model mean (i.e. mu). |
[in] | sigma | is the standard deviation of the model's residuals/innovations. |
[in] | nIntegral | is the non-seasonal difference order. |
[in] | phis | are the coefficients's values of the non-seasonal AR component. |
[in] | p | is the order of the non-seasonal AR component. |
[in] | thetas | are the coefficients's values of the non-seasonal MA component. |
[in] | q | is the order of the non-seasonal MA component. |
[in] | nSIntegral | is the seasonal difference. |
[in] | nSPeriod | is the number of observations per one period (e.g. 12=Annual, 4=Quarter). |
[in] | sPhis | are the coefficients's values of the seasonal AR component. |
[in] | sP | is the order of the seasonal AR component. |
[in] | sThetas | are the coefficients's values of the seasonal MA component. |
[in] | sQ | is the order of the seasonal MA component. |
[in] | nStep | is the forecast time/horizon (expressed in terms of steps beyond end of the time series). |
[in] | retType | is a switch to select the type of value returned (see FORECAST_RETVAL_FUNC). |
[in] | alpha | is the statistical significance level. If missing, a default of 5% is assumed. |
[out] | retVal | is the calculated forecast value. |
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.
NDK_SUCCESS | operation successful |
NDK_FAILED | operation is unsuccessful ( ) |
[in] | pData | is the univariate time series data (a one dimensional array). |
[in] | nSize | is the number of observations in X. |
[in] | mean | is the model mean (i.e. mu). |
[in] | sigma | is the standard deviation of the model's residuals/innovations. |
[in] | nIntegral | is the non-seasonal difference order. |
[in] | phis | are the coefficients's values of the non-seasonal AR component. |
[in] | p | is the order of the non-seasonal AR component. |
[in] | thetas | are the coefficients's values of the non-seasonal MA component. |
[in] | q | is the order of the non-seasonal MA component. |
[in] | nSIntegral | is the seasonal difference. |
[in] | nSPeriod | is the number of observations per one period (e.g. 12=Annual, 4=Quarter). |
[in] | sPhis | are the coefficients's values of the seasonal AR component. |
[in] | sP | is the order of the seasonal AR component. |
[in] | sThetas | are the coefficients's values of the seasonal MA component. |
[in] | sQ | is the order of the seasonal MA component. |
[in] | retType | is a switch to select a fitness measure ( see GOODNESS_OF_FIT_FUNC). |
[out] | retVal | is the calculated goodness of fit value. |
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.
NDK_SUCCESS | operation successful |
NDK_FAILED | operation is unsuccessful ( ) |
[in] | pData | is the univariate time series data (a one dimensional array). |
[in] | nSize | is 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] | nIntegral | is the non-seasonal difference order. |
phis | [inout] are the coefficients's values of the non-seasonal AR component. | |
[in] | p | is the order of the non-seasonal AR component. |
thetas | [inout] are the coefficients's values of the non-seasonal MA component. | |
[in] | q | is the order of the non-seasonal MA component. |
[in] | nSIntegral | is the seasonal difference. |
[in] | nSPeriod | is 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] | sP | is the order of the seasonal AR component. |
sThetas | [inout] are the coefficients's values of the seasonal MA component. | |
[in] | sQ | is the order of the seasonal MA component. |
[in] | retType | is a switch to select the type of value returned: 1= Quick Guess, 2=Calibrated, 3= Std. Errors ( see MODEL_RETVAL_FUNC). |
[in] | maxIter | is the maximum number of iterations used to calibrate the model. If missing or less than 100, the default maximum of 100 is assumed. |
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.
NDK_SUCCESS | operation successful |
NDK_FAILED | operation is unsuccessful ( ) |
[in] | mean | is the model mean (i.e. mu). |
[in] | sigma | is the standard deviation of the model's residuals/innovations. |
[in] | nIntegral | is the non-seasonal difference order. |
[in] | phis | are the coefficients's values of the non-seasonal AR component. |
[in] | p | is the order of the non-seasonal AR component. |
[in] | thetas | are the coefficients's values of the non-seasonal MA component. |
[in] | q | is the order of the non-seasonal MA component. |
[in] | nSIntegral | is the seasonal difference. |
[in] | nSPeriod | is the number of observations per one period (e.g. 12=Annual, 4=Quarter). |
[in] | sPhis | are the coefficients's values of the seasonal AR component. |
[in] | sP | is the order of the seasonal AR component. |
[in] | sThetas | are the coefficients's values of the seasonal MA component. |
[in] | sQ | is the order of the seasonal MA component. |
[in] | pData | is the univariate time series data (a one dimensional array). |
[in] | nSize | is the number of observations in X. |
[in] | nSeed | is an unsigned integer for setting up the random number generators. |
[out] | retVal | is the simulated value. |
[in] | nStep | is the simulation time/horizon (expressed in terms of steps beyond end of the time series). |
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.).
NDK_SUCCESS | operation successful |
NDK_FAILED | operation is unsuccessful ( ) |
[in] | mean | is the model mean (i.e. mu). |
[in] | sigma | is the standard deviation of the model's residuals/innovations. |
[in] | nIntegral | is the non-seasonal difference order. |
[in] | phis | are the coefficients's values of the non-seasonal AR component. |
[in] | p | is the order of the non-seasonal AR component. |
[in] | thetas | are the coefficients's values of the non-seasonal MA component. |
[in] | q | is the order of the non-seasonal MA component. |
[in] | nSIntegral | is the seasonal difference. |
[in] | nSPeriod | is the number of observations per one period (e.g. 12=Annual, 4=Quarter). |
[in] | sPhis | are the coefficients's values of the seasonal AR component. |
[in] | sP | is the order of the seasonal AR component. |
[in] | sThetas | are the coefficients's values of the seasonal MA component. |
[in] | sQ | is the order of the seasonal MA component. |