## 5 Our Approach
### Tuning ARIMA
#### 5.2.1 Preprocessing  
The input of such a step is a properly formatted time series. We used a time series constituted by (_price_, _date_) tuples with consecutive daily entries. We used these tuples to find out if a given time series is _stationary_ (_d_), the size of clusters of correlated entries (_q_) and partially correlated entries (_p_). In short, if a time series is stationary, then taking first-differences is not needed. The series is integrated of order zero, obtaining \(d\) = 0 and we specify an ARMA model. Conversely, if the series is not stationary, further calculation is necessary. The parameters \(p\) and \(q\), in short, tell us how big the clusters of entries that have a similar behavior over time are. Parameters estimation can be done following the _Box and Jenkins_ method [32] in order to find the best fit in a time series using ARIMA. It consists of a model identification step, a parameter estimation step and a model evaluation step. * **Model identification:** The first step is to check the stationarity of the series, needed by the ARIMA model. Based on some work in literature [31], we used the NG and Perron modified unit root test as it has been proved to be more efficient than the ADF test. A time series has stationarity if a shift in time does not cause a change in the shape of the distribution; unit roots are one cause for non-stationarity. According to the literature about probability theory and statistics, a unit root represents a feature that in a stochastic process can lead toward problems in statistical inference when time series models are involved. In our context, if a time series has a unit root, it is characterized by a systematic pattern that is unpredictable [48], as it happens in the non-invertible processes [16; 49]. The augmented _Dickey-Fuller_ test is built with a null hypothesis that there is a unit root. The null hypothesis could be rejected if the _p_-value of the test result is less than 5%. Furthermore, we checked also that the _Dickey-Fuller_ statistical value is more negative than the associated _t-distribution_ critical value; the more negative the statistical value, the more we can reject the hypothesis that there is a unit root. If the test result shows that we cannot reject the hypothesis, we have to differentiate the series and repeat the test again. Usually, differencing more than twice a series means that the series is not good to fit into ARIMA. Figures 3 and 4 show examples of stationary and non-stationary time series of our data (Examples taken from [[http://ciaranmonahan.com/supply-chain-models-arima-models-non-stationary-data/](http://ciaranmonahan.com/supply-chain-models-arima-models-non-stationary-data/)]([http://ciaranmonahan.com/supply-chain-models-arima-models-non-stationary-data/](http://ciaranmonahan.com/supply-chain-models-arima-models-non-stationary-data/))). * **Parameters estimation:** Within the domain of time series, two important functions deal with lags. The first, the _Partial AutoCorrelation Function_ (PACF), is the correlation between a time series and its own lagged values. The other, the _AutoCorrelation Function_ (ACF), defines how points are correlated with each other, based on how many time steps they are separated by. These two functions are necessary for time series analysis as they are able to identify the extent of the lag in an autoregressive model (PACF) and in a moving average model (ACF) [50]. Figures 5 and 6 show an example of an ACF and PACF. The use of these functions was introduced as part of the _Box-Jenkins_ approach to time series modeling, where computing the partial autocorrelation function could be determined by the appropriate lags \(p\) in an ARIMA (\(p\), \(d\), \(q\)) model, and computing the autocorrelation function could be determined by the appropriate lag \(q\) in an ARIMA (\(p\), \(d\), \(q\)) model.