Skip to content
Rafat Hussain edited this page Jul 25, 2020 · 9 revisions

AUTO ARIMA Class and Functions

auto_arima_object auto_arima_init(int *pdqmax,int *PDQmax,int s, int r, int N);

pdqmax - Integer array of [pmax,dmax,qmax] where,
    pmax is the maximum number of AR coefficients in the search grid
    qmax is the maximum number of MA coefficients
    dmax is the maximum number of times the series needs to be differenced

Set pdqmax to NULL if you want to use the default [5,2,5] values

PDQmax - Integer array of [Pmax,Dmax,Qmax] where,
    Pmax is the maximum number of Seasonal AR coefficients in the search grid
    Qmax is the maximum number of Seasonal MA coefficients
    Dmax is the maximum number of times the series needs to be differenced (s*D)


Set PDQmax to NULL if you want to use the default [2,1,2] values

N - Length of Time Series
s - Seasonality/Period
r - Number of exogenous variables


Execution

void auto_arima_exec(auto_arima_object obj, double *inp,double *xreg);

obj - Auto ARIMA 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

Auto ARIMA Object Parameters

	int N;// length of time series
	int Nused;//length of time series after differencing, Nused = N - d -s*D
	int method;
	int optmethod;
	int pmax;// Maximum size of phi
	int dmax;// Maximum Number of times the series is to be differenced
	int qmax;// Maximum size of theta
	int Pmax;//Maximum Size of seasonal phi
	int Dmax;// Maximum number of times the seasonal series is to be differenced
	int Qmax;//Maximum size of Seasonal Theta
	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;
	double mean;
	double var;
	double loglik;
	double ic;
	int retval;
	int start;
	int imean;
	int idrift;
	int stationary;
	int seasonal;
	int Order_max;
	int p_start;
	int q_start;
	int P_start;
	int Q_start;
	char information_criteria[10];
	int stepwise;
	int num_models;
	int approximation;
	int verbose;
	char test[10];
	char type[10];
	char seas[10];
	double alpha_test;
	double alpha_seas;
	double lambda;
	double sigma2;
	double aic;
	double bic;
	double aicc;

AUTO ARIMA Method (method)

0 - Conditional Method - Sum Of Squares + Exact Maximum Likelihood Method (Default)
1 - Exact Maximum Likelihood Method
2 - Conditional Method - Sum Of Squares

Optimization Method (optmethod)


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

Return Values

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

Functions associated with Auto ARIMA method


void auto_arima_setMethod(auto_arima_object obj, int value); // Sets ARIMA method. value accepts 0,1 and 2

void auto_arima_setOptMethod(auto_arima_object obj, int value); // Sets Optimization method. Value accepts 0,1,2,3,4,5,6 and 7

void auto_arima_summary(auto_arima_object obj); // Prints Auto ARIMA results and summary.

void auto_arima_setStepwise(auto_arima_object obj, int stepwise);// stepwise: 1 for stepwise search. 0 for full grid search.

void auto_arima_setApproximation(auto_arima_object obj, int approximation);// approximation: 1 . Use faster but approximate CSS method. 0 for slower but more accurate Maximum Likelihood Estimation

void auto_arima_setStationarityParameters(auto_arima_object obj,const char *test, double alpha, const char *type);// Stationarity Test Parameters
1. test is one of "kpss" , "df"/"adf" or "pp". "kpss" is default.
2. alpha accepts values between 0.0 and 0.10. Default is 0.05
3. type is one of "level" or "trend". default is "level" 

void auto_arima_setSeasonalParameters(auto_arima_object obj,const char *test, double alpha); // Seasonality Test
1. test is one of "seas" (Rob Hundman's seasonality heuristics test) and "ocsb". "seas" is default.
2. alpha parameters default value is 0.05. See above.

void auto_arima_predict(auto_arima_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

Deallocate Object Obj when the computation is finished

 void auto_arima_free(auto_arima_object object);

Examples

Auto ARIMA example for a stationary time series with no seasonal components and no exogenous variable.
Seasonal Auto ARIMA example with no exogenous variable.
Auto ARIMA example with exogenous variables.