# Machine Learning Models to Predict Google Stock Prices
## 3 Data  
Several variables can affect the stock price of Alphabet. We chose those that are more frequently used in the reference literature and that are more related to the operational context of Google. We then sourced from Yahoo Finance, besides the closing price of Alphabet, which would be our response variable, the explanatory variables described in Table 1 below, for the period from June 2014 to May 2024. To avoid inconsistencies, explanatory variables that are functions of the daily price were lagged by one day. To build and compare the machine learning models, we randomly sampled 80% of the observations as the training set and used the remaining 20% as the test set. \begin{table}
\begin{tabular}{c c} \hline
**Variable** & **Description** \\ \hline \multirow{2}{*}{retGOOG} & Alphabet’s daily return computed as: \\  & \(r_{t+1}=\frac{p_{t+1}-p_{t}}{p_{t}}\) (lagged). \\ \hline HldiffGOOG & Difference between high and low daily price: \(d_{Hl}=p_{H}-p_{l}\) (lagged). \\ \hline OCdiffGOOG & Difference between Open and Close daily price: \(d_{OC}=p_{O}-p_{C}\) (lagged). \\ \hline HLprodOC & Products between HldiffGOOG and OCdiffGOOG (lagged). \\ \hline \multirow{2}{*}{StdChangeVolGOOG} & Standardised daily change in volume \\  & \(SCV_{t}=\frac{\alpha_{V}-p_{t}}{\alpha_{C}}\). \\ \hline IXIC & Nasdaq Composite Index (IXIC). \\ \hline \multirow{2}{*}{DXYNYB} & U.S. Dollar Index, measuring the value of the United States dollar relative to a basket of foreign currencies (EUR, JPY, GBP, CAD, SEK, CHF), sourced from Yahoo Finance. \\ \cline{2-2}  & TRXFLDUSP & Bloomberg U.S. Dollar Total Return Index. \\ \hline \multirow{2}{*}{VIX} & Volatility Index, a real-time market index representing the market’s expectations for volatility over the coming 30 days, sourced from Yahoo Finance. \\ \hline Gold & Gold adjusted Close price on Yahoo Finance. \\ \hline \multirow{2}{*}{retGOLD} & Return on Gold adjusted close price: \\  & \(r_{t+1}=\frac{p_{t+1}-p_{t}}{p_{t}}\). \\ \hline CrudeOil & Crude Oil adjusted Close price on Yahoo Finance. \\ \hline \end{tabular}
\end{table} 
Table 1: The considered variables. Source: Yahoo Finance and Bloomberg. Authors’ Elaboration. In Figure 1, we plotted the correlations of the variables described in Table 1 with the Alphabet closing price (Close). From Figure 1, note that the target variable, Alphabet's Close Price, has a high correlation (0.98) with IXIC (Nasdaq Composite Index) and with TRXFLDUSP (Bloomberg U.S. Dollar Total Return Index), but also with gold Close price (0.85), the difference between high and low (0.69) and the crude oil Close price (0.56). Figure 1 also underlines the strong collinearity among the explanatory variables. The presence of multicollinearity may reduce predictive accuracy, and the interpretability of the models. To improve interpretability, in this paper we have subdivided the collected data into three data sets, which differ by the contained features. The first dataset contains only the lags from 1 day to 5 days of GOOG's close price. The second dataset includes both financial market data related to the Google stock price, such as retGOOG and HlfidGOOG, and variables describing the market context in which Alphabet works, such as retGOLD, \begin{table}
\begin{tabular}{c c} \hline
**Variable** & **Description** \\ \hline retCrudeOil & Return on Crude Oil adjusted Close price: \(r_{t+1}=\frac{P_{t+1}-P_{t}}{p_{t}}\). \\ \hline retGOOGvsCostRD & Ratio between daily percentage of change in prices over the quarterly percentage of change in the previous quarter. \\ \hline VarAdjClosevsRDrev & Ratio between retGOOG and the percentage of R\&D in terms of revenues related to the previous quarter. \\ \hline AdjClosevsPE & Ratio between daily price over PE in that quarter. \\ \hline AdjClosevsTTMNetEPS & Ratio between daily prices over TTM Net EPS (Trailing Twelve Months Net Earnings Per Share) in that quarter. This ratio could reflect how the current stock price compares to recent earnings over a rolling 12-month period. \\ \hline \end{tabular}
\end{table}