Page 1 of 2

Log-likelihood calculation fails at values close to the starting values!

Posted: 03 Jul 2023, 18:31
by f_nyanzu
Hi Stephane and David,

I am having a challenging situation for some time now regarding my model and your assistance would be of great help.
I have my model set up to the best of my knowledge and I think everything runs pretty well up to the estimation stage.

That is at the stage where I have to run this code
model=apollo_estimate(apollo_beta,
apollo_fixed,
apollo_probabilities,
apollo_inputs)

Anytime I run the above code, I get the error message:
Error in apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, :
Log-likelihood calculation fails at values close to the starting values!
I have worked around the problem through the helpful resource "http://www.apollochoicemodelling.com/faq.html" and have tried the possible suggested solutions, i.e. "using the apollo_searchStart function", changing the initial value on the log-parameter to -3. and all else zero. I still have the error.

Below are the codes I used.

Thank you for your assistance.
Frederick
********************************************************************************************************************************************************
********************************************************************************************************************************************************
********************************************
###Code I have so far ###
********************************************


rm(list = ls())

### Set Directory ###
setwd("")

### Load Apollo ###
library(tidyverse)
library(magrittr)
library(kableExtra)
library(apollo)


#Start by initializing the code and setting up core controls
##################################################

### Initialize ###
apollo_initialise()

### Set core controls ###
apollo_control= list(
modelName ="MNL_basicmodel_fully_correlated_600",
modelDescr = "Basic MMNL model with fully correlated random coefficient in Preference Space - Max Likelihood 600 MLHS Draws",
indivID = "respondent_id",
outputDirectory = "C:/Users/fnyanzu2/Box/A_ILLINOIS FOLDER/Amy Ando/A_Survey Analysis summer 2022",
mixing = TRUE,
nCores = 6,
panelData = TRUE,
seed = 1995
)


# ##########################################################
### LOAD DATA AND APPLY ANY TRANSFORMATIONS ###
# #########################################################

### Loading data
database = read.csv(".csv", header=TRUE)

### The betta values here uses the last estimate from the apollo_searchStart ###

apollo_beta=c(mu_asc = 0.9440,
sigma_asc = -0.2631,
mu_log_cost = -3.000,
sigma_asc_log_cost = 0.0000,
sigma_log_cost = 0.0000,
mu_nature = 0.0073,
sigma_asc_nature = -0.0082,
sigma_log_cost_nature = 0.0030,
sigma_nature = 0.0075,
mu_farmland = 0.0019,
sigma_asc_farmland = 0.0037,
sigma_log_cost_farmland = -0.0089,
sigma_nature_farmland = 0.0049,
sigma_farmland = -0.0036,
mu_meals_nature = 0.1057,
sigma_asc_meals_nature = -0.0859,
sigma_log_cost_meals_nature = 0.0236,
sigma_nature_meals_nature = 0.0491,
sigma_farmland_meals_nature = 0.0321,
sigma_meals_nature = -0.0160,
mu_meals_farmland = 0.0000,
sigma_asc_meals_farmland = 0.0332,
sigma_log_cost_meals_farmland = 0.1461,
sigma_nature_meals_farmland = -0.1116,
sigma_farmland_meals_farmland = -0.0598,
sigma_meals_nature_meals_farmland = 0.0484,
sigma_meals_farmland = 0.1235,
mu_access_MT = 0.4781,
sigma_asc_access_MT = -0.2186,
sigma_log_cost_access_MT = -0.0342,
sigma_nature_access_MT = -0.1143,
sigma_farmland_access_MT = 0.0120,
sigma_meals_nature_access_MT = -0.0699,
sigma_meals_farmland_access_MT = -0.0196,
sigma_access_MT = 0.0014,
mu_access_PT = -0.0841,
sigma_asc_access_PT = 0.0628,
sigma_log_cost_access_PT = -0.0573,
sigma_nature_access_PT = 0.2299,
sigma_farmland_access_PT = 0.0569,
sigma_meals_nature_access_PT = 0.0672,
sigma_meals_farmland_access_PT = -0.0035,
sigma_access_MT_access_PT = 0.0081,
sigma_access_PT = 0.0030,
mu_access_TT = 0.7235,
sigma_asc_access_TT = 0.0000,
sigma_log_cost_access_TT = 0.0139,
sigma_nature_access_TT = -0.3151,
sigma_farmland_access_TT = 0.0436,
sigma_meals_nature_access_TT = -0.0513,
sigma_meals_farmland_access_TT = -0.0775,
sigma_access_MT_access_TT = 0.0461,
sigma_access_PT_access_TT = 0.0247,
sigma_access_TT = 0.0082,
mu_distance = -0.0403,
sigma_asc_distance = 0.0538,
sigma_log_cost_distance = 0.0020,
sigma_nature_distance = 0.0254,
sigma_farmland_distance = -0.0272,
sigma_meals_nature_distance = 0.0315,
sigma_meals_farmland_distance = -0.0018,
sigma_access_MT_distance = -0.0041,
sigma_access_PT_distance = 0.0192,
sigma_access_TT_distance = -0.0102,
sigma_distance = 0.0005
)

