Switching Regression Models and Causal Inference in the Presence of Discrete Latent Variables