Working with the Hidden Markov Model


Editor's note: This post is part of a series of blogs written by SAS interns. To check out more posts written by our awesome interns, visit our SAS Intern Life blog series webpage.

Making a difference at SAS: My current project

the hidden markov modelI am currently pursuing my Ph.D. in the Department of Economics at North Carolina State University and earlier this year I secured a graduate student internship with SAS. For the last several months I've been working as an econometric fellow in the Econometrics Time Series group and have been fortunate enough to work on some very interesting things. One project has been particularly exciting (and it matches my dissertation) - developing the new Hidden Markov model (HMM) procedure for next year’s release.

HMM has been widely applied in engineering and the Artificial Intelligence industry, including signal processing and speech recognition (like Siri and Cortana, or the automatic subtitles in YouTube). Hidden means you can observe a sequence of signals, but do not know the sequence of states the model went through to generate the signals. Markov represents the hidden states or regimes evolve according to the transition probability under some assumptions.

Naturally, the HMM can also be applied in the financial market, since the asset prices are the signals you can observe, and the states of the economy are not known to most people. The one identifies the incoming bull or bear market and can make a fortune or avoid a loss. With the new multivariate HMM model, we can identify the most possible sequence of hidden states producing the combination of signals.

For example, by evaluating the return of the portfolio of 10 different stocks, we can find out the hidden states and how these stocks perform in each state. Then, by predicting the probability of incoming states, we can select the investing strategy accordingly. The following figure demonstrates how we used HMM to break down the stock index returns using S&P 500 data. We assume there are five states of the return process and the number of states also can be totally data driven. From the graph, we can clearly see each state cover a market condition, including positive return, negative return, the one with high volatility or peaceful period, etc.


The three basic problems of HMMS that must be solved for practical use are naming evaluation, decoding and learning. The evaluation problem is computing the probability the observed sequence produced given the model. It is very useful when we want to choose the model that best matches the observations. Decoding uncovers the most possible hidden states of the model. Learning optimizes the model parameters to describe best how the signals have been produced. With the HMM procedure, we can answer all the three questions.

Playing a part in the evolution of SAS

Playing a small part in the evolution of our software has been a great experience. As a technology company and a leader in analytics, SAS has evolved a great deal in the past 40 years. Nowadays, cloud computing, self-service analytics, and the rise of open resource software are the new frontiers to conquer, and we’re responding with the newly released SAS® Viya™. Every employee is playing a part in this evolution and as an intern, I am also trying to infuse my talent to help push the evolution of the SAS technology.

Advice for future interns: Keep an open mind and you can make it

After two years of applying for an internship at SAS, I finally landed a spot at the company (perseverance pays off). Before coming to SAS I was working in a totally different industry and I know that experience – a high demanding job with a lot of pressure – has served me well here. After four months I can now say I’ve survived, thrived and contributed. There are a lot of employees at SAS who have come from other industries, and SAS is a great place where everybody loves to share their knowledge and ideas.

I have drawn great inspiration from my colleagues here at SAS. I’ve also taught myself a lot. During my study in graduate school, I have collected a list of useful resources which have helped me a lot. If you are interested in learning some programming skills and econometrics, please feel free to visit this link, where I've aggregated a lot of what I've learned. These resources certainly help me a lot in my current role.

Learn more about internships and fellowships at SAS.


About Author

Ji Shen

Graduate Intern

Ph.D. candidate in Department of Economics of NC State University. Minor in Statistics. An econometric fellow with ETS department of Advanced Analytics Division.

Related Posts

Leave A Reply

Back to Top