Hidden Markov Model for Stock Selection
Abstract
:1. Introduction
2. A Brief Introduction of the Hidden Markov Model
 Length of observation data, T
 Number of states, N
 Number of symbols per state, M
 Observation sequence, $O=\{{O}_{t},t=1,2,\dots ,T\}$
 Hidden state sequence, $Q=\{{q}_{t},t=1,2,\dots ,T\}$
 Possible values of each state, $\{{S}_{i},i=1,2,\dots ,N\}$
 Possible symbols per state, $\{{v}_{k},k=1,2,\dots ,M\}$
 Transition matrix, $A=\left({a}_{ij}\right)$, where ${a}_{ij}=P({q}_{t}={S}_{j}{q}_{t1}={S}_{i}),\phantom{\rule{3.33333pt}{0ex}}i,j=1,2,\dots ,N$
 Vector of initial probability of being in state (regime) ${S}_{i}$ at time $t=1$, $p=\left({p}_{i}\right)$, where ${p}_{i}=P({q}_{1}={S}_{i}),\phantom{\rule{3.33333pt}{0ex}}i=1,2,\dots ,N$
 Observation probability matrix, $B=\left({b}_{ik}\right)$, where ${b}_{ik}=P({O}_{t}={v}_{k}{q}_{t}={S}_{i}),\phantom{\rule{3.33333pt}{0ex}}i=1,2,...,N$ and $k=1,2,\dots ,M.$
 Given the observation data $O=\{{O}_{t},t=1,2,\dots ,T\}$ and the model parameters $\lambda =(A,B,p)$, how do we compute the probabilities of the observations, $P\left(O\right\lambda )$?
 Given the observation data $O=\{{O}_{t},t=1,2,\dots ,T\}$ and the model parameters $\lambda =(A,B,p)$, how do we choose the best corresponding state sequence $Q=\{{q}_{1},{q}_{2},...,{q}_{T}\}$?
 Given the observation data $O=\{{O}_{t},t=1,2,\dots ,T\}$, how do we calibrate HMM parameters, $\lambda =(A,B,p)$, to maximize $P\left(O\right\lambda )$?
2.1. Forward Algorithm
The forward algorithm. 

2.2. Backward Algorithm
2.3. The Viterbi Algorithm
The backward algorithm. 

The Viterbi algorithm. 

2.4. Baum–Welch Algorithm
The Baum–Welch algorithm 