apollo_fixed=c()

apollo_draws=list(
interDrawsType = "halton",
interNDraws = 500,
interNormDraws = c("draws_asc","draws_log_cost","draws_nature",
"draws_farmland","draws_meals_nature","draws_meals_farmland",
"draws_access_MT","draws_access_PT","draws_access_TT",
"draws_distance")
)



apollo_randCoeff=function(apollo_beta,apollo_inputs){
randcoeff=list()
randcoeff[["b_asc"]] = (mu_asc + sigma_asc*draws_asc)
randcoeff[["b_cost"]] = exp(mu_log_cost + sigma_asc_log_cost * draws_asc + sigma_log_cost * draws_log_cost)
randcoeff[["b_nature"]] = (mu_nature + sigma_asc_nature * draws_asc + sigma_log_cost_nature * draws_log_cost + sigma_nature * draws_nature)
randcoeff[["b_farmland"]] = (mu_farmland + sigma_asc_farmland * draws_asc + sigma_log_cost_farmland * draws_log_cost + sigma_nature_farmland * draws_nature + sigma_farmland * draws_farmland)
randcoeff[["b_meals_nature"]] = (mu_meals_nature + sigma_asc_meals_nature * draws_asc + sigma_log_cost_meals_nature * draws_log_cost + sigma_nature_meals_nature * draws_nature + sigma_farmland_meals_nature * draws_farmland + sigma_meals_nature * draws_meals_nature)
randcoeff[["b_meals_farmland"]] = (mu_meals_farmland + sigma_asc_meals_farmland * draws_asc + sigma_log_cost_meals_farmland * draws_log_cost + sigma_nature_meals_farmland * draws_nature + sigma_farmland_meals_farmland * draws_farmland + sigma_meals_nature_meals_farmland * draws_meals_nature + sigma_meals_farmland * draws_meals_farmland)
randcoeff[["b_access_MT"]] = (mu_access_MT + sigma_asc_access_MT * draws_asc + sigma_log_cost_access_MT * draws_log_cost + sigma_nature_access_MT * draws_nature + sigma_farmland_access_MT * draws_farmland + sigma_meals_nature_access_MT * draws_meals_nature + sigma_meals_farmland_access_MT * draws_meals_farmland + sigma_access_MT * draws_access_MT)
randcoeff[["b_access_PT"]] = (mu_access_PT + sigma_asc_access_PT * draws_asc + sigma_log_cost_access_PT * draws_log_cost + sigma_nature_access_PT * draws_nature + sigma_farmland_access_PT * draws_farmland + sigma_meals_nature_access_PT * draws_meals_nature + sigma_meals_farmland_access_PT * draws_meals_farmland + sigma_access_MT_access_PT * draws_access_MT + sigma_access_PT * draws_access_PT)
randcoeff[["b_access_TT"]] = (mu_access_TT + sigma_asc_access_TT * draws_asc + sigma_log_cost_access_TT * draws_log_cost + sigma_nature_access_TT * draws_nature + sigma_farmland_access_TT * draws_farmland + sigma_meals_nature_access_TT * draws_meals_nature + sigma_meals_farmland_access_TT * draws_meals_farmland + sigma_access_MT_access_TT * draws_access_MT + sigma_access_PT_access_TT * draws_access_PT + sigma_access_TT * draws_access_TT)
randcoeff[["b_distance"]] = (mu_distance + sigma_asc_distance * draws_asc + sigma_log_cost_distance * draws_log_cost + sigma_nature_distance * draws_nature + sigma_farmland_distance * draws_farmland + sigma_meals_nature_distance * draws_meals_nature + sigma_meals_farmland_distance * draws_meals_farmland + sigma_access_MT_distance * draws_access_MT + sigma_access_PT_distance * draws_access_PT + sigma_access_TT_distance * draws_access_TT + sigma_distance * draws_distance)

return(randcoeff)
}

