Comparison of ARIMA and SARIMA for Forecasting Crude Oil Prices

Crude oil price fluctuations affect the business cycle due to affecting the ups and downs of the growth of the economy, which one of the indicators of the economic business cycle phenomenon. The importance of oil price prediction requires a model that can predict future oil prices quickly, easily, and accurately so that it can be used as a reference in determining future policies. Machine learning is an accurate method that can be used in predicting and makes it easier to predict because there is no need to program computers manually. ARIMA is a machine learning algorithm while ARIMA that uses a seasonal component is called SARIMA. Based on background, research purpose is modeling crude oil price forecasting by ARIMA and SARIMA. Forecasting is done on daily crude oil price data taken from Yahoo Finance from January 27, 2020 to January 25, 2023. The evaluation results show the RMSE value of ARIMA and SARIMA is 1.905. The forecast result of 7 days ahead with ARIMA is 86.230003 while SARIMA is 86.260002. The research results are expected to be helpful for policy makers to adopt policies and make the right decisions in the use of crude oil.


Introduction
One of the commodities that is quite important for the Indonesian economy is oil [1]. Oil price fluctuations impact business cycles. This is because fluctuations in crude oil prices affect the rise and fall of economic growth, that is an indicator of economic business cycle phenomena. Oil price fluctuations also have an impact on state revenue in the form of non-tax oil revenue and oil tax revenue [2].
The short and long-term impacts of world oil price fluctuations on macroeconomic variables and fuel subsidies require appropriate government policies to avoid economic and social instability in society [3].
As one of the most important strategic resources in the world, the fluctuation cycle of oil prices is critical to the survival and development of oil companies. Accurate oil price forecasts will help oil companies adjust business strategies, optimize asset structures, avoid oil price risks, and help investors understand the laws of market volatility and make profits in trading [4].
Given that oil price forecasts are important, a model is required which can be used to forecast future oil prices quickly, easily, and accurately that can be used as a reference in determining future policies.
Machine Learning is an accurate method can be used in predicting prices [5]. The use of machine learning, also makes it easier to make predictions because it does not have to manually program the computer continuously. Machine learning must be trained by studying preexisting data to be able to do something automatically. This aims to make a prediction based on these data [6].
One of the machine learning algorithms is ARIMA. This algorithm is flexible (following data patterns), has a relatively high level of precision in forecasting and is suitable for forecasting several variables quickly, easily, accurately, and cheaply as it requires only historical data to perform forecasting [7].
An extension of the ARIMA model that has seasonal effects is SARIMA [8]. According to the background above, this research will do crude oil price forecasting with ARIMA and SARIMA model. A Forecast is a prediction of what will occur in the future [9].
There are many studies that have used ARIMA for forecasting. Such as Bitcoin price forecasting [10], Litecoin and Dogecoin price forecasting [11], and forecasting third wave of COVID-19 effect in India [12]. week. This research is expected to help policy makers to adopt the right policies and make the right.

Data Extration
Extracting crude oil price data from Yahoo Finance is conducted with yfinance. It's an open source python package used for downloading of historical market data from Yahoo! Finance [14]. The data retrieved is crude oil price data from January 27, 2020 to January 25, 2023.

Prepocessing
Preprocessing is used to get data as required. The data required for this research is Close. Close is selected to present the price of the index to be forecasted. Close was selected as it represents the entire index activity on the trading day [15]. So that unnecessary data such as Open, High, Low, Adj Close, and Volume need to be deleted.need to be deleted.

