Page 1 of 1
Weight check inside apollo_makeLogLike
Posted: 28 Nov 2020, 00:29
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!
Re: Weight check inside apollo_makeLogLike
Posted: 28 Nov 2020, 13:37
by stephanehess
Tomas
which version of Apollo are you using?
Stephane
Re: Weight check inside apollo_makeLogLike
Posted: 28 Nov 2020, 17:26
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
Re: Weight check inside apollo_makeLogLike
Posted: 28 Nov 2020, 19:33
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
Re: Weight check inside apollo_makeLogLike
Posted: 28 Nov 2020, 20:37
by tomas.rossetti
Excellent, I'll take a look as soon as they're uploaded.
Thank you Stephane
Re: Weight check inside apollo_makeLogLike
Posted: 09 Mar 2021, 14:10
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
Re: Weight check inside apollo_makeLogLike
Posted: 16 Mar 2021, 10:28
by stephanehess
Oops, sorry, the files have been updated now