3. Describe the Model and Data
3.1. Data Selections
 Inflations: we use the 12month changes (%) in CPI where CPI is the consumer price indexes, the monthly changes in the prices paid by urban consumers for a representative basket of goods and services of all items (not seasonally adjusted). Data source: Bureau of Labor Statistics, U.S. Department of Labor (http://www.bls.gov/cpi/).
 Industrial production index, INDPRO: we use the monthly changes of real output for all facilities located in the United States manufacturing, mining and electric and gas utilities (excluding those in U.S. territories). Data source: Board of Governors of the Federal Reserve System (http://www.federalreserve.gov/).
 Stock market index: we use onemonth changes of the S&P 500 index where the Standard & Poor’s 500 (S&P 500) is an American stock market index based on the market capitalizations of 500 large companies having common stock listed on the New York stock exchange (NYSE) or the National Association of Securities Dealers Automated Quotations (NASDAQ). Data source: Yahoo Finance (http://finance.yahoo.com/).
 Market volatility: we use the Chicago Board Options Exchange Market (CBOE) Volatility Index, VIX. Data source: Chicago Board of Options Exchange (http://www.cboe.com/).
 Earnings/price (E/P) is calculated by the earning accumulation over the trailing twelve months of the stock divided by weekend price. A higher number indicates greater value for each unit of earnings, which tends to drive higher stock returns.
 The free cash flow/enterprise value is calculated by the cash flow minus cash dividends minus capital expenditures divided by market value of equity plus debt. A higher number is better.
 The sales/enterprise value is calculated by the sales accumulation over the trailing twelve months of the stock divided by the market value of equity plus debt (enterprise value). A higher sales/enterprise value signifies that each unit of a stock’s value is used to generate more sales, which normally leads to higher stock returns.
 Longterm earning per share (LT EPS) growth: projected longterm growth rate of earning per share based on a fiveyear moving regression trend line. A high earnings growth rate normally leads to higher future returns.
 Longterm sales (LT sales) growth: projected longterm growth rate of sales based on a fiveyear moving regression trend line. A high sales growth rate normally leads to higher future returns.
3.2. Description of Model
4. Implementations and Results
4.1. Regimes of Macro Variables
4.2. Stock Selection
5. Conclusions
Acknowledgments
Author Contributions
A. Stock Performance on Different Economic Regimes
Conflicts of Interest
References
 C. Chen. “How well can we predict currency crises? ” In Evidence from a threeregime MarkovSwitching model. Davis, CA, USA: Department of Economics, UC Davis, 2005. [Google Scholar]
 M.R. Hassan, and B. Nath. “Stock Market Forecasting Using Hidden Markov Models: A New approach.” In Proceeding of the IEEE fifth International Conference on Intelligent Systems Design and Applications, Wroclaw, Poland, 8–10 September 2005.
 M. Kritzman, S. Page, and D. Turkington. “Regime Shifts: Implications for Dynamic Strategies.” Financ. Anal. J. 68 (2012). [Google Scholar] [CrossRef]
 M. Guidolin, and A. Timmermann. “Asset Allocation under Multivariate Regime Switching.” J. Econ. Dyn. Control 31 (2007): 3503–3544. [Google Scholar] [CrossRef]
 A. Ang, and G. Bekaert. “International Asset Allocaion with Regime Shifts.” Rev. Financ. Stud. 15 (2002): 1137–1187. [Google Scholar] [CrossRef]
 N. Nguyen. “Probabilistic Methods in Estimation and Prediction of Financial Models.” In Electronic Theses. Tallahassee, FL, USA: Treatises and Dissertations, Florida State University, 2014, p. 9059. [Google Scholar]
 B. Nobakht, C.E. Joseph, and B. Loni. “Stock market analysis and prediction using hidden markov models.” In Proceeding of the 2012 Students Conference on Engineering and Systems (SCES), Allahabad, Uttar Pradesh, India, 16–18 March 2012; pp. 1–4.
 L.E. Baum, and T. Petrie. “The Annals of Mathematical Statistics.” Stat. Inference Probab. Funct. Finite State Markov Chains 37 (1966): 1554–1563. [Google Scholar]
 L.E. Baum, T. Petrie, G. Soules, and N. Weiss. “A maximization technique occurring in the statistical analysis of probabilistic functions of Markov chains.” Ann. Math. Stat. 41 (1970): 164–171. [Google Scholar] [CrossRef]
 S.E. Levinson, L.R. Rabiner, and M.M. Sondhi. “An introduction to the application of the theory of probabilistic functions of Markov process to automatic speech recognition.” Bell Syst. Techn. J. 62 (1983): 1035–1074. [Google Scholar] [CrossRef]
 X. Li, M. Parizeau, and R. Plamondon. “Training Hidden Markov Models with Multiple Observations—A Combinatorial Method.” IEEE Trans. PAMI 22 (2000): 371–377. [Google Scholar]
 L.E. Baum, and J.A. Egon. “An inequality with applications to statistical estiation for probabilistic functions of Markov process and to a model for ecnogy.” Bull. Am. Meteorol. Soc. 73 (1967): 360–363. [Google Scholar] [CrossRef]
 L.E. Baum, and G.R. Sell. “Growth functions for transformations on manifolds.” Pac. J. Math 27 (1968): 211–227. [Google Scholar] [CrossRef]
 L.R. Rabiner. “A Tutorial on Hidden Markov Models and Selected Applications in Speech Recognition.” IEEE 77 (1989): 257–286. [Google Scholar] [CrossRef]
 G.D. Forney. “The Viterbi algorithm.” IEEE 61 (1973): 268–278. [Google Scholar] [CrossRef]
 A.J. Viterbi. “Error bounds for convolutional codes and an asymptotically optimal decoding algorithm.” IEEE Trans. Informat. Theory IT13 (1967): 260–269. [Google Scholar] [CrossRef]
 V. A. Petrushin. “Hidden Markov Models: Fundamentals and Applications.” http://www.cis.udel.edu/ lliao/cis841s06/hmmtutorialpart2.pdf (accessed on 28 October 2015).
© 2015 by the authors; licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution license (http://creativecommons.org/licenses/by/4.0/).
Share and Cite
Nguyen, N.; Nguyen, D. Hidden Markov Model for Stock Selection. Risks 2015, 3, 455473. https://doi.org/10.3390/risks3040455
Nguyen N, Nguyen D. Hidden Markov Model for Stock Selection. Risks. 2015; 3(4):455473. https://doi.org/10.3390/risks3040455
Chicago/Turabian StyleNguyen, Nguyet, and Dung Nguyen. 2015. "Hidden Markov Model for Stock Selection" Risks 3, no. 4: 455473. https://doi.org/10.3390/risks3040455