Forecasting Stock Prices Using Multi-Macroeconomic Regressors Based on the Facebook Prophet Model

This paper utilizes four Machine Learning (ML) models to forecast the stock prices of Meta Platforms, including Facebook Prophet with five regressors, Facebook Prophet with no regressor, NeuralProphet, and the ARIMA model. Facebook Prophet serves as the primary model for forecasting in this study. Five macroeconomic regressors are applied to the Facebook Prophet to increase the precision of Meta closing price prediction. The experiment also incorporates the NeuralProphet model and the ARIMA model to predict future Meta stock closing prices. NeuralProphet uses Neural Networks to model time-series data. A comparative study of the four models is made as part of the result analysis. No regressors are added to NeuralProphet or ARIMA for the purpose of comparative analysis. The experimental results show that the Facebook Prophet model with five regressors is the superior model for predicting stock prices compared to the NeuralProphet model and the ARIMA model. The forecasting done by Facebook Prophet with multiregressors scores a mean absolute error of 14.08259, the lowest of the four models. It also scores the lowest for three other measures of errors. The results indicate that using five regressors related to the macroeconomy can achieve high forecasting accuracy.


Introduction
The recent volatility of the U.S. financial market can be attributed to negative macroeconomic conditions. Issues of political uncertainty, higher recessionary expectations, and concerns over the COVID-19 pandemic have negatively affected the U.S. Stock Market. This creates a need for an accurate model that forecasts stock prices. Studies on forecasting stock prices have been done extensively. The nonlinearity of the stock market, along with the noisy data, has made stock price forecasting difficult. In past literature, the forecasting of stock prices was done by statistical models. Statistical models such as ARIMA was useful at predicting stock prices (Ariyo et al., 2014). The stock market is volatile in nature, so other methods were used to forecast. Machine learning have been popular among researchers who seek to gain a better understanding of the stock market's behavior. For example, one study evaluated the predicting accuracy of different tree-based ensemble ML methods (Ampomah et al., 2020). In this study, six ML models were used, including Random Forest, XGBoost Classifier, Bagging Classifier, and more. The experiment was based on historical data from 2005 to 2019. The data was obtained from NYSE, NASDAQ, and NSE. The Extra tree model demonstrated better precision than other models. Liu et al. proposed a hybrid framework combining PSO, dpLSTM, ORLEM, and EWT to predict daily stock closing prices (Liu & Long, 2020). The experiment extracted stock closing prices from the U.S. and China to make predictions. The hybrid model improved the prediction accuracy when compared to traditional ML models. A study in 2020 used three different ML algorithms to predict stock behavior. These algorithms were Support Vector Machine, Logistic Regression, and Perceptron (Parray et al., 2020). Time-series data were collected from 2013 to 2018 from the Indian National Stock Exchange. Researchers then calculated technical indicators to use as parameters. Only historical stock prices were used as inputs of the prediction in this experiment. All three models had high accuracy in predicting stock behavior. The Support Vector Machine reached 87.35% average accuracy when the time-series dataset was not organized into a supervised learning format. These studies show that accurate forecasting of stock prices can be achieved. However, most stock prediction papers have an overarching problem of using only historical data. Our main contribution addresses this problem, and the next section discusses our contribution in details.
The rest of the paper is structured as follows: Section 3 reviews works of literature on stock prediction, addresses problems related to these works, and introduces a novel model to predict future stock prices. Section 4 describes the methodology of the research. It details the features of the four ML models and the five unique regressors used to influence the primary model. Section 5 presents the experimental results and analyzes the predicting accuracy of the four models. Section 6 offers the conclusion and proposal for future research.