apollo_inputs=apollo_validateInputs()

apollo_probabilities=function(apollo_beta, apollo_inputs, functionality="estimate"){


apollo_attach(apollo_beta, apollo_inputs)
on.exit(apollo_detach(apollo_beta, apollo_inputs))
P = list()


## ### Alternative Utilities or list of utilities: these must use the same names as in mnl_settings, order is irrelevant
V = list()
V[["prj"]] = b_asc * asc1 + b_nature * nature1 + b_farmland * farmland1 + b_meals_nature * meals_nature1 + b_meals_farmland * meals_farmland1 + b_access_MT * access_MT1 + b_access_PT * access_PT1 + b_access_TT * access_TT1 + b_distance * distance1 + b_cost + cost1
V[["statusquo"]] = b_asc * asc2 + b_nature * nature2 + b_farmland * farmland2 + b_meals_nature * meals_nature2 + b_meals_farmland * meals_farmland2 + b_access_MT * access_MT2 + b_access_PT * access_PT2 + b_access_TT * access_TT2 + b_distance * distance2 + b_cost + cost2


### Define MNL Settings ###
mnl_settings = list(
alternatives = c(prj=1, statusquo=2),
choiceVar = choice,
utilities = V
)

### Computing probabilities using MNL Model ###
P[["model"]] = apollo_mnl(mnl_settings, functionality)

### Taking product across observation for the same individual ###
P = apollo_panelProd(P, apollo_inputs, functionality)

### Average Across Inter-individual Draws ###
P = apollo_avgInterDraws(P, apollo_inputs, functionality)

### Prepare and Return Outputs of Function ###
P = apollo_prepareProb(P, apollo_inputs, functionality)
return(P)
}


### Search for Starting Values ###
## Stop at 3 iterations ##
#searchStart_settings=list(maxStages = 3,
# nCandidates = 10)


#apollo_beta=apollo_searchStart(apollo_beta,
# apollo_fixed,
# apollo_probabilities,
# apollo_inputs,
# searchStart_settings)



model=apollo_estimate(apollo_beta,
apollo_fixed,
apollo_probabilities,
apollo_inputs)



********************************************
###output results###
*********************************************
Preparing user-defined functions.

Testing likelihood function...
Setting "avail" is missing, so full availability is assumed.

Overview of choices for MNL model component :
prj statusquo
Times available 4344.00 4344.00
Times chosen 2290.00 2054.00
Percentage chosen overall 52.72 47.28
Percentage chosen when available 52.72 47.28

Log-likelihood calculation fails at starting values!
Affected individuals:
ID LL
4 -Inf
13 -Inf
14 -Inf
...
...
...
830 -Inf
832 -Inf
834 -Inf
837 -Inf
Error in apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, :
Log-likelihood calculation fails at values close to the starting values!

Re: Log-likelihood calculation fails at values close to the starting values!

Posted: 05 Jul 2023, 14:07
by stephanehess
Hi

did you start off with a simple MNL model first? And when moving to the mixed model, did you look first at univariate distributions? What you have below is a very complex specification, and there are many reasons why it could go wrong and we need to try to isolate the issue

Stephane

Re: Log-likelihood calculation fails at values close to the starting values!

Posted: 06 Jul 2023, 00:56
by f_nyanzu
Hi Stephane,

Thank you for your response.
I tried the simple MNL model first but with different data (I use the apollo_swissRouteChoiceData example provided). And all was ok. When I started off with this data, I get stuck with the error even with the simple model.
I think maybe I might be doing something wrong that I am not able to figure out.

Thank you.

Best,
Frederick

Re: Log-likelihood calculation fails at values close to the starting values!

Posted: 06 Jul 2023, 09:02
by stephanehess
Hi

if it fails with a simple model, then that needs fixing first. Can you show us the code and output for that one

Thanks

Stephane

Re: Log-likelihood calculation fails at values close to the starting values!

Posted: 07 Jul 2023, 18:18
by f_nyanzu
Hi Stephane,

Below is the output for the simple preference space model:

