Markov-switching autoregressive latent variable models for longitudinal data