I would like to do the latent class regression. The sample is at firm-year level. Normally, the gsem or fmm could help us to group those firm-year observations into classes based on the posterior probability.

For example:
fmm 2: regress y x1 x2 x3
predict classpost*, classposteriorpr
generate expclass = 1 + (classpost2>0.5)


I was wondering whether it is possible to group the firms instead of firm-years into latent classes.


Thanks so much!