Parameter Selection
ARIMA parameters are p, d, and q while SARIMA hyperparameters are p, d, and q as well as P, D, Q, and S [16]. The selection of optimal parameter values can be done by plotting ACF and PACF graphs.
In addition, it can also be done by auto arima function. This auto_arima function works similar to a grid lookup that tests different sets of parameters p and q for nonseasonal model also P and Q for seasonal models. Model selection is performed using minimized AIC or BIC or selected information criteria [17] [12].
Akaike's Information Criterion (AIC), which can help define ARIMA model order, can be formulated in equation 1 [18]: With L is data likelihood, k=1 when c≠0 and k=0 when c=0 and final term in brackets represents the sum of the models parameters ( 2 of residual variance included).
The AIC and Bayesian Information Criterion (BIC) of the ARIMA model in equation 2 and 3 [18]: The best model is found if the AIC, AICc or BIC is minimized. Criteria of information are not likely the best guide to select the correct d value of a model, but just to select p and q values. It is due to different transformations from the data that the likelihood is calculated, so that AIC values of the models with different orders of difference cannot be compared. Therefore, it is necessary to use another method to select d, and then select p and q using AICc [18].
In auto arima to choose differencing using stationarity tests as the Dickey-Fuller and seasonal differencing as the Canova-Hansen for Seasonal models [17].
Stationarity holds an essential position in time series analysis, as to apply the ARIMA model for forecasting past cases, it first needs to be confirmed that time series data cannot have an increasing or decreasing or seasonal trend through the test of stationarity. Time series data that does not have an upward or downward trend or seasonality is what is called stationary [12]. Data stationarity is required to minimize model error [19].
A time series that is stationary is a series without a particular pattern [12]. A series is stationary when the following conditions are [20]: Constant Mean by Time; Constant Variance by Time, and Constant Autocorrelation by Time.
A comparison of stationary and non-stationary plots of time series is shown in Figure 1 [20]. Based on Figure  1, the plot on the left is stationary while the plot on the right shows non-stationary.
ADF test which stands for Augmented Dickey-Fuller is one such unit root test. This test was developed by Dickey and Fuller [21], [22] This test is performed to identify whether a time series is stationary by using the p-value, when [12], [23]: Value of p > 0.05: Failing to reject H0 means that the time series has unit roots and isn't stationary; Value of p <= 0.05: Reject the H0, meaning there isn't unit root and the time series is stationary.
The hypotheses of ADF test are as follows [12], [21], [23] : Null hypothesis (H0): the time series has unit root and isn't stationary (has a time dependent structure); Alternative hypothesis (H1): the time series hasn't unit root and is stationary.

. Stationary and Nonstationary Plot Examples
A KPSS test is the inverse of the ADF test, which is a stationarity test that was first considered as a complement to the unit root test [21]. A KPSS test hypothesis is as follows [21], [22], [24]: Null hypothesis (H0): the time series hasn't unit root and is stationary; Alternative hypothesis (H1): the time series has unit root and is not stationary (has a time dependent structure).
For the non-stationary time series, then differencing is necessary to convert it to stationary [12], [23].

Modeling
Modeling is conducted by ARIMA which was is a method that George Box and Gwilyn Jenkins developed at 1970 and commonly called Box-Jenskins method. This method can be split into AR, I and MA [11].
The AR model can be called autoregressive as this model re-models the variable's past value. This method is utilized to decide the value of the p order coefficient that indicates a value's dependence on the nearest previous value [10] I is the acronym for Integrated that is utilized to get the time series stationary via the difference in observed at various times (d) [26].
MA (Moving Average) is a method to decide the value of the q coefficient that describes the previous change in the residual value [10].
In summary, ARIMA is a method of statistical perspective represented by three parameters, the first is AR data from past processes retrieved and stored and integrated processing (I) making the process of prediction easier [10].
The ARMA model is a union between the AR and MA models. The common formula of AR and MA models or ARIMA (p, 0, q) in equation 4 [10], [26].
In this case, ≠ 0, ≠ 0, and 2 > 0. Order p is referred to as AR while order q is referred to as MA. ARMA models can be applied when stationary time series, i.e. the mean and variance are more homogeneous. However, most real time series cannot meet this condition. The ARIMA model does not have such restrictions. For time series that are not stationary, the step of initial differencing is applied for making the time series obtained stationary thus ARMA model is applied [27] This model is presented in equations 5 and 6 [18].
For simplicity, complex models can be written in backshift notation as in equation 7 [18]: For handling seasonality, the process of ARIMA is generalized and SARIMA models is formulated. The SARIMA process was developed for modeling time series by short-term trends, seasonal patterns, and correlations [28]. This process extends standard model of Box and Jenkins also adds seasonal autoregressive factors and moving averages in the modeling process. SARIMA model combines the factors of non-seasonality and seasonality in a multiplicative model as in equation 8 [28]. where:

Evaluation
A forecast is never completely accurate. The difference between forecast and actual is called forecast error [9].
A commonly used method for measuring error in time series models is RMSE [26]. RMSE is utilized for evaluating prediction accuracy of a model. It calculates the difference or residual between the real and forecasted values. RMSE compares the forecast errors of the various models for a specific dataset and not between the datasets. The formula for calculating RMSE is shown in equation 9 [26] = √ 1 ∑ ( −̂) 2

=1 (9)
Here represents total number of observations, represents the actual value while ̂ represents the forecast value.
RMSE values close to zero indicate good model predictability and reliability. The range of RMSE values for model evaluation can be seen in Table 2 [29]

Prediction
Predictions are made to forecast crude oil prices for the next 7 days. This prediction is based on the daily dataset and using the model with the best RMSE value.

