This study develops parametric and semiparametric hidden Markov models to analyze univariate and multivariate longitudinal data. The proposed models generalize conventional regression models to allow bidirectional transition between hidden states and conventional hidden Markov models to allow latent variables and functional covariate effects. We develop maximum likelihood and Bayesian approaches, along with efficient Markov chain Monte Carlo algorithm, to conduct parameter estimation. The asymptotic properties of the parameter estimators are established. The proposed methodologies are applied to the analysis of two real-life datasets concerning the prevention of cocaine use and the risk factors of Alzheimer’ disease.