Page 1 of 1

How can I know the choice probability of LC with EM algorithm?

Posted: 17 May 2022, 08:38
by Hyewon
Dear Stephane,

Hello, thank you for your effort with this wonderful tool.
I am using the Latent Class model with EM algorithm.

Mine is the binary choice of Stated Preference between conventional bus vs. New transport service.
However, I have two questions related to this model.

1. When I increase the class from two into three, NaNs are produced. I differentiated the starting points. What is the problem?

2. How can I know the choice probability conditional on class membership?
For example, Class 1 prefer new transport service compared to bus , Class 2 does not have a difference between the choice, etc.
In the example code, I cannot get the result, only can get the class share of class 1, 2, 3..
In the EM algorithm, we have conditional choice probability of class s, and I saw in several literatures, How can I know with Apollo?

Here I would attach the results and code with Github gist to verify easily.
The result is also attached in the comment of the gist.
https://gist.github.com/HyewonNamgung/c ... 1171f36d45

Result:

Code: Select all

Model run at : 2022-05-17 16:13:49
Estimation method : EM algorithm (bfgs) -> Maximum likelihood (bfgs)
Model diagnosis : successful convergence
Number of individuals : 1165
Number of rows in database : 4293
Number of modelled outcomes : 4293

Number of cores used : 1
Model without mixing

LL(start) : -2848.58
LL(0, whole model) : -2975.68
LL(C, whole model) : -2888.34
LL(final, whole model) : -1910.58
Rho-square (0) : 0.3579
Adj.Rho-square (0) : 0.3492
Rho-square (C) : 0.3385
Adj.Rho-square (C) : 0.3295
AIC : 3873.16
BIC : 4038.65

LL(0,Class_1) : -2975.68
LL(final,Class_1) : -5373.64
LL(0,Class_2) : -2975.68
LL(final,Class_2) : -16094.25
LL(0,Class_3) : -2975.68
LL(final,Class_3) : -7714.03

Estimated parameters : 26
Time taken (hh:mm:ss) : 00:02:13.96
pre-estimation : 00:00:4.48
estimation : 00:01:58.94
post-estimation : 00:00:10.55
Iterations : 90 (EM) & 35 (bfgs)
Min abs eigenvalue of Hessian : 0.043924
Some eigenvalues of Hessian are positive, indicating potential problems!

Unconstrained optimisation.

Estimates:
Estimate s.e. t.rat.(0) Rob.s.e. Rob.t.rat.(0)
asc_1_a 4.597119 1.276384 3.60167 1.509443 3.04557
asc_1_b -27.856248 NaN NaN 5.009692 -5.56047
asc_1_c -15.645011 NaN NaN 38.244792 -0.40908
asc_2_a 0.000000 NA NA NA NA
asc_2_b 0.000000 NA NA NA NA
asc_2_c 0.000000 NA NA NA NA
beta_wt_a -0.005569 0.082469 -0.06753 0.089096 -0.06251
beta_wt_b -2.070511 NaN NaN 0.421405 -4.91335
beta_wt_c -2.315043 NaN NaN 4.947627 -0.46791
beta_iv_a -0.051867 0.024606 -2.10786 0.025410 -2.04120
beta_iv_b -0.054558 0.011591 -4.70710 0.009526 -5.72718
beta_iv_c -1.031415 NaN NaN 1.986223 -0.51928
beta_md_a -0.214077 0.090520 -2.36496 0.103065 -2.07710
beta_md_b -1.174756 NaN NaN 0.278043 -4.22509
beta_md_c 0.608398 NaN NaN 0.456473 1.33282
beta_bw_a -0.182590 0.196766 -0.92795 0.207327 -0.88069
beta_bw_b -2.996197 NaN NaN 0.587952 -5.09599
beta_bw_c 1.723233 NaN NaN 1.046393 1.64683
beta_tc_a -0.020958 0.004238 -4.94579 0.004364 -4.80196
beta_tc_b -0.076817 NaN NaN 0.014767 -5.20179
beta_tc_c -0.071926 NaN NaN 0.025418 -2.82972
delta_a -0.238713 0.269398 -0.88610 0.288927 -0.82621
delta_c 0.000000 NA NA NA NA
gamma_elderly_a 1.158193 0.233494 4.96027 0.240400 4.81777
gamma_commuter_a 0.123817 0.247931 0.49940 0.265574 0.46622
gamma_elderly_c 0.000000 NA NA NA NA
gamma_commuter_c 0.000000 NA NA NA NA
delta_b -0.766038 0.314646 -2.43460 0.345228 -2.21893
gamma_elderly_b 1.375340 0.263549 5.21853 0.268600 5.12041
gamma_commuter_b -0.049522 0.289815 -0.17087 0.328972 -0.15054
gamma_caruser_a 0.252084 0.259699 0.97067 0.279820 0.90088
gamma_caruser_b 0.134804 0.292552 0.46078 0.317205 0.42497
gamma_caruser_c 0.000000 NA NA NA NA

Summary of class allocation for LC model component :
Mean prob.
Class_1 0.4629
Class_2 0.2642
Class_3 0.2729
I look forward to your answer.
Thank you so much for the effort for this tool, again.

With best,
Hyewon

Re: How can I know the choice probability of LC with EM algorithm?

Posted: 29 Jun 2022, 16:56
by stephanehess
Hi

apologies for the slow reply

1. It looks like your model has ended up in a strange solution. I suggest you change the starting values a bit more and try again

2. Do you just mean LL(final,Class_1), etc

Stephane