# 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.

Returns
status code of the operation
Return values
 NDK_SUCCESS Operation successful NDK_FAILED Operation unsuccessful. See Macros for full list.
Parameters
[in] pData is the univariate time series data (a one dimensional array).
[in] nSize is the number of observations in pData.
[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:
Order   Description
1 Log-Likelihood Function (LLF) (default)
2 Akaike Information Criterion (AIC)
3 Schwarz/Bayesian Information Criterion (SIC/BIC)
4 Hannan-Quinn information criterion (HQC)
[out] retVal is the calculated goodness of fit value.
Remarks
1. The underlying model is described here.
2. The time series is homogeneous or equally spaced
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 ARMA model has independent and normally distributed residuals with constant variance. The ARMA log-likelihood function becomes: $\ln L^* = -T\left(\ln 2\pi \hat \sigma^2+1\right)/2$ Where:
• $$\hat \sigma$$ is the standard deviation of the residuals.
6. The value of the input argument - period - must be greater than one, or the function returns #VALUE!.
7. The value of the seasonal difference argument - sD - must be greater than one, or the function returns #VALUE!.
8. The maximum likelihood estimation (MLE) is a statistical method for fitting a model to the data and provides estimates for the model's parameters.
9. The long-run mean argument (mean) can take any value or be omitted, in which case a zero value is assumed.
10. The residuals/innovations standard deviation (sigma) must be greater than zero.
11. For the input argument - phi (parameters of the non-seasonal AR component):
• The input argument is optional and can be omitted, in which case no non-seasonal AR component is included.
• The order of the parameters starts with the lowest lag.
• The order of the non-seasonal AR component model is solely determined by the order of the last value in the array with a numeric value (vs. missing or error).
12. For the input argument - theta (parameters of the non-seasonal MA component):
• The input argument is optional and can be omitted, in which case no non-seasonal MA component is included.
• The order of the parameters starts with the lowest lag.
• The order of the non-seasonal MA component model is solely determined by the order of the last value in the array with a numeric value (vs. missing or error).
13. For the input argument - sPhi (parameters of the seasonal AR component):
• The input argument is optional and can be omitted, in which case no seasonal AR component is included.
• The order of the parameters starts with the lowest lag.
• The order of the seasonal AR component model is solely determined by the order of the last value in the array with a numeric value (vs. missing or error).
14. For the input argument - sTheta (parameters of the seasonal MA component):
• The input argument is optional and can be omitted, in which case no seasonal MA component is included.
• The order of the parameters starts with the lowest lag.
• The order of the seasonal MA component model is solely determined by the order of the last value in the array with a numeric value (vs. missing or error).
15. The non-seasonal integration order - d - is optional and can be omitted, in which case d is assumed to be zero.
16. The seasonal integration order - sD - is optional and can be omitted, in which case sD is assumed to be zero.
17. The season length - s - is optional and can be omitted, in which case s is assumed to be zero (i.e. plain ARIMA).
Requirements
Examples



 Namespace: NumXLAPI Class: SFSDK Scope: Public Lifetime: Static
 int NDK_SARIMA_GOF ( double[] pData, UIntPtr nSize, double mean, double sigma, short nIntegral, double[] phis, UIntPtr p, double[] thetas, UIntPtr q, short nSIntegral, double[] sPhis, UIntPtr sP, double[] sThetas, UIntPtr sQ, GOODNESS_OF_FIT_FUNC retType, ref double retVal )

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

Return Value

a value from NDK_RETCODE enumeration for the status of the call.

 NDK_SUCCESS operation successful Error Error Code
Parameters
[in] pData is the univariate time series data (a one dimensional array).
[in] nSize is the number of observations in pData.
[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:
Order   Description
1 Log-Likelihood Function (LLF) (default)
2 Akaike Information Criterion (AIC)
3 Schwarz/Bayesian Information Criterion (SIC/BIC)
4 Hannan-Quinn information criterion (HQC)
[out] retVal is the calculated goodness of fit value.
Remarks
1. The underlying model is described here.
2. The time series is homogeneous or equally spaced
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 ARMA model has independent and normally distributed residuals with constant variance. The ARMA log-likelihood function becomes: $\ln L^* = -T\left(\ln 2\pi \hat \sigma^2+1\right)/2$ Where:
• $$\hat \sigma$$ is the standard deviation of the residuals.
6. The value of the input argument - period - must be greater than one, or the function returns #VALUE!.
7. The value of the seasonal difference argument - sD - must be greater than one, or the function returns #VALUE!.
8. The maximum likelihood estimation (MLE) is a statistical method for fitting a model to the data and provides estimates for the model's parameters.
9. The long-run mean argument (mean) can take any value or be omitted, in which case a zero value is assumed.
10. The residuals/innovations standard deviation (sigma) must be greater than zero.
11. For the input argument - phi (parameters of the non-seasonal AR component):
• The input argument is optional and can be omitted, in which case no non-seasonal AR component is included.
• The order of the parameters starts with the lowest lag.
• The order of the non-seasonal AR component model is solely determined by the order of the last value in the array with a numeric value (vs. missing or error).
12. For the input argument - theta (parameters of the non-seasonal MA component):
• The input argument is optional and can be omitted, in which case no non-seasonal MA component is included.
• The order of the parameters starts with the lowest lag.
• The order of the non-seasonal MA component model is solely determined by the order of the last value in the array with a numeric value (vs. missing or error).
13. For the input argument - sPhi (parameters of the seasonal AR component):
• The input argument is optional and can be omitted, in which case no seasonal AR component is included.
• The order of the parameters starts with the lowest lag.
• The order of the seasonal AR component model is solely determined by the order of the last value in the array with a numeric value (vs. missing or error).
14. For the input argument - sTheta (parameters of the seasonal MA component):
• The input argument is optional and can be omitted, in which case no seasonal MA component is included.
• The order of the parameters starts with the lowest lag.
• The order of the seasonal MA component model is solely determined by the order of the last value in the array with a numeric value (vs. missing or error).
15. The non-seasonal integration order - d - is optional and can be omitted, in which case d is assumed to be zero.
16. The seasonal integration order - sD - is optional and can be omitted, in which case sD is assumed to be zero.
17. The season length - s - is optional and can be omitted, in which case s is assumed to be zero (i.e. plain ARIMA).
Exceptions
Exception Type Condition
None N/A
Requirements
Namespace NumXLAPI SFSDK Public Static NumXLAPI.DLL
Examples

References
* Hamilton, J .D.; Time Series Analysis , Princeton University Press (1994), ISBN 0-691-04289-6
* Tsay, Ruey S.; Analysis of Financial Time Series John Wiley & SONS. (2005), ISBN 0-471-690740
* D. S.G. Pollock; Handbook of Time Series Analysis, Signal Processing, and Dynamics; Academic Press; Har/Cdr edition(Nov 17, 1999), ISBN: 125609906
* Box, Jenkins and Reisel; Time Series Analysis: Forecasting and Control; John Wiley & SONS.; 4th edition(Jun 30, 2008), ISBN: 470272848