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

Joint model Log-likelihood fails at starting values

Post by ChrisDjie »

Dear Mr., Ms.,

I have a joint model of kilometers driven by car, train, and other modes.
Due to the logarithmic distributions of kilometers traveled, the km/mode is modeled as the fraction of exp(km_total) driven per mode.
Mathematically, this should work, but when estimating the model, I get the following error: Log-likelihood calculation fails at values close to the starting values!

Did I make a mistake?
If not: is there a way to avoid this issue in Apollo?

Many thanks,
Chris

PS. I am trying to built a more complicated latent class model. I first tried building this model in biogeme, but it was too sensitive to the starting values. I hope to have better luck in Apollo.
Last edited by ChrisDjie on 17 Aug 2023, 08:58, 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

I'm not sure I follow your model specification

Can you write it down mathematically?

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,

Thank you for your very quick reply.
Does this help?

...

Whereby ld is a parameter representing the log of kilometers traveled, U is the utility of each mode m, F is the fraction of kilometers traveled per mode m, and dm is the number of kilometers traveled with mode m (the target variable).

Best regards,

Chris
Last edited by ChrisDjie on 17 Aug 2023, 09:00, 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 »

Okay, this is what I thought you were doing. Is this based on actual theory, as you seem to have some circular dependencies here.

Did you consider instead using a discrete continuous model?
--------------------------------
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,

We are fairly certain there are no circular dependencies in the model.
The estimation issue seems to be purely numerical/computational.

We did get a simplified 2class version of this model (km/mode for car-owning and carless households) working in biogeme.
The results were sensible.

Best, Chris
ChrisDjie
Posts: 11
Joined: 07 Jul 2023, 10:20

Re: Joint model Log-likelihood fails at starting values

Post by ChrisDjie »

*Apologies: an extended 2class version of this model.Yet, our intended 3class model did not work due to computational issues.
stephanehess
Site Admin
Posts: 998
Joined: 24 Apr 2020, 16:29

Re: Joint model Log-likelihood fails at starting values

Post by stephanehess »

For now, there isn't really a convergence issue, but a purely numerical issue. If you can share your code and data with me outside the forum, then I'll have a look at that for you
--------------------------------
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,

Thank you.
I cannot share my data though: it is (very) privacy sensitive because it is based on residential addresses and license plates.

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 »

I understand. That makes it difficult of course for me to help debug your model. Essentially, I believe your starting values are leading to an initial failure, but it could be due to the coding of the model.

You could try and see what you get out by simply calculating the log-likelihood.

After defining your model, try

Code: Select all

tmp=apollo_probabilities(apollo_beta,apollo_inputs,functionality="output")
--------------------------------
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,

Thank you for the tip.
Something came up in the meantime, but I'll make sure to follow up after the holidays.

Best regards,

Chris
Post Reply