Thank you.
************************************************


>
> ## Clear memory
> rm(list = ls())
>
> ### Set Directory ###
>
> ### Load Apollo ###
> library(tidyverse)
> library(magrittr)
> library(kableExtra)
> library(apollo)
>
>
> #Start by initializing the code and setting up core controls
> ############################################################
>
> ### Initialize ###
> apollo_initialise()
Apollo ignition sequence completed
>
> ### Set core controls ###
> apollo_control= list(
+ modelName ="MNL_basicmodel_fully_correlated_600",
+ modelDescr = "Basic MMNL model in Preference Space - Max Likelihood 600 MLHS Draws",
+ indivID = "respondent_id",
+ outputDirectory = "",
+ mixing = TRUE,
+ nCores = 6,
+ panelData = TRUE,
+ seed = 1995
+ )
>
>
> # ##########################################################
> ### LOAD DATA AND APPLY ANY TRANSFORMATIONS ###
> # #########################################################
>
> ### Loading data
> database = read.csv("C:/Users/fnyanzu2/Box/A_ILLINOIS FOLDER/Amy Ando/A_Survey Analysis summer 2022/data_apollo1.csv", header=TRUE)
>
>
> #Determine the attributes of the model and define the priors on the model parameters.

> apollo_beta=c(mu_asc = 0.00,
+ sigma_asc = 0.000,
+ mu_log_cost = -3.00,
+ sigma_log_cost = -0.01,
+ mu_nature = 0.000,
+ sigma_nature = 0.000,
+ mu_farmland = 0.000,
+ sigma_farmland = 0.000,
+ mu_meals_nature = 0.000,
+ sigma_meals_nature = 0.000,
+ mu_meals_farmland = 0.000,
+ sigma_meals_farmland = 0.000,
+ mu_access_MT = 0.000,
+ sigma_access_MT = 0.000,
+ mu_access_PT = 0.000,
+ sigma_access_PT = 0.000,
+ mu_access_TT = 0.000,
+ sigma_access_TT = 0.000,
+ mu_distance = 0.000,
+ sigma_distance = 0.000
+ )
>
> apollo_fixed = c()
>
>
> ###########################################################
> # Setting parameters to define draws & Random parameters
> ##########################################################
>
> ### Draws
> apollo_draws=list(
+ interDrawsType = "mlhs",
+ interNDraws = 600,
+ interNormDraws = c("draws_asc","draws_log_cost","draws_nature",
+ "draws_farmland","draws_meals_nature","draws_meals_farmland",
+ "draws_access_MT","draws_access_PT","draws_access_TT",
+ "draws_distance")
+ )
>
>
> ### Random parameters
>
> apollo_randCoeff=function(apollo_beta,apollo_inputs){
+ randcoeff=list()
+ randcoeff[["b_asc"]] = (mu_asc + sigma_asc*draws_asc)
+ randcoeff[["b_cost"]] = -exp(mu_log_cost + sigma_log_cost * draws_log_cost)
+ randcoeff[["b_nature"]] = (mu_nature + sigma_nature * draws_nature)
+ randcoeff[["b_farmland"]] = (mu_farmland + sigma_farmland * draws_farmland)
+ randcoeff[["b_meals_nature"]] = (mu_meals_nature + sigma_meals_nature * draws_meals_nature)
+ randcoeff[["b_meals_farmland"]] = (mu_meals_farmland + sigma_meals_farmland * draws_meals_farmland)
+ randcoeff[["b_access_MT"]] = (mu_access_MT + sigma_access_MT * draws_access_MT)
+ randcoeff[["b_access_PT"]] = (mu_access_PT + sigma_access_PT * draws_access_PT)
+ randcoeff[["b_access_TT"]] = (mu_access_TT + sigma_access_TT * draws_access_TT)
+ randcoeff[["b_distance"]] = (mu_distance + sigma_distance * draws_distance)
+
+ return(randcoeff)
+ }
>
>
>
> ### Validating inputs
> apollo_inputs=apollo_validateInputs()
apollo_draws and apollo_randCoeff were found, so apollo_control$mixing was set to TRUE
All checks on apollo_control completed.
All checks on database completed.
Generating inter-individual draws .......... Done
>
>
> ### Likelihood function and model defining
> apollo_probabilities=function(apollo_beta, apollo_inputs, functionality="estimate"){
+
+ ### Function initialisation: do not change the following three commands ###
+ ### 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()
+
+
+ ## ### Alternative Utilities or list of utilities: these must use the same names as in mnl_settings, order is irrelevant
+ V = list()
+ V[["prj"]] = b_asc * asc1 + b_nature * nature1 + b_farmland * farmland1 + b_meals_nature * meals_nature1 + b_meals_farmland * meals_farmland1 + b_access_MT * access_MT1 + b_access_PT * access_PT1 + b_access_TT * access_TT1 + b_distance * distance1 + b_cost + cost1
+ V[["statusquo"]] = b_asc * asc2 + b_nature * nature2 + b_farmland * farmland2 + b_meals_nature * meals_nature2 + b_meals_farmland * meals_farmland2 + b_access_MT * access_MT2 + b_access_PT * access_PT2 + b_access_TT * access_TT2 + b_distance * distance2 + b_cost + cost2
+
+
+ ### Define MNL Settings ###
+ mnl_settings = list(
+ alternatives = c(prj=1, statusquo=2),
+ choiceVar = choice,
+ utilities = V
+ )
+
+ ### Compute Probabilities using MNL Model ###
+ P[["model"]] = apollo_mnl(mnl_settings, functionality)
+
+ ### Take Product Across Observation for Same Individual ###
+ P = apollo_panelProd(P, apollo_inputs, functionality)
+
+ ### Average Across Inter-individual Draws ###
+ P = apollo_avgInterDraws(P, apollo_inputs, functionality)
+
+ ### Prepare and Return Outputs of Function ###
+ P = apollo_prepareProb(P, apollo_inputs, functionality)
+ return(P)
+ }
> model = apollo_estimate(apollo_beta, apollo_fixed,apollo_probabilities, apollo_inputs)
Preparing user-defined functions.

