Important: Read this before posting to this forum

  1. This forum is for questions related to the use of Apollo. We will answer some general choice modelling questions too, where appropriate, and time permitting. We cannot answer questions about how to estimate choice models with other software packages.
  2. There is a very detailed manual for Apollo available at http://www.ApolloChoiceModelling.com/manual.html. This contains detailed descriptions of the various Apollo functions, and numerous examples are available at http://www.ApolloChoiceModelling.com/examples.html. In addition, help files are available for all functions, using e.g. ?apollo_mnl
  3. Before asking a question on the forum, users are kindly requested to follow these steps:
    1. Check that the same issue has not already been addressed in the forum - there is a search tool.
    2. Ensure that the correct syntax has been used. For any function, detailed instructions are available directly in Apollo, e.g. by using ?apollo_mnl for apollo_mnl
    3. Check the frequently asked questions section on the Apollo website, which discusses some common issues/failures. Please see http://www.apollochoicemodelling.com/faq.html
    4. Make sure that R is using the latest official release of Apollo.
  4. If the above steps do not resolve the issue, then users should follow these steps when posting a question:
    1. provide full details on the issue, including the entire code and output, including any error messages
    2. posts will not immediately appear on the forum, but will be checked by a moderator first. This may take a day or two at busy times. There is no need to submit the post multiple times.

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

Ask questions about model specifications. Ideally include a mathematical explanation of your proposed model.
Post Reply
Hyewon
Posts: 11
Joined: 28 Dec 2020, 04:30

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

Post 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
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

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

Post 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
--------------------------------
Stephane Hess
www.stephanehess.me.uk
Post Reply