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.

Weight check inside apollo_makeLogLike

Ask questions about errors you encouunter. Please make sure to include full details about your model specifications, and ideally your model file.
Post Reply
tomas.rossetti
Posts: 18
Joined: 16 Jul 2020, 14:51

Weight check inside apollo_makeLogLike

Post by tomas.rossetti »

I am trying to estimate a latent class choice model using the EM algorithm. For some reason, I am getting the following error message:

Code: Select all

Error in apollo_makeLogLike(apollo_beta, apollo_fixed, apollo_probabilities,  : 
  When using weights, apollo_weighting should be called inside apollo_probabilities.
This error pops up when I'm running my code using a Windows computer, but not a Mac. Do you know what could be causing this?

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

Re: Weight check inside apollo_makeLogLike

Post by stephanehess »

Tomas

which version of Apollo are you using?

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
tomas.rossetti
Posts: 18
Joined: 16 Jul 2020, 14:51

Re: Weight check inside apollo_makeLogLike

Post by tomas.rossetti »

Hi Stephane,

Windows is running version 0.2.1 and Mac is running version 0.1.0.

I forgot to mention that the following line seems to have the problem:

Code: Select all

model = apollo_estimate(apollo_beta, apollo_fixed, 
                          apollo_probabilities_class, apollo_inputs,
                          estimate_settings=list(writeIter=FALSE,silent=TRUE,hessianRoutine="none"))
apollo_probabilities_class is very similar to the example you provide:

Code: Select all

apollo_probabilities_class=function(apollo_beta, apollo_inputs, functionality="estimate"){
  ### Attach inputs and detach after function exit
  apollo_attach(apollo_beta, apollo_inputs)
  on.exit(apollo_detach(apollo_beta, apollo_inputs))
  
  ### Create list of probabilities P
  P = list()
  
  ### Load posterior class allocation probabilities from inputs
  h_1=apollo_inputs$h1
  h_2=apollo_inputs$h2
  h_3=apollo_inputs$h3
  h_4=apollo_inputs$h4
  h_grouped=list(h_1,h_2,h_3,h_4)
  
  ### Take logs of class allocation probabilities
  log_pi_values=lapply(pi_values,log)
  
  ### Define model that aims to minimise difference between posterior and unconditional class allocation probabilities
  P[["model"]]=exp(Reduce('+', mapply('*',h_grouped,log_pi_values,SIMPLIFY = FALSE)))
  
  ### Prepare and return outputs of function
  P = apollo_prepareProb(P, apollo_inputs, functionality)
  return(P)
}
Thank you very much,

Tomás
stephanehess
Site Admin
Posts: 998
Joined: 24 Apr 2020, 16:29

Re: Weight check inside apollo_makeLogLike

Post by stephanehess »

Tomas

in the new version of Apollo, there is an apollo_lcEM function so you don't need to bother with the separate apollo_probabilities_class etc anymore

I've put them on the website now, replacing the old ones.

We've been busy developing Apollo but have not kept the website as up to date as we would wish. That'll happen next

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
tomas.rossetti
Posts: 18
Joined: 16 Jul 2020, 14:51

Re: Weight check inside apollo_makeLogLike

Post by tomas.rossetti »

Excellent, I'll take a look as soon as they're uploaded.

Thank you Stephane
alvarogutyerrez
Posts: 12
Joined: 19 Jan 2021, 07:53
Contact:

Re: Weight check inside apollo_makeLogLike

Post by alvarogutyerrez »

Dear Stephane and Tomas,

I came across the same error as the OP. Additionally, I noticed that even though the documentation has been updated from version 0.2.3 onwards, the example 28 has not been updated on the website yet, and apparently it is not backward compatible with the new versions.

Is it possible to get access to the latest version of the example_28, please? I know that the example it's partially provided on the documentation, however, given that the function `apollo::apollo_lcEM()` requires disabling apollo cheks it's a little bit harder to debug.

Thank you in advance!

Best wishes
Álvaro A. Gutiérrez-Vargas
https://alvarogutyerrez.github.io/
stephanehess
Site Admin
Posts: 998
Joined: 24 Apr 2020, 16:29

Re: Weight check inside apollo_makeLogLike

Post by stephanehess »

Oops, sorry, the files have been updated now
--------------------------------
Stephane Hess
www.stephanehess.me.uk
Post Reply