Testing likelihood function...
Setting "avail" is missing, so full availability is assumed.

Overview of choices for MNL model component :
prj statusquo
Times available 4344.00 4344.00
Times chosen 2290.00 2054.00
Percentage chosen overall 52.72 47.28
Percentage chosen when available 52.72 47.28

Log-likelihood calculation fails at starting values!
Affected individuals:
ID LL
4 -Inf
13 -Inf
...
...
...
832 -Inf
834 -Inf
837 -Inf
Error in apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, :
Log-likelihood calculation fails at values close to the starting values!
>

Re: Log-likelihood calculation fails at values close to the starting values!

Posted: 07 Jul 2023, 18:40
by stephanehess
Hi

This is still mixed logit. Did the MNL work? Can you show us that?

Stephane

Re: Log-likelihood calculation fails at values close to the starting values!

Posted: 07 Jul 2023, 22:15
by f_nyanzu
Dear Stephane,

No, the MNL as mentioned earlier, had similar error.
Please see below, the codes I used and the output as well.

Thank you.

*******************************************************************************************


## Clear memory
> rm(list = ls())
> #gc()
>
> ### Set Directory ###
> setwd("")
>
> ### Load Apollo ###
> library(tidyverse)
> library(magrittr)
> library(kableExtra)
> library(apollo)
>
>
> #Start by initializing the code and setting up core controls
> ############################################################
>
> ### Initialise code
> apollo_initialise()
Apollo ignition sequence completed
>
> ### Set core controls
> apollo_control = list(
+ modelName = "MNL_Farm_Nature",
+ modelDescr = "Simple MNL model on mode farmland value",
+ indivID = "respondent_id",
+ outputDirectory = "output"
+ )
>
>
> # ##########################################################
> ### LOAD DATA AND APPLY ANY TRANSFORMATIONS ###
> # #########################################################
>
> ### Loading data
> database = read.csv(" ## Clear memory
> rm(list = ls())
> #gc()
>
> ### Set Directory ###
> setwd("C:/Users/fnyanzu2/Box/A_ILLINOIS FOLDER/Amy Ando/A_Survey Analysis summer 2022")
>
> ### Load Apollo ###
> library(tidyverse)
> library(magrittr)
> library(kableExtra)
> library(apollo)
>
>
> #Start by initializing the code and setting up core controls
> ############################################################
>
> ### Initialise code
> apollo_initialise()
Apollo ignition sequence completed
>
> ### Set core controls
> apollo_control = list(
+ modelName = "MNL_Farm_Nature",
+ modelDescr = "Simple MNL model on mode farmland value",
+ indivID = "respondent_id",
+ outputDirectory = "output"
+ )
>
>
> # ##########################################################
> ### LOAD DATA AND APPLY ANY TRANSFORMATIONS ###
> # #########################################################
>
> ### Loading data
> database = read.csv("C:/Users/fnyanzu2/Box/A_ILLINOIS FOLDER/Amy Ando/A_Survey Analysis summer 2022/data_apollo1.csv", header=TRUE)
>
>
> # ################################################################# #
> #### DEFINE MODEL PARAMETERS ####
> # ################################################################# #
>
> ### Vector of parameters, including any that are kept fixed in estimation
> apollo_beta=c(b_asc = 0,
+ b_nature = 0,
+ b_farmland = 0,
+ b_meals_nature = 0,
+ b_meals_farmland = 0,
+ b_access_MT = 0,
+ b_access_PT = 0,
+ b_access_TT = 0,
+ b_distance = 0,
+ b_cost = 0)
>
> ### Vector with names (in quotes) of parameters to be kept fixed at their starting value in apollo_beta, use apollo_beta_fixed = c() if none
> apollo_fixed = c("b_cost")
> apollo_inputs = apollo_validateInputs()
Several observations per individual detected based on the value of respondent_id. Setting panelData in apollo_control set to TRUE.
All checks on apollo_control completed.
All checks on database completed.
> apollo_probabilities=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()
+
+
+
+
+ ## ### Alternative Utilities or list of utilities: these must use the same names as in mnl_settings, order is irrelevant
+ V = list()
+ V[["prj"]] = b_asc * asc1 + b_nature * nature1 + b_farmland * farmland1 + b_meals_nature * meals_nature1 + b_meals_farmland * meals_farmland1 + b_access_MT * access_MT1 + b_access_PT * access_PT1 + b_access_TT * access_TT1 + b_distance * distance1 + b_cost + cost1
+ V[["statusquo"]] = b_asc * asc2 + b_nature * nature2 + b_farmland * farmland2 + b_meals_nature * meals_nature2 + b_meals_farmland * meals_farmland2 + b_access_MT * access_MT2 + b_access_PT * access_PT2 + b_access_TT * access_TT2 + b_distance * distance2 + b_cost + cost2
+
+
+ ### Define MNL Settings ###
+ mnl_settings = list(
+ alternatives = c(prj=1, statusquo=2),
+ choiceVar = choice,
+ utilities = V
+ )
+
+
+
+ ### Compute probabilities using MNL model
+ P[["model"]] = apollo_mnl(mnl_settings, functionality)
+
+ ### Take product across observation for same individual
+ P = apollo_panelProd(P, apollo_inputs, functionality)
+
+ ### Prepare and return outputs of function
+ P = apollo_prepareProb(P, apollo_inputs, functionality)
+ return(P)
+ }
> model = apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs)
Preparing user-defined functions.

