Page 1 of 1

Using Apollo v0.2.0 from a remote desktop

Posted: 29 Oct 2020, 00:22
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 708 times

Re: Using Apollo v0.2.0 from a remote desktop

Posted: 09 Nov 2020, 18:22
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