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.

Joint model Log-likelihood fails at starting values

Ask questions about errors you encouunter. Please make sure to include full details about your model specifications, and ideally your model file.
ChrisDjie
Posts: 11
Joined: 07 Jul 2023, 10:20

Re: Joint model Log-likelihood fails at starting values

Post by ChrisDjie »

Dear Stephane,

It seems that the loglikelihood is basically zero for some households (while reasonable for others).
For instance, the first 25 loglikelihoods of kilometers traveled are as attached.

What would you suggest?

Thank you,

Chris
Loglikelihoods_2class_model.png
Loglikelihoods_2class_model.png (75.22 KiB) Viewed 3823 times
stephanehess
Site Admin
Posts: 998
Joined: 24 Apr 2020, 16:29

Re: Joint model Log-likelihood fails at starting values

Post by stephanehess »

does the code also give you the LL for the combined model, not just the individual components? maybe show me the code again too, please?
--------------------------------
Stephane Hess
www.stephanehess.me.uk
ChrisDjie
Posts: 11
Joined: 07 Jul 2023, 10:20

Re: Joint model Log-likelihood fails at starting values

Post by ChrisDjie »

Dear Stephane,

My apologies, see attached the LL for the combined model.
This LL should be equal to the following equation: LL_total = log(P_c0*(L_car_c0*L_pt_c0*L_other_c0) + P_c1*(L_Car_c1*L_pt_c1*L_Other_c1) whereby L is the likelihood.

The model successfully run in Biogeme, but I ran into problems when trying to add a c2 class (for households owning 2+ cars).
I then tried to replicate the model in Apollo (see code below).
Again, I am not entirely sure this code is correct as I am used to programming in Biogeme.

Thank you so much,

Chris
Attachments
Loglikelihoods_2class_model_inctotal.png
Loglikelihoods_2class_model_inctotal.png (103.48 KiB) Viewed 3807 times
Last edited by ChrisDjie on 17 Aug 2023, 08:59, edited 1 time in total.
stephanehess
Site Admin
Posts: 998
Joined: 24 Apr 2020, 16:29

Re: Joint model Log-likelihood fails at starting values

Post by stephanehess »

Hi

so none of these are actually zero. Close to zero is fine. But have you played around with starting values?

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
ChrisDjie
Posts: 11
Joined: 07 Jul 2023, 10:20

Re: Joint model Log-likelihood fails at starting values

Post by ChrisDjie »

Oh, I am afraid some are.
I will have a look at the original data behind the entries that resulted in zero LL_total.

Thank you,

Chris
Attachments
Loglikelihoods_2class_model_zeros.png
Loglikelihoods_2class_model_zeros.png (97.77 KiB) Viewed 3809 times
ChrisDjie
Posts: 11
Joined: 07 Jul 2023, 10:20

Re: Joint model Log-likelihood fails at starting values

Post by ChrisDjie »

Dear Stephane,

The entries with zero total likelihoods were all households that traveled many kilometers by motors/mopeds.
I thus excluded all kms by private motorized modes that are not cars.
The total likelihoods were never zero after this intervention.
The likelihoods of kilometers traveled by modes within a specific class, like carlike kms for households that do not own a car (c0), were sometimes zero though.
There is nothing weird or typical about the underlying entries.
The model now runs, which is an improvement, but the results say that the likelihood within one component is zero (which makes sense).
Depending on the starting values, this component is either in the no-car (c0) or car-owning (c1) class.

Please note that I already sucessfully ran this version of the model in Biogeme.
However, the model was too sensitive to the starting values, making it impossible to add another class (multiple cars, c2).
I was hoping that Apollo could help me fix the issue.

Do you have any remaining ideas?

Best regards and many thanks,

Chris
stephanehess
Site Admin
Posts: 998
Joined: 24 Apr 2020, 16:29

Re: Joint model Log-likelihood fails at starting values

Post by stephanehess »

Hi Chris

zero LL in one class is not a problem as the average across classes will then still be non-zero

LC is notoriously sensitive to starting values. You could try a starting value search using apollo_searchStart

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
ChrisDjie
Posts: 11
Joined: 07 Jul 2023, 10:20

Re: Joint model Log-likelihood fails at starting values

Post by ChrisDjie »

Dear Stephane,

Good to know that the zero LLs within one class are okay.
When running the searchStart function, I get: "100 candidates removed due to non-finite starting LL. 0 remain."

Best regards,

Chris
stephanehess
Site Admin
Posts: 998
Joined: 24 Apr 2020, 16:29

Re: Joint model Log-likelihood fails at starting values

Post by stephanehess »

Chris

sounds like a starting values issue again, maybe with your sigmas?

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
Post Reply