user3731653 - 10 months ago 126

R Question

I am using poLCA to generate posterior latent class membership probabilities. I need to assign each of 477 participants to one of three classes. The process is a bit tedious, as I am having to look at each of three probabilities for every case. Is there a way to have R generate a dummy variable for latent class membership based on the posterior estimations? Said another way, is there a code that will generate latent class membership assignments based on the optimal probability of membership?

Answer

Look at `predclass`

, the vector of predicted class memberships by modal assignment, as indicated on the `poLCA`

help page. For example, if you do

```
data(values)
two.class.model = poLCA(cbind(A,B,C,D)~1,values,nclass=2)
```

then `two.class.model$predclass`

displays the assignment of each record to one of two classes.

Source (Stackoverflow)