-
Notifications
You must be signed in to change notification settings - Fork 26
SARIMAX
Rafat Hussain edited this page Jul 25, 2020
·
9 revisions
sarimax_object sarimax_init(int p, int d, int q,int P, int D, int Q,int s, int r,int imean, int N);
p - Number of Autoregressive coefficients
d - Number of times the series needs to be differenced
q - Number of Moving Average Coefficients
P - Number of Seasonal Autoregressive coefficients
D - Number of times the seasonal series needs to be differenced (s*D)
Q - Number of Seasonal Moving Average Coefficients
s - Seasonality/Period
r - Number of Exogenous Variables. (Important - Make sure it is set to 0 if none.
imean - 1 : Calculate mean/intercept. 0 : Otherwise
N - Length of Time Series
void sarimax_exec(sarimax_object obj, double *inp,double *xreg) ;
obj - SARIMAX object
inp - Input Time series of length N
xreg - Exogenous Variables of size r*N (row major order)
In case r=0 and no exogenous variables are present set xreg field to NULL
int N;// length of time series
int Nused;//length of time series after differencing, Nused = N - d - s*D
int method;
int optmethod;
int p;// size of phi
int d;// Number of times the series is to be differenced
int q;//size of theta
int s;// Seasonality/Period
int P;//Size of seasonal phi
int D;// The number of times the seasonal series is to be differenced
int Q;//size of Seasonal Theta
int r;// Number of exogenous variables
int M; // M = 0 if mean is 0.0 else M = 1
int ncoeff;// Total Number of Coefficients to be estimated
double *phi;// AR coefficients of size p
double *theta;// MA coefficients of size q
double *PHI;// Seasonal AR coefficients of size P
double *THETA;// Seasonal MA coefficients of size Q
double *exog;// Exogenous Variables coefficients of size r
double *vcov;// Variance-Covariance Matrix Of length lvcov
int lvcov; //length of VCOV
double *res;// Residual vector of size N
double mean;// Mean
double var;// Variance
double loglik;
double aic;
int retval;
int start;
int imean;
0 - Conditional Method - Sum Of Squares + Exact Maximum Likelihood Method (Default)
1 - Exact Maximum Likelihood Method
2 - Conditional Method - Sum Of Squares
optmethod accepts values between 0 and 7 where -
Method 0 - Nelder-Mead
Method 1 - Newton Line Search
Method 2 - Newton Trust Region - Hook Step
Method 3 - Newton Trust Region - Double Dog-Leg
Method 4 - Conjugate Gradient
Method 5 - BFGS (Default)
Method 6 - Limited Memory BFGS
Method 7 - BFGS Using More Thuente Method
retval = 0 Input Error
retval = 1 Probable Success
retval = 4 Optimization Routine didn't converge
retval = 7 Exogenous Variables are collinear
retval = 10 Nonstationary AR part
retavl = 12 Nonstationary Seasonal AR part
retval = 15 Optimization Routine Encountered Inf/Nan Values
void sarimax_setMethod(sarimax_object obj, int value); // Sets ARIMA method. value accepts 0,1 and 2
void sarimax_setOptMethod(sarimax_object obj, int value); // Sets Optimization method. Value accepts 0,1,2,3,4,5,6 and 7
void sarimax_vcov(sarimax_object obj, double *vcov); // Returns variance-covariance matrix vcov
void sarimax_summary(sarimax_object obj); // Prints Seasonal ARIMA results and summary.
void sarimax_predict(sarimax_object obj, double *inp, double *xreg, int L,double *newxreg, double *xpred,
double *amse); // L-step Prediction for time series inp (length N). newxreg is the length r * L matrix of exogenous
variables. Set it to NULL if xreg is NULL ( r = 0). Returns length L output xpred and length L mean square error amse vectors
sarimax_free(obj);
ARMA example for a stationary time series with no seasonal components and no exogenous variable. |
---|
SARIMA example with no exogenous variable. |
ARMA example with exogenous variable. |