Abstract
The underlying market trends that drive stock price fluctuations are often referred to in terms of bull and bear markets. Optimal stock portfolio selection methods need to take into account these market trends; however, the bull and bear market states tend to be unobserved and can only be assigned retrospectively. We fit a linked hidden Markov model (LHMM) to relative stock price changes for S&P 500 stocks from 2011–2016 based on weekly closing values. The LHMM consists of a multivariate state process whose individual components correspond to HMMs for each of the 12 sectors of the S&P 500 stocks. The state processes are linked using a Gaussian copula so that the states of the component chains are correlated at any given time point. The LHMM allows us to capture more heterogeneity in the underlying market dynamics for each sector. In this study, stock performances are evaluated in terms of capital gains using the LHMM by utilizing historical stock price data. Based on the fitted LHMM, optimal stock portfolios are constructed to maximize capital gain while balancing reward and risk. Under out-of-sample testing, the annual capital gain for the portfolios for 2016–2017 are calculated. Portfolios constructed using the LHMM are able to generate returns comparable to the S&P 500 index.
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs13571-022-00290-5/MediaObjects/13571_2022_290_Fig1_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs13571-022-00290-5/MediaObjects/13571_2022_290_Fig2_HTML.png)
Similar content being viewed by others
References
Baum, L.E. and Petrie, T. (1966). Statistical inference for probabilistic functions of finite state Markov chains. Ann. Math. Stat. 37, 1554–1563.
Brechmann, E.C., Czado, C. and Aas, K. (2012). Truncated regular vines in high dimensions with application to financial data. Cana. J. Stat. 40, 68–85.
Dempster, A.P., Laird, N.M. and Rubin, D.B. (1977). Maximum likelihood from incomplete data via the EM algorithm. J. R. Stat. Soc., 39.
Elliott, R. and van der Hoek, J. (1997). An application of hidden Markov models to asset allocation problems (*). Finance Stochast. 1, 229–238. https://doi.org/10.1007/s007800050022.
Elliott, R., Siu, T.K. and Alex, B. (2010). On mean-variance portfolio selection under a hidden Markovian regime-switching model. Econ. Model.27, 678–686.
Ensor, K.B. and Koev, G.M. (2014). Computational finance: Correlation, volatility, and markets. WIREs Comput. Stat. 6, 326–340. https://doi.org/10.1002/wics.1323.
Fiecas, M., Franke, J., von Sachs, R. et al. (2017). Shrinkage estimation for multivariate hidden Markov models. J. Am. Stat. Assoc. 112, 326–340. https://doi.org/10.1080/01621459.2016.1148608.
Hamilton, J.D. (1989). A new approach to the economic analysis of nonstationary time series and the business cycle. Econometrica 57, 357–384.
Hassan, M.R. and Nath, B. (2005). Stock market forecasting using hidden Markov model: A new approach, p. 192–96.
Ji, Q. (2019). Computational methods for hidden Markov models with applications. Ph.D. Thesis Department of Mathematics and Statistics. University of Maryland, Baltimore County.
Ji, Q. and Neerchal, N.K. (2019). Creating stock portfolios using hidden Markov models, p. 2105–2118.
Joe, H. and Xu, J.J. (1996). The Estimation Method of Inference Functions for Margins for Multivariate Models. Tech. Rep. No. 166 Department of Statistics. University of British Columbia, Vancouver.
Kole, E. and Dijk, v D (2016). How to identify and forecast bull and bear markets? J. Appl. Econ., 32.
Kruskal, W.H. (1958). Ordinal measures of association. J. Am. Stat. Assoc. 53, 814–861.
Majumder, R. (2021). Hidden Markov Models for High Dimensional Data with Geostatistical Applications. Ph.D. Thesis Department of Mathematics and Statistics. University of Maryland, Baltimore County.
Malkiel, BG (2019). A Random Walk Down Wall Street: Including A Life-Cycle Guide To Personal Investing, 12th edn. W.W. Norton & Company.
Markowitz, H. (1952). Portfolio selection. J. Financ. 7, 77–91.
McGrory, C.A. and Titterington, D.M. (2009). Variational Bayesian analysis for hidden Markov models. Australian and New Zealand J. Stat. 51, 227–244.
Mhanna, M. and Bauwens, W. (2012). A stochastic space-time model for the generation of daily rainfall in the Gaza Strip. Int. J. Climatol. 32, 1098–1112.
Nelsen, RB (2006). An Introduction to Copulas, 2nd edn. Springer.
Nguyen, N. (2018). Hidden Markov model for stock trading. Int. J. Financ. Stud. 36, 192–96.
Nguyen, N. and Nguyen, D. (2015). Hidden Markov model for stock selection. Risks 3, 455–473.
Rabiner, L.R. (1989). A tutorial on hidden Markov models and selected applications in speech recognition. Proc. IEEE, 77.
Rizzo, ML (2019). Statistical Computing with R, 2nd edn. Chapman & Hall/CRC.
Serfozo, R (2009). Basics of Applied Stochastic Processes. Springer.
Varin, C., Reid, N. and Firth, D. (2011). An overview of composite likelihood methods. Stat. Sin. 21, 5–42.
Visser, I and Speekenbrink, M (2010). depmixS4: An R package for hidden Markov models. J. Stat. Softw. 36, 7, 1–21. http://www.jstatsoft.org/v36/i07/.
Visser, I and Speekenbrink, M (2019). Hidden Markov Models with R. Springer.
Viterbi, A. (1967). Error bounds for convolutional codes and an asymptotically optimum decoding algorithm. IEEE Trans. Inf. Theory 13, 260–269.
Xu, J and Cao, L (2021). High-dimensional cross-market dependence modeling and portfolio forecasting by copula variational LSTM. Available at SSRN: https://doi.org/10.2139/ssrn.3881474.
Yeo, I.K. and Johnson, R.A. (2000). A new family of power transformations to improve normality or symmetry. Biometrika 87, 954–959.
Acknowledgements
The hardware used in the computational studies is part of the UMBC High Performance Computing Facility (HPCF). The facility is supported by the U.S. National Science Foundation through the MRI program (grant nos. CNS–0821258, CNS–1228778, and OAC–1726023) and the SCREMS program (grant no. DMS–0821311), with additional substantial support from the University of Maryland, Baltimore County (UMBC). See hpcf.umbc.edu for more information on HPCF and the projects using its resources. Reetam Majumder was supported by the Joint Center for Earth Systems Technology and by the HPCF as a Research Assistant.
Author information
Authors and Affiliations
Corresponding author
Ethics declarations
Conflict of Interest
The authors have no competing interests to declare that are relevant to the content of this article.
Additional information
Publisher’s Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Qing Ji and Nagaraj K. Neerchal contributed equally to this work.
Rights and permissions
About this article
Cite this article
Majumder, R., Ji, Q. & Neerchal, N.K. Optimal Stock Portfolio Selection with a Multivariate Hidden Markov Model. Sankhya B 85 (Suppl 1), 177–198 (2023). https://doi.org/10.1007/s13571-022-00290-5
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s13571-022-00290-5
Keywords and phrases
- Linked hidden Markov model
- multivariate Markov chain
- stochastic simulations
- portfolio allocation
- Gaussian copula