Application of a Hybrid Model of Markov Switching and Machine Learning for Predicting Stock Prices
Hosseininesaz, Hamid (2024-06-25)
Hosseininesaz, Hamid
25.06.2024
Julkaisun pysyvä osoite on
https://urn.fi/URN:NBN:fi-fe2024062558129
https://urn.fi/URN:NBN:fi-fe2024062558129
Tiivistelmä
The stock market is considered one of the most attractive markets for investors, as there is no limit to the amount of capital that can be invested. The most important goal of investors in the stock market is to make a profit. For this reason, knowing the behavior and predicting the movement of the stock price plays an important role in making profits. Therefore, many researchers have tried to develop models to accurately predict stock prices. However, due to the complexity of the stock market and the influence of various factors on the stock price, there is still no model that can accurately predict the stock price. The stock price has two linear and non-linear components. The linear component shows the trend of the stock price, and the non-linear component shows the price fluctuations, which can be due to emotions, expectations, news, etc. For example, the linear component can indicate the overall trend of a stock's price increase or decrease, while the non-linear component indicates momentary and unexpected fluctuations and changes caused by external factors.
Due to the complexity and rapid changes in the stock market, using a single model to predict prices may be insufficient (Pan, 2010). Therefore, this study presents a hybrid model to pre-dict the trend and price fluctuations. The proposed hybrid model is a combination of the Markov Switching (MS) model for predicting stock trends and the Long Short-Term Memory (LSTM) model for predicting price fluctuations. The MS model can recognize changes in dif-ferent market regimes, while the LSTM model is able to learn complex and long-term pat-terns in data due to its special structure in neural networks.
In this study, the historical data of the stock prices of five companies (Digia, Kone B, Nokia, UPM Kymmene and Wartsila) from January 2019 to December 2023 were used. This data includes daily stock prices. The use of historical data allows us to evaluate the performance of the models under real market conditions. To verify the performance of the proposed model, we compared it with MS and LSTM models. For this purpose, the three criteria Root Mean Squared Error (RMSE), Mean Absolute Percentage Error (MAPE) and R-Squared (R2) were used. The results show that the MS model has the best performance in predicting stock prices compared to the other models and the proposed model has the worst performance.
To increase the robustness and validity of the results, the models were compared again in a weekly time frame. For this purpose, the historical data of the stock prices of the listed com-panies in the period from January 2000 to May 2024 were used. The results of comparing the performance of the models showed that the proposed model outperformed other models in predicting stock prices for all criteria for all stocks. This could be due to the greater volatility in the weekly time frame than in the daily time frame. Therefore, the proposed model is more efficient for markets with higher volatility, such as the cryptocurrency market.
Due to the complexity and rapid changes in the stock market, using a single model to predict prices may be insufficient (Pan, 2010). Therefore, this study presents a hybrid model to pre-dict the trend and price fluctuations. The proposed hybrid model is a combination of the Markov Switching (MS) model for predicting stock trends and the Long Short-Term Memory (LSTM) model for predicting price fluctuations. The MS model can recognize changes in dif-ferent market regimes, while the LSTM model is able to learn complex and long-term pat-terns in data due to its special structure in neural networks.
In this study, the historical data of the stock prices of five companies (Digia, Kone B, Nokia, UPM Kymmene and Wartsila) from January 2019 to December 2023 were used. This data includes daily stock prices. The use of historical data allows us to evaluate the performance of the models under real market conditions. To verify the performance of the proposed model, we compared it with MS and LSTM models. For this purpose, the three criteria Root Mean Squared Error (RMSE), Mean Absolute Percentage Error (MAPE) and R-Squared (R2) were used. The results show that the MS model has the best performance in predicting stock prices compared to the other models and the proposed model has the worst performance.
To increase the robustness and validity of the results, the models were compared again in a weekly time frame. For this purpose, the historical data of the stock prices of the listed com-panies in the period from January 2000 to May 2024 were used. The results of comparing the performance of the models showed that the proposed model outperformed other models in predicting stock prices for all criteria for all stocks. This could be due to the greater volatility in the weekly time frame than in the daily time frame. Therefore, the proposed model is more efficient for markets with higher volatility, such as the cryptocurrency market.