I am new to state-space models with Markov-switching, but the reason I am interested in this is because I want to model trend productivity in the fashion of Kahn & Rich (2007). In general, I am new to state-space or Markov-switching models. For all of you who have experience in these models, I would like to ask for some introductory literature to state-space models with Markov-switching (other than Kim & Nelson 1999). Also, I would like to ask what is the best approach to studey these models i.e. should I first understand Markov-switching models and then state-space models or viceversa? Also I would appreciate if you know of any code (Matlab, R, Stata) that uses these models, just to see how it all works.
Thank you all for your help.