Stratification of patient trajectories using covariate latent variable models