Literature Review
A variety of ML models were used by researchers to predict future stock prices using past stock prices. A study done in 2009 combined the Artificial Neural Network (ANN) and the Decision Tree Model (DT) to predict stock performance (Tsai & Wang, 2009). The study discussed the widespread use of ANN in forecasting and the additional DT model results in decision rules for future analysis. Neural Network imitates the human brain with many layers of artificial neurons. A Decision Tree is also known as a classification tree where tree nodes and branches indicate output and decision. The hybrid model indicates whether the stock rises or falls. The results show that ANN + DT model achieves 77% forecasting precision in electronic industry stock. This study employed both fundamental and technical analysis. It used data related to the company's performance as inputs. However, no parameter related to the general economy was used. Nikou et al. applied time-series data to assess the forecasting power of Deep Learning methods, Support Vector Regression method, and Random Forest method (Nikou et al., 2019). The time-series data was the closing price of the iShare MSCI U.K. exchange-traded fund from 2015 to 2018. The researchers found the Deep Learning method as the most powerful forecasting tool relative to other ML methods. No company-related data or macroeconomic variables were used as inputs, so only historical data were used to generate the predicted outputs. As mentioned in the previous research, Deep Learning can be an efficient forecasting tool. Other models used to predict stock prices also include the LSTM Deep Learning network, which utilizes all types of sequential data. Mehtab et al. used historical data from the NIFTY 50 index from 2014 to 2018 to train eight regression models (Mehtab et al., 2021). The LSTM-based model best predicted future open value using historical data from one week earlier, relative to the other models. The precision of LSTM demonstrated the effectiveness of Deep Learning in predicting time-series data. LSTM network was a powerful tool for predicting stock prices in this study. Unfortunately, this study has only been done for medium-term traders who are concerned with stocks in the short term. It did not address the long-term profitability of different stocks. Another study has been done to compare the effectiveness between Ensemble ML methods and single-stage ML methods (Zhang et al., 2020). These models applied technical indicators as inputs to predict the value of stock closing prices. Data were collected from previous years, from 2012 to 2017. Technical indicators describe the trend of past stock prices, which include moving average, transaction volume, and relative strength index. In this study, SVR-ENANFIS was the two-stage ensemble ML model with the highest prediction accuracy. However, the problem of this study was that all inputs were historical data. No outside input related to the stock market or the macroeconomy was used.
As shown in these works, there is a lack of using inputs other than historical stock prices and technical indicators to make future predictions. Relying on historical data and company-specific data creates a knowledge gap on how other market forces affect the U.S. stock market at large. Recent world events and macroeconomic trends have greatly contributed to the volatility of the U.S. Stock market, such as the outbreak of COVID-19. The COVID-19 pandemic intensified the remnant volatility of the stock market (Jin et al., 2022). Geopolitical events such as the invasion of Ukraine also hurt stock indices. Researchers observed a negative relationship between the invasion of Ukraine and stock returns when they surveyed the stock returns from more than 94 countries after the invasion (Jin et al., 2022). The recent stock market is highly volatile due to these macroeconomic trends. Because the stock market and the macroeconomy are interdependent on each other, ignoring macroeconomic variables will result in inaccurate predictions. To eliminate this knowledge gap, this BCP Business & Management

EMEHSS 2022
Volume 25 (2022) 233 study uses regressors related to the macroeconomy in the Prophet model to forecast the future stock closing prices.
In this study, we evaluated the forecasting power of Facebook Prophet, NeuralProphet, and ARIMA. In Facebook Prophet, we can add to influence the prediction. Facebook Prophet is useful due to its two important features (Taylor & Letham, 2017). Firstly, the model can process a large amount of data, unlike most statistical models that cannot achieve forecasting at scale. Secondly, the model achieves analyst-in-the-loop analysis, which enables additional information to be applied to the model. This feature utilizes both subjective information from the stock and objective information from the analyst. Taylor et al. found that among different forecasting methods and time series, the Facebook Prophet had a statistically significant decrease in its prediction error (Taylor & Letham, 2017). The error was lower than the ETX model, the Seasonal Naive method, and the Tbats model. In addition, the Facebook Prophet model can analyze weekly and yearly seasonality trends. Facebook Prophet made accurate predictions based on time-series data and statistical parameters in past experiments (Christy Jackson et al., 2021). NeuralProphet is a combination of the Prophet model and Neural Network (Sahay & Amudha, 2020). Based on previous experimental results, the Deep Learning method is suitable for time-series forecasting. The NeuralProphet model can address the needs of all kinds of traders. Including day-traders, medium-term traders, long-term investors, and wealth management companies. NeuralProphet is also less complicated when comparing to other Deep Learning methods. These more complicated methods are ANN and LSTM. Average traders do not have an abundant ML experience, so NeuralProphet is more accessible for them than ANN and LSTM.
Our marginal contribution can be summed up as follows: First, a Facebook Prophet model that correctly incorporated multi-macroeconomic regressors is suggested. To our knowledge, this is the first time the Facebook Prophet model based on multi-macroeconomic regressors has been employed for predicting stock price, and it fully utilizes the strengths of multi-macroeconomic regressors and the Facebook Prophet model.