Testing likelihood function...
Setting "avail" is missing, so full availability is assumed.

Overview of choices for MNL model component :
prj statusquo
Times available 4344.00 4344.00
Times chosen 2290.00 2054.00
Percentage chosen overall 52.72 47.28
Percentage chosen when available 52.72 47.28

Log-likelihood calculation fails at starting values!
Affected individuals:
ID LL
4 -Inf
13 -Inf
14 -Inf
41 -Inf
...
...
...
828 -Inf
830 -Inf
832 -Inf
834 -Inf
837 -Inf

Error in apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, :
Log-likelihood calculation fails at values close to the starting values!
>

Re: Log-likelihood calculation fails at values close to the starting values!

Posted: 14 Jul 2023, 12:44
by stephanehess
I can look into this for you if you are able to share the code and data with me outside the forum

Re: Log-likelihood calculation fails at values close to the starting values!

Posted: 18 Jul 2023, 16:03
by stephanehess
Hi

easy fix

You have

Code: Select all

+ b_cost + cost1
intead of

Code: Select all

+ b_cost * cost1
Same for the second alternative. Your uitlities then exploded for large values for cost

And why do you keep b_cost fixed?

Stephane

Re: Log-likelihood calculation fails at values close to the starting values!

Posted: 18 Jul 2023, 17:25
by f_nyanzu
Oh! Thank you for that catch.
The cost was fixed for the mixlogit model. I should have deleted that.
Thank you!!!