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.

Using Apollo v0.2.0 from a remote desktop

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
Rafael
Posts: 1
Joined: 29 Oct 2020, 00:02

Using Apollo v0.2.0 from a remote desktop

Post by Rafael »

Hi everybody,

I'm trying to estimate a exploded logit model using a hybrid choice model. The model is running in Apollo v0.2.0 (released just few days ago) from a remote server with R v4.0.2.

All inputs were validated:
All checks on apollo_control completed.
All checks on database completed.
Generating inter-individual draws ... Done
Inter-person draws are being used without a panel structure.

But i'm having troubles testing likelihood function and the model output can't be estimated by caused this error:

"Testing likelihood functionError in checkForRemoteErrors(lapply(cl, recvResult)) : 4 nodes produced errors; first error: non-numeric argument to binary operator".

By the other hand, when i run the same model from the laptop using an older Apollo version this error doesn't occur and the model can be estimated, but it takes so much time.

Regards,

Rafael
EL_TransportPolicies_HybridChoiceModel.rar
Model and database
(23.35 KiB) Downloaded 572 times
dpalma
Posts: 190
Joined: 24 Apr 2020, 17:54

Re: Using Apollo v0.2.0 from a remote desktop

Post by dpalma »

Hi Rafael,

You found a bug in apollo. Version 0.2.0 and 0.2.1 cannot handle latent variables defined recursively, i.e. one latent variable cannot depend on the value of another.

There are two ways around this:

First option is to not use analytic gradients. This will allow your model to run, but much slower than it could. You do this by setting analyticGrad=FALSE inse apollo_control:

Code: Select all

apollo_control = list(
  modelName  = "EL_TransportPolicies_HybridChoiceModel",
  modelDescr = "Exploded logit model on transport policies choice data using hybrid choice model",
  indivID    = "ID",
  mixing     = TRUE,
  nCores     = 4,
  analyticGrad=FALSE
)
The second option is to replace the call to randcoeff[["protec"]] by its definition. It is not ideal, but it should let you use analytic gradients during estimation, and so it should be a faster than the previous alternative. This would look like the following.

Code: Select all

apollo_randCoeff=function(apollo_beta, apollo_inputs){
  randcoeff = list()
  
  randcoeff[["protec"]] = zeta_edad_protec*(Edad) + zeta_femenino_protec*(Femenino==1) + eta1
  randcoeff[["procar"]] = zeta_NVehiculosBC_procar*(NVehiculosBC==1) + zeta_edad_procar*(Edad) + zeta_NEstudiosAlto_procar*(NivelEstudiosAlto==1) + zeta_protec_procar*(zeta_edad_protec*(Edad) + zeta_femenino_protec*(Femenino==1) + eta1) + eta2
  randcoeff[["desamb"]] = zeta_NVehiculosBC_desamb*(NVehiculosBC==1) + eta3
  
  return(randcoeff)
}
Do not use both options at the same time!

Cheers
David
Post Reply