Data & Experimental Setup
The closing price of Meta is the data used in this study as inputs. The stock prices are daily timeseries data collected from January 1st , 2018, to December 31st , 2021. The data from January 1st , 2018, to December 31st , 2020 is used as the training set, and the time interval from January 1st , 2021 to December 31st , 2021 as the testing set. The input is Meta stock closing prices from January 1st , 2018, to December 31st , 2020. The inputs are employed to train the ML models. Five additional inputs (these are macroeconomic variables, including expected inflation rate, economic policy uncertainty index, geopolitical uncertainty index, S&P 500 index closing prices, and 5-year forward treasury yield.) are employed to generate outputs. We only add these additional inputs to the Facebook Prophet model. The model will then forecast the Meta stock closing price in 2021 as the output based on the inputs. The period from January 1st , 2018, to December 31st , 2020 will be define as time interval t, and the stock prices and macroeconomic variables from time t will be used by the ML models to forecast stock prices on time t+1. The outputs are then compared to the actual 2021 closing price for both stocks, which shows the forecasting accuracy of the model. The closing prices of Meta Platforms are being extracted from Yahoo Finance. Meta belongs to the technology sector. It is one of the biggest social media companies in the world, but it is still volatile. Therefore, the share price of Meta is a suitable input. The flowchart of the proposed experimental method is shown in Figure 1. ( ) = ( ) + ( ) + ℎ( ) + ( ) The outputs are the forecasted stock prices. The trends are broken down into five main components: overall growth trend, yearly seasonality effects, weekly seasonality effects, holiday effects, and the additive regressors. These components are plotted on a graph for visualization. Furthermore, it allows users to manually change the intensity of changepoint detection, which helps avoid overfitting. Facebook Prophet is the predecessor of NeuralProphet, another forecasting algorithm for time-series data. In this study, the first model is the Prophet model added with multi-macroeconomic regressors. The second Prophet model have no regressor. The Meta closing price is pre-processed, combined with the regressor data into a single dataset. The Prophet model adds the corresponding regressor data, using the same column name as the combined dataset to access the regressor data. The Prophet model will then make the forecast.

NeuralProphet
NeuralProphet is a relatively new model, developed only in 2020. It is the third model investigated in this study. NeuralProphet differs from Facebook Prophet in that the model itself is built upon Neural Network. The package for NeuralProphet is accessed in Python. The coding is done in Jupyter Notebook. Six core features of NeuralProphet include trend, holiday effects, seasonality, autoregression, lagged regressors, and future regressors. Since it is built on Neural Network, it is more complicated than Facebook Prophet. But it is still more accessible to users than Artificial Neural Network and Long short-term memory. NeuralProphet is a Deep Learning method because it contains many hidden layers and nodes. A trend is formed when NeuralProphet detects the changepoints in a dataset. Holiday effects mean that special events are automatically processed as covariates of NeuralProphet. Seasonality can be modeled after the Fourier series, so the function for the dataset is periodic. The auto-regressive aspect of NeuralProphet allows it to predict future values based on past values with AR-Net. Statistically, it is a model for lagged regression. The function of an autoregressive model in order of p is written out below: = + * −1 + −1 + The dataset is processed before fitting on NeuralProphet. The pre-processed dataset only includes the date and the corresponding Meta closing price. No macroeconomic regressor is used for this model.

