Macro data analysis

Using R or matlab to do the following

Step 1: apply PCA to determine the number of latent factors using the macro indicators.

Step 2: estimate a hidden Markov model and find the optimal number of regimes (states

Sample Solution