Hi Statalists,

I am running a LCA with the gsem-command. My code is as follows:
Code:
  gsem ( var1 var2 <- _cons, family(bernoulli) link(logit)) , lclass(C 3)
  
  estat ic 
estat lcprob
estat lcmean

predict cpost*, classposteriorpr

gen class1 = 1 if cpost1>0.5
replace class1=0 if cpost1<0.5
gen class2 = 1 if cpost2>0.5
replace class2=0 if cpost2<0.5
gen class3 = 1 if cpost3>0.5
replace class3=0 if cpost3<0.5
I'd like to allocate them to the class based on their highest probability; i.e. adjusting the code so it specifically picks out the maximum value of the three probabilities, as the thresholds for the cut offs may be lower than e.g. 0.5, especially when we have a larger number of classes.
Not sure how to implement this...

Regards!