ARIMA Model
The autoregressive integrated moving average model (ARIMA), a time-series modeling method proposed by Box Jenkins (Box & Jenkins, 1970) is virtually an extension of the autoregressive moving average model (ARIMA). Accordingly, the paper applies the ARIMA model to the prediction residual of the three fuzzy information particles in PPI monthly time-series data to correct the deviation of GA-SVR, and the ARIMA model can be expressed as represents stock prices in time interval t+1, and the sequence after d differential conversion of . Regarding , it is the random error at time t. Furthermore, (i=1,2,..,p) and (j=1,2,…,q) are the parameters to be estimated; that is, p and q are the orders of the model. In short, the above model is denoted ARIMA (p, d, q), which, in essence, is a linear model, making it more suitable for linear modeling. The same input dataset used for NeuralProphet is applied to ARIMA. The flowchart of ARIMA modeling and prediction in this paper is shown in Figure 2.

Macroeconomic Regressors
In statistics, regressors are independent variables that trigger a response. These must be variables with known values. The regressors used in this experiment are macroeconomic variables. We name these multi-macroeconomic variables in our study. 5 (Baker et al., 2016). The study suggested a negative relationship between increased EPU and macro-level performance.
Geopolitical Risk Index: The Geopolitical Risk Index (GPR) used in this study was constructed based on 25 million news articles from the 20th century to the present, accessed from the electronic archives of important newspaper institutions (Caldara & Iacoviello, 2022). These institutions included New York Times, the Washington Post, The Wall Street Journal, and more. The study found that an elevated level of GPR relates to lower investment. In this study, GPR is used as one of the multi-macroeconomic regressors due to the effect it has on the equity market.

10-Year Treasury Constant Maturity Minus 2-Year Treasury Constant Maturity:
The percentage of 10-year treasury yield help investors make accurate predictions on stock performance. A higher yield means higher demand for the treasury, corresponding to a volatile stock market. The opposite is true. The market yield for 10-year maturity treasury securities is added as a regressor so that the Facebook Prophet model increase forecasting precision.
S&P 500 index: Investors most often view the S&P 500 index as a benchmark for stock market performance. S&P 500 is cap-weighted, featuring the 500 largest U.S. companies. The index includes companies from all industries, making S&P 500 the leading stock index. Therefore, S&P 500 index is added as a regressor for Facebook Prophet.  In this research, 75% of the data is considered for the training set, and 25% is considered for the testing set. The four models produced four graphs, showing the past closing prices and the predicted future stock closing prices. Figure 3 shows the actual stock closing price from January 1st, 2018, to December 31st, 2021. Figures 4, 5, and 7 are graphed in R, but Figure 6 is graphed in Python. The volatility of Meta stocks is shown in these graphs. Figure 3 is used as a benchmark because it shows the true values of the stocks.

Visualizations and Analysis of Forecasting
In Figures 4 and 5, the black dots display the actual closing prices from January 1st, 2018, to December 31st, 2020. The black line in Figure 7 represents the actual closing price from January 1st, 2018, to December 31st, 2020, for the ARIMA model. There is no black line or dots in Figure 6 because NeuralProphet only graphs the predicted values and trends.
The blue lines in Figure 4 and 5 represents the predicted trend of Meta's closing prices from January 1st,2021, to December 31st, 2021. Figure 6's blue line represents the NeuralProphet's predicated stock price from January 1st, 2021, to December 31st, 2021. The blue lines are the Y hat values, which are the predicted y values in the regression equation. The Y hat values are the stock closing prices generated by the regression of the ML models.
Of the four models, Facebook Prophet with multi-macroeconomic regressors (Fig. 4) graphs the stock trend that most closely resembles the true value of the stock closing price (Fig. 3). The blue trend in Figure 4 is the closest to the actual stock price trend graphed in Figure 3. The blue lines in  Figure 4. The margin of error is the largest in Figure 7, showing ARIMA's low forecasting accuracy. The empirical results indicate that the Facebook Prophet model with multi-macroeconomic regressors make the most accurate predictions compared to the other models.  The growth trend shows slower growth in Figure 7 compared to the growth trend in Figure 8. This change is due to the additive regressors applied to Facebook Prophet model in Figure 7. Any negative macroeconomic conditions can hinder growth in the stock market. NeuralProphet constructs a linear growth trend, shown in Figure 9.