Results and Discussions
The data used for this research is daily historical crude oil price data starting from January 27, 2020 to January 25, 2023 with a total of 755 data. The dataset extracted from yahoo finance consists of Date, Open, High, Low, Close, Adj Close, and Volume as shown in Table 3. The most basic method to detect stationarity is the graph test, then determine visually whether the graph results qualify as stationary or non-stationary data.
The results of graph test are in Figure 2.  Figure 2 shows a trend in the crude oil price dataset. Rolling Mean of the data varies with time and the Rolling Standard Deviation has several peaks -troughs that vary with time. The stationarity requirement is that µ (mean) is equal for all t and σ (variance) is equal for all t. Based on Figure 2, the data does not meet the stationary requirements because the Rolling Mean and Standard Deviation vary and there is a trend. This research also uses ADF and KPSS tests to test for stationarity.
When a time series isn't stationary, it needs to be transformed to stationary or stationarity transformation. It is conducted by counting the difference or shift in the value of the observations. Counting changes or differences in observation values can also be done using the ADF and KPSS methods. The results of ADF and KPSS in Table 5.  Table 4 shows that the data is a non-stationary time series. Because the p value in ADF > 0.05 which means it fails to reject H0, meaning the data is non-stationary. Similarly, with the KPSS method, the p value > 0.05. So that the p value fails to reject H0, meaning data are not stationary. According to recommendations of both ADF and KPSS tests, the d value for the ARIMA model is 1.
Transformed data to stationarity is checked again until the data has a stationary time series. The results are in Figure 3 and Table 6.    Based on Table 6, the recommendations of the Canova Hansen test and OCSB test, the D value for the SARIMA model is 0.
The selection of p, q, P, and Q in this research is done using plots of ACF and PACF also auto arima. The plot results of ACF and PACF are shown in Figure 4. The lollipop plot in Figure 4 is the result of ACF and PACF. The estimated AR value can be seen by plotting the PACF.
First, ignore the lag 0 value. Lag 0 would indicate a prefect correlation, as the plot will estimate the correlation between the today's value and self. The blue area on the plot represents the confidence interval. The estimated AR value that should be used is to count the number of "lollipops" that are at the top or bottom of a trust interval before the next lollipop enters the blue area.
Thus, by looking the PACF plot in Figure 4, it can be estimated that the AR value is 0. Similarly to the PACF function, estimating the MA value can be done by looking at the ACF plot.
The same logic is applied here, i.e. the number of lollipops that are either at the top or the bottom of the trust interval until the next lollipop enters the blue area.
Thus, by looking the PACF plot in Figure 4, it can be estimated that the MA value is 0.
Based on the results of the d value recommendation with ADF and KPSS as well as the results of the ACF and PCAF plots, an optimal ARIMA model is the ARIMA (0,1,0) model.
This study also uses auto_arima to validate that the optimal ARIMA model for this study is ARIMA (0,1,0  Based on Table 7, ARIMA (0,1,0) indicates that AIC value is least. So, the model is regarded as the best forecasting model.
The SARIMA model with the best parameters in this study can also be found by ACF and PACF plots and auto_arima.
The plot of ACF and PACF to search for the optimal P and Q for the SARIMA model is seen in Figure 5.
The plots of ACF and PACF are not only to find AR and MA, but also to find the values of P and Q of the SARIMA model.The predicted P value is plotted by the PACF plot while the Q value is plotted by the ACF plot. So, by looking at the PACF plot in Figure 5, it can be estimated that the value of P is 0. Meanwhile, by looking at the ACF plot, it can be estimated that the Q value is 0. According to the results of recommendations for the value of d with ADF and KPSS, the value of D with Canova Hansen and OCSB and the results of ACF and PCAF plots. The best SARIMA model is SARIMA (0,1,0) (0,0,0) [7]. As for the S parameter used, it depends on the data and the chosen period. Since this research data is daily data and the chosen time period is weekly, the S value used is 7.
The results of finding the optimal parameters for the SARIMA model with auto_arima are in Table 9.

Conclusion
The research compared 2 models for crude oil price forecasting, i.e. ARIMA and SARIMA. The research results in best models based on optimal parameter value selection for ARIMA, i.e. ARIMA (0,1,0) while SARIMA is SARIMA (0,1,0) (0,0,0) [7]. Both models have the same evaluation value results of 0.01905% RMSE, it means the model has excellent prediction accuracy. The prediction results for the next 7 days with ARIMA and SARIMA are 86.230003 and 86.260002.