A two-stage approach to the analysis of longitudinal type categorical data