100 Ibn Al-Haitham Jour. for Pure & Appl. Sci. 34 (2) 2021 Bayesian Structural Time Series for Forecasting Oil Prices Ali Hussein AL-Moders Tasnim H. Kadhim ahussaein287@gmail.com tasnim.h@sc.uobaghdad.edu.iq Department of Mathematics, Collage of Science, University of Baghdad, Baghdad- Iraq Abstract There are many methods of forecasting, and these methods take data only, analyze it, make a prediction by analyzing, neglect the prior information side and do not considering the fluctuations that occur overtime. The best way to forecast oil prices that takes the fluctuations that occur overtime and is updated by entering prior information is the Bayesian structural time series (BSTS) method. Oil prices fluctuations have an important role in economic so predictions of future oil prices that are crucial for many countries whose economies depend mainly on oil, such as Iraq. Oil prices directly affect the health of the economy. Thus, it is necessary to forecast future oil price with models adapted for emerging events. In this article, we study the Bayesian structural time series (BSTS) for forecasting oil prices. Results show that the price of oil will increase to 156.2$ by 2035. Keywords: Bayesian structural time series (BSTS), Bayesian inference, prior oil prices. 1. Introduction Oil prices are incredibly significant as an economic source of Iraq, because in fact there is no economy in Iraq. Iraq depends on the price of oil. This was what we noticed when the price of oil decreased due to coronavirus. Oil prices have two major junctures, the first juncture initiated from 1859 when the oil was discovered until 1970 and when the organization of OPEC was established and instituted itself as one of the important players in oil market. The second juncture has been initiated since 1970 till present where new producers and government companies have come in the market. There are many opinions that explain the impact of the change in oil prices on the global economy. Morana [1], Barsky [2], Kilian.L. [3], Segal.P. [4], Sundry studies found that high oil prices have a negative impact on oil importing countries and a positive effect on countries whose economies depend on oil Ibn Al Haitham Journal for Pure and Applied Science Journal homepage: http://jih.uobaghdad.edu.iq/index.php/j/index Doi: 10.30526/34.2.2631 Article history: Received,25, Augest ,2020, Accepted 28, September,2020, Published in April 2021 mailto:ahussaein287@gmail.com mailto:tasnim.h@sc.uobaghdad.edu.iq 101 Ibn Al-Haitham Jour. for Pure & Appl. Sci. 34 (2) 2021 revenues [5,6]. Moreover, such positive effect impact of higher oil price on oil exporting Iraq is found out to be the most useful [7,8]. To make suitable decisions about the direction of economic policy, it is important to accurately forecast future oil prices [9]. Global oil prices in 2008 witnessed rise to $ 134/Bbl., which has been on an upward trend since 2003. In 2014 the price of Crude Oil fell below $ 50 /Bbl. The proven Iraqi oil reserves are about 112 billion barrels, while 80% of Iraqi oil is uncertain, with a total unconfirmed reserve ratio of about 360 billion barrels. In 1996, during the blockade, Iraq relied heavily on the oil-for-food program and contributed to a partial lifting of the suffering of the Iraqi citizen. After 2003 and the absence of industry and agriculture significantly, the Iraqi economy became dependent on 90% of oil exports. Bayesian structural time series model can reliably predict oil price, which creates difficulties when using classical statistical methods to forecast oil prices. However, predicting the oil prices is more complex and difficult to model because oil prices fluctuations are non-linear, unstable, and very volatile. Bayesian structural time series (BSTS) has shown great power in forecasting nonlinear and complex time series. Many papers have presented successful application of bsts for forecasting the oil price series for example YuzeLi et al. [10], Choi.D. [11], Bekiros et al [12], Jinwen Qiu et al [13]. 2. Model Used to Predict of Oil Prices There are different time series forecasting methods; they are: Auto-regressive, Moving Average, Autoregressive Moving Average, Integrated Moving Average, Seasonal Autoregressive Integrated Moving-Average (SARIMA), Bayesian structural time series (BSTS) [14]. There is no best way of doing time series modeling. It all depends on the problem. But it is almost always true that bringing in some prior information is helpful. For example, oil prices are down now due to the coronavirus outbreak. In other words, if your model is not taking that into account, it will be useless. Thus, the Bayesian structural time series of predicting oil prices is the basis of the optimal decision making to control the country's economic situation. 3. Bayesian structural time series (BSTS): Bayesian structural time series model is a technique used for time series nowcasting, forecasting, inferring causal impact a sequence of data. Samples are taken in time order with equal time intervals. Time series are analyzed to understand the past and to forecast the future. The goal of time series is forecasting, improved computing power, have made time series methods widely applicable. Time series forecasting has many real applications in various areas such as forecasting of economy, business weather, decease, and others. Suppose 𝑦𝑑 is observation with time series t. There are two components of a structural time series model: (1) Observation equation and (2) Transition equation.as 𝑦𝑑 = 𝛽𝑑 𝑋𝑑 𝑇 + πœ–π‘‘ (1) where Ξ²t is vector of variables, Xt is a vector of parameters and Ξ΅t ~𝑁(0, 𝜎 2). In addition, Ξ²t is represented as the following transition equation 𝛽𝑑+1 = 𝑇𝑑 𝛽𝑑 + 𝑅𝑑 𝛿𝑑 (2) 102 Ibn Al-Haitham Jour. for Pure & Appl. Sci. 34 (2) 2021 Where 𝛿𝑑 ~𝑁(0, 𝜎 2) and 𝑇𝑑 , 𝑅𝑑 are transition matrix. The above equations describe the observed data, and through them we can build time series models to forecast in the short and long term [15,16]. 4. Bayesian Structural Time Series Model for Forecasting Oil Prices: Oil price changes overtime because of crises, political conflicts, supply and demand to oil. For this reason, investors and policymakers need to know the direction of future oil prices. This leads to the need for the use of BSTS. BSTS features input of backend and Bayesian component regression for updating the timeline model. Hence, in this paper, we are forecasting oil prices data over time by BSTS. We use the Bayesian approach in the first place. There are many advantages in doing this such as to help us update our data continuously by entering prior information and estimating models with large numbers of parameters [17]. The Bayesian approach is based on Bayes' theorem, and we express it in the following equation: 𝑝(πœƒ|𝑦) = 𝑝(𝑦|πœƒ)𝑝(πœƒ) 𝑝(𝑦) (3) Here 𝑝(πœƒ|𝑦) is the posterior distribution for the parameter for, 𝑝(πœƒ) is the prior distribution for the parameter πœƒ, likelihood function and 𝑓(𝑦) is marginal probability of the y, this marginal probability is computed as: 𝑝(𝑦) = ∫(𝑦|πœƒ)𝑝(πœƒ)π‘‘πœƒ (4) Forecasting using the Bayesian structural time series, 𝑦𝑛+π‘Ÿ , r = 1, 2, … on the data collected up to the current time, 𝑦 = {𝑦𝑛 , π‘¦π‘›βˆ’1, … , 𝑦1}. 𝑦𝑑 = 𝛽0 + 𝛽1π‘¦π‘‘βˆ’1 + 𝛽2π‘¦π‘‘βˆ’2 + β‹― + π›½π‘‘βˆ’π‘π‘¦π‘‘βˆ’π‘ + 𝑑 (5) 𝑑 ~ 𝑁(0, 𝜎 2) Forecast equation is defined as 𝑦𝑛+π‘Ÿ = 𝛽0 + βˆ‘ 𝛽𝑖 𝑦𝑖 𝑛 𝑖=1 (6) 5. Data: The data of oil prices is taken from EIA, from 2006 to 2020 years where it has a variety of information available. This contains prices, production levels and many other relevant statistics. The results obtained from BSTS are compared with that of EIA. For the use of the Bayesian structural time series model, this study will focus on the yearly crude oil future pricing shown in Table .1 and represented in Figure .1 The data represent oil price from EIA. It is the US Energy Information Administration which is a major agency of the United States Federal Statistical System responsible for collecting, analyzing, and disseminating information on energy to promote sound policies, market efficiency, and public understanding of energy and its interaction with the economy and the environment. 103 Ibn Al-Haitham Jour. for Pure & Appl. Sci. 34 (2) 2021 Table 1. Crude Oil Price Oil price $ Year 60.85 2006 95.95 2007 97.26 2008 61.67 2009 79.50 2010 111.26 2011 111.67 2012 108.66 2013 98.95 2014 52.39 2015 43.73 2016 54.19 2017 71.31 2018 64.21 2019 42.01 2020 104 Ibn Al-Haitham Jour. for Pure & Appl. Sci. 34 (2) 2021 Figure 1: Data for oil price from 2006 to 2020. 6. Modeling Bayesian structural has an advantage to apply for short and long-term forecasting. However, most of models involve complicated mathematics and it is almost impossible for the statistician who does not have strong mathematical background to conduct forecasting. Meanwhile, BSTS allows us to conduct this study with some lines of R code. To run simulations with MCMC in the Bayesian time series in R, there is a package called a (BSTS) package. Automatically performs sample generating operations etc. The BSTS is a function specific to the Bayesian time series which includes the MCMC simulation method for generating samples and calculating parameters in the Bayesian regression model [18]. 7. Forecasting Oil Price In this section, we present the expected results obtained by applying the BSTS model to oil prices. Predicting the price of oil is very difficult due to the variables that change or occur overtime, for example the outbreak of the Corona virus and political conflicts, and thus the price of oil changes within a short period of time. Meaning demand and supply are not static. This means that there is no exact model for this. All models are probabilistic models. We carry out the bsts modeling for forecasting 15 years. To predict future values for the years 2021 to 2035 we use forecast package of the forecast code based on the coding of R- programming such that the value (64.02)we are getting from forecast package. Table 2 shows the prediction results by BSTS. The oil price was evaluated to increase to 119.88in 2035. In 2035year, EIA has estimated that the oil price will reach 120.47. The price we value in this paper is lower than the EIA because we use moderate assumptions regarding the future oil market. 105 Ibn Al-Haitham Jour. for Pure & Appl. Sci. 34 (2) 2021 Table 2. BSTS Prediction results(by authors). EIA $[19] Oil price $ Year 64.69 64.02 2021 68.86 68.53 2022 72.01 71.86 2023 75.53 74.43 2024 79.24 79.08 2025 83.03 79.81 2026 86.48 86.38 2027 90.51 88.58 2028 94.65 93.19 2029 98.29 95.78 2030 102.56 102.02 2031 106.52 103.65 2032 111.48 100.87 2033 115.84 113.18 2034 120.47 119.88 2035 106 Ibn Al-Haitham Jour. for Pure & Appl. Sci. 34 (2) 2021 Figure 2: Forecasted oil price from 2021 to 2035 8. Conclusion In this study we have provided a method to build a model forecast long-term oil prices. In this study, we applied BSTS using R program. Bayesian structural time series suitable method. Since the oil price change constantly it is useful to incorporate some prior information in the model for example, the coronavirus outbreak. This study predicts oil prices through 2035, oil price is expected to rise to $ 119.88in 2035, and the EIA predicts that oil price in 2035 will reach 120.47$. References 1. Morana, K. The oil price-macroeconomy relationship since the mid-1980s: A global perspective. Energy J. 2013. 2. Barsky, R.B.; Kilian, L. Oil and macroeconomy since the 1970s. J. Econ. Perspect. 2004. 3. Kilian, L. Not all oil price shocks are alike: Disentangling demand and supply shocks in the crude oil market. Am. Econ. Rev. 2009, 99, 1053–1069. [CrossRef] 4. Segal, P. Oil price shocks and the macroeconomy. Oxf. Rev. Econ. Policy 2011. 5. Timilsina, G.R. Oil prices and the global economy: A general equilibrium analysis. Energy Econ. 2015. 6. Archanskaia, E.; Creel, J.; Hubert, P. The nature of oil shocks and the global economy. Energy Policy, 2012. 7. Peersman, G.; Van Robays, I. Cross-country differences in the effects of oil shocks. Energy Econ. 2012, 34, 1532–1547. [CrossRef] 8. W. Xie, L. Yu, S. Xu, and S. Wang, A new method for crude oil price forecasting based on support Vector machines, in Proceedings of the International Conference on Computational Science (Part IV).2006, 444–451,. 9. Crude oil price analysis and forecasting: A perspective of new triangle, Energy Economics. 2020, 87, 104721. 107 Ibn Al-Haitham Jour. for Pure & Appl. Sci. 34 (2) 2021 10. Choi, D. The Effect of Shale Gas Revolution on Oil Industry; The Institute of Energy Economics Japan: Tokyo, Japan, 2013. 11. Bekiros, S.D.; Diks, C.G.H. The Relationship between Crude Oil Spot and Futures Prices: Cointegration, Linear and Nonlinear Causality. Energy Econ. 2008, 30, 2673– 2685. 12. Jinwen Qiu, S. Rao Jammalamadaka, Ning Ning. Multivariate Bayesian Structural Time Series Model, 2018. 13. R. Shumway ; D. Stoffer, Time Series Analysis and Its Applications, Springer, 4th Edition, 2017. 14. Schmitt, E.; Tull, C.; Atwater, P. Extending Bayesian structural time-series estimates of causal impact to many-household conservation initiatives. Ann. Appl. Stat. 2018. 15. Scott, S.L.; Varian, H.R. Predicting the Present with Bayesian Structural Time Series. 2013. 16. Energy Information Administration (EIA). Annual Energy Outlook 2020; U.S. Department of Energy. 17. Koduvely, H.M. Learning Bayesian Models with R; Packt: Birmingham, UK, 2015. 18. Steven L. Scott. Package β€˜bsts’, May 2, 2020. 19. International Energy Agency (IEA). Analysis of the Impact of High Oil Prices on the Global Economy; OCED/IEA: Paris, France, 2004.