kim0sun / glca

An R Package for Multiple-Group Latent Class Analysis
https://kim0sun.github.io/glca/
GNU General Public License v3.0
10 stars 2 forks source link

Extracting Class or Clusters as dataframe #8

Closed Wentemi closed 2 years ago

Wentemi commented 2 years ago

Hi Prof Sun, Thank you for your wonderful package. After running the model is there a way of extracting the predicted class for observation ? I tried using the max probability from the lca$posterior matrix to classify for each observation, it doesn't seem to be right. Any points will be appreciated.

kim0sun commented 2 years ago

You can use lca$posterior But the object can be a list of matrix. Thus, you should assign class each matrix separately. Note following command:

lapply(lca$posterior, apply, 1, which.max)

If the command fails, please show me your full code. Thank you.

sirwentemi commented 2 years ago

Thank you very much it worked perfectly.