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. We check the forum at least twice a week. It may thus take a couple of days for your post to appear and before we reply. There is no need to submit the post multiple times.

apollo_searchStart Test2 Conditions?

Report bugs or highlight issues with Apollo functions. At a minimum, please include the part of the output where you believe the bug is manifested. Ideally, please share your model file.
Post Reply
johnathan
Posts: 8
Joined: 06 Mar 2025, 16:37

apollo_searchStart Test2 Conditions?

Post by johnathan »

I am not sure if test2 is applying its conditions properly in apollo_searchStart. This is it's description from the beginning of the code:
Tolerance for test 2. A candidate is discarded if the norm of its gradient is smaller than \code{gTest} AND its LL is further than \code{llTest} from a better 
This is the code: 

Code: Select all

# Apply tests only if it hasn't converged and is not the best LL of the stage if(length(betterLLRows)>0 & !converged[j]){ # Test 1: Distance in parameter space to a better one betterParams <- candidates[[s+1]][betterLLRows,] if(length(betterLLRows)==1) betterParams <- matrix(betterParams, nrow=1) distParam <- apply(betterParams, MARGIN=1, function(x) sqrt(sum((x-candParam)^2)) ) failedT1Rows <- betterLLRows[ distParam<dTest ] # Test 2: small gradient norm and close to another browser() distLL <- abs(as.vector(LL[betterLLRows,s+1] - candLL)) failedT2Rows <- betterLLRows[ gradientNorm[betterLLRows]<gTest & distLL>=llTest ]
If I am understanding this correctly,  for test 2 the gradient norm should be for the focal candidate (gradientNorm[j]), not on the better candidate (graidentNorm[betterLLRows]).

Please let me know if that is a proper assessment, or if I am incorrect. Thank you for your attention and hard work in putting together Apollo.
stephanehess
Site Admin
Posts: 1330
Joined: 24 Apr 2020, 16:29

Re: apollo_searchStart Test2 Conditions?

Post by stephanehess »

Hi

thanks for spotting this. This will be fixed in version 0.3.7

We may make a development version online in the next few days on the apollo website, prior to the CRAN release later this year

Best wishes

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