Identifying Latent Structures in Panel Data