Hidden Markov Model Analysis of the Nifty 50 Index

This project utilizes a Gaussian Hidden Markov Model to perform a statistical analysis of the Nifty 50 stock index. The notebook begins by importing essential Python libraries such as hmmlearn, pandas, yfinance, and matplotlib. Financial data is loaded from a CSV file, and daily data is preprocessed and resampled to a monthly frequency.

The core of the analysis involves a loop that tests a range of possible hidden states (from 2 to 6) for the HMM. For each potential number of states, the model is trained using the Baum-Welch algorithm on a sliding window of the monthly data. The log-likelihoods are then used to calculate and store various information criteria—Akaike Information Criterion (AIC), Bayesian Information Criterion (BIC), Hannan-Quinn Criterion (HQC), and Consistent Akaike Information Criterion (CAIC)—to determine the optimal number of hidden states for the model.

This project analyzes the Nifty 50 stock index using a Gaussian Hidden Markov Model (HMM) to find the optimal number of hidden states by evaluating multiple information criteria.