Visualization and Analysis of Prophet Plot Components
The yearly seasonality trends are volatile in all three figures. All three figures show that Meta stock performs well from July to September. The performance of Meta is poor from January to April, according to the yearly trends in all figures. Each figure shows a decreasing trend from September to January and an increasing trend from April to July.
The weekly seasonality trends are not volatile in any of the models. Weekly trends are stagnant in all three figures, meaning relatively low weekly volatility for the Meta stock. We use four evaluation indices to assess the forecasting accuracy of the four models we proposed. These indices are root mean square error (RMSE), mean absolute percentage error (MAPE), mean absolute error (MAE), and symmetric mean absolute percentage error (SMAPE). These metrics are calculated using two sets of values, the predicted stock prices, and the actual stock prices. The predicted stock prices are the Y hat values. The actual stock prices are obtained from Yahoo Finance. Table 1 shows that Facebook Prophet with multi-macroeconomic regressors has the lowest value for each evaluation metric. The predicted closing prices done by the Prophet model with multimacroeconomic regressors are the closest to the actual daily Meta closing prices in 2021. In other words, this model's Y hat values are the closest to the actual stock closing values. The proposed model has an RMSE of 23.27807, so its forecasting error is not greatly spread out from the regression line. MAPE is scale-independent, but the scale is the same for all four models in this experiment. MAE is the scale-dependent KPI. Prophet with multi-macroeconomic regressors produces a low MAPE and MAE values. The low average forecasting error indicates this model's high accuracy. MAE reduces by more than 50% going from the second and third model to the first model in the table, so the error rate decreases significantly when we added regressors to the Prophet model.

Evaluation Metrics / Models Performance Comparison
Facebook Prophet model with no regressor has a higher RMSE than NeuralProphet. However, the baseline Prophet model's other error values are lower than those of NeuralProphet. Neuralprophet has higher MAPE, MAE, and SMAPE than the Prophet model with no regressors. Both models are better at predicting time-series data than the ARIMA model. The evaluation metrics reveal that prediction done by ARIMA produces the lowest accuracy. Its RMSE, MAPE, MAE, and SMAPE are the highest out of the four models. The forecasting error of ARIMA is significant.
Results of experiments reveal that the Facebook Prophet model with multi-macroeconomic regressors achieve lower RMSE, MAPE, MAE, and SMAPE relative to the NeuralProphet and ARIMA models, indicating that the proposed Facebook model with multi-macroeconomic regressors is an effective and novel approach for the prediction of stock price.

Conclusion
Geopolitical conflicts, rising expectations of a nationwide recession, and occurrence of a global pandemic are having a negative impact on the U.S. stock market. The rocky performance of the stock market has raised concerns for many investors. To predict the unpredictability of the stock market, ML models that accurately predict stock prices is needed. This paper directly addresses this need by using four ML models to forecast. These four models are Facebook Prophet, NeuralProphet and ARIMA. Five macroeconomic regressors have been applied to Facebook Prophet. This is done to find out how macroeconomic variables can help investors understand the stock market. The experiment aims to create transparency for investors in order to grow their investment. In this experiment, datasets are prepared in R. The closing price of Meta Platforms are used. All four models conducted one year forward forecasting. Baseline Prophet model, NeuralProphet model and ARIMA model serve as secondary models of forecasting, to compare the results with Facebook Prophet with regressors. Facebook Prophet with five regressors prove to be the most accurate prediction model as it achieves the lowest RMSE, MAPE, MAE, and SMAPE among all four models. The results demonstrate the effectiveness of using five macroeconomic regressors in predicting stock. The macroeconomic variables have a positive effect on predicting future stock prices. In future studies, different macroeconomic data should be considered. For example, unemployment data, M2 Money Supply, and Economic Growth rate are all macroeconomic factors that can influence stock price prediction. Other ML models should also be included in future studies to compare results with the Prophet model with regressors.