Calculation of Class Membership in Latent Class Logit Model

9 views
Skip to first unread message

Natchaphon Leungbootnak

unread,
Jun 28, 2025, 3:18:10 AMJun 28
to Biogeme
Dear Professor Bierlaire,

I hope this message finds you well.I am currently working on latent class logit model to calculate class membership probabilities using Biogeme. To do so, I have implemented the corresponding equation (please refer to the attached screenshot). However, I am unsure whether I should use Pn(i) based on the actual choice made by the individual or on the predicted choice. I have also attached my Biogeme code for your reference. I would greatly appreciate your guidance on this matter.

Thank you very much for your time and support.
Best regards,
Natchaphon Leungbootnak
class membership equation.png
Latent class logit class membership - biogeme code.docx

Michel Bierlaire

unread,
Jun 28, 2025, 4:12:07 AMJun 28
to natcha...@gmail.com, Michel Bierlaire, Biogeme
I am not sure to understand your question.
You'll find examples of latent class models implementation here:
https://biogeme.epfl.ch/sphinx/auto_examples/swissmetro/plot_b07discrete_mixture.html
and a more advanced one here:
https://biogeme.epfl.ch/sphinx/auto_examples/swissmetro/plot_b07discrete_mixture.html
> <class membership equation.png>
>
> --
> You received this message because you are subscribed to the Google Groups "Biogeme" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to biogeme+u...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/biogeme/ba5dd476-edf4-4263-b8c6-324a16be6af7n%40googlegroups.com.
> <class membership equation.png><Latent class logit class membership - biogeme code.docx>

Michel Bierlaire
Transport and Mobility Laboratory
School of Architecture, Civil and Environmental Engineering
EPFL - Ecole Polytechnique Fédérale de Lausanne
http://transp-or.epfl.ch
http://people.epfl.ch/michel.bierlaire

Natchaphon Leungbootnak

unread,
Jun 28, 2025, 4:01:56 PMJun 28
to Michel Bierlaire, Biogeme
Dear Professor Bierlaire,

Thank you for your response, and I apologize for the lack of clarity in my previous questions. I have successfully used Biogeme to estimate the coefficients and class probabilities for a latent class logit model. I would like to classify the dataset based on the estimated class membership probabilities in order to better understand the characteristics of each class. In my case, the model includes two latent classes and two alternatives (choice 1 and choice 2). Equation are as follows:

P(predict choice 1) = P(class 1)*P(predict choice 1 | class 1) + P(class 2)*P(predict choice 1 | class 2)
P(predict choice 2) = P(class 1)*P(predict choice 2 | class 1) + P(class 2)*P(predict choice 2 | class 2)
 
So, class membership probability should be
P(posterior class 1 of each traveler) = P(class 1)*P(predict choice 1 | class 1) / P(predict choice 1) if traveler choose choice 1

or

P(posterior class 1 of each traveler) = P(class 1)*P(predict choice 2 | class 1) / P(predict choice 2) if traveler choose choice 2

My question is whether the traveler's choice indicated in the red text should be based on the actual observed choice from the data or the predicted choice from the model calculations.

Thank you very much for your time and support.
Best regards,
Natchaphon Leungbootnak

Michel Bierlaire

unread,
Jun 28, 2025, 4:12:55 PMJun 28
to Natchaphon Leungbootnak, Michel Bierlaire, Biogeme
If you want to guess the class from the data (that is, both the independent variables and the choice), the formula is indeed

P(class = 1 | choice = i, x) = P(choice = i | class = 1, x) P(class = 1 | x) / P(choice = i | x),

where i and x are the data corresponding to an individual. So, i is indeed the observed choice.
Reply all
Reply to author
Forward
0 new messages