Indirect estimation of Markov Swithing models with endogenous switching