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.

Parameter does not influence the log-likelihood of your model!

Ask questions about model specifications. Ideally include a mathematical explanation of your proposed model.
kiatkiat94
Posts: 2
Joined: 16 Jul 2025, 15:21

Re: Parameter does not influence the log-likelihood of your model!

Post by kiatkiat94 »

Hi Stephane,

I face the same issue. Installed latest Apollo, tried different starting values, but it doesn't work.

_______________________________________________________________________________________________

# ################################################################# #
#### LOAD LIBRARY AND DEFINE CORE SETTINGS ####
# ################################################################# #

### Install Apollo (if needed)
#install.packages(apollo)

### Clear memory
rm(list = ls())

### Load Apollo library
library(apollo)
library(readxl)
library(readr)
library(rmarkdown)
library(tidyverse)

### Initialise code
apollo_initialise()

### Set core controls
apollo_control = list(
modelName ="NeP_MNL_All",# Make sure to use a new name for every model
indivID ="rid", # Name of column in the database with each individual's ID
modelDescr ="NeP_MNL_All",
nCores = 6 # Number of cores to use in estimation
)

### Load data
database = read_excel("final_analysis.xlsx")

names(database)

# ################################################################# #
#### DEFINE MODEL PARAMETERS ####
# ################################################################# #

### Vector of parameters, including any that are kept fixed in estimation

apollo_beta=c(

treatmenta_asc =0,
treatmentb_asc =0,

beta_cost = 0,

pain_reduc1 = 0,
pain_reduc2 = 0,
pain_reduc3 = 0,
pain_reduc4 = 0,

time_eff1 = 0,
time_eff2 = 0,
time_eff3 = 0,

proven_eff1 = 0,
proven_eff2 = 0,
proven_eff3 = 0,

risk_se1 = 0,
risk_se2 = 0,
risk_se3 = 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(
"treatmentb_asc",
"pain_reduc1",
"time_eff1",
"proven_eff1",
"risk_se1"
)

apollo_inputs = apollo_validateInputs()

# ################################################################# #
#### DEFINE MODEL AND LIKELIHOOD FUNCTION ####
# ################################################################# #

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()

## SP utility function
V = list()

V[['alt1']]= treatmenta_asc + beta_cost * cost1 + pain_reduc1 * (painreduc1==1) + pain_reduc2 * (painreduc1==2) + pain_reduc3 * (painreduc1==3)
+ pain_reduc4 * (painreduc1==4) + time_eff1 * (timeeff1==1) + time_eff2 * (timeeff1==2) + time_eff3 * (timeeff1==3) + proven_eff1 * (proveneff1 ==1)
+ proven_eff2 * (proveneff1 ==2) + proven_eff3 * (proveneff1 ==3) + risk_se1 * (riskse1==1) + risk_se2 * (riskse1==2) +
risk_se3 * (riskse1==3)

V[['alt2']]= treatmentb_asc + beta_cost * cost2 + pain_reduc1 * (painreduc2==1) + pain_reduc2 * (painreduc2==2) + pain_reduc3 * (painreduc2==3)
+ pain_reduc4 * (painreduc2==4) + time_eff1 * (timeeff2==1) + time_eff2 * (timeeff2==2) + time_eff3 * (timeeff2==3) + proven_eff1 * (proveneff2 ==1)
+ proven_eff2 * (proveneff2 ==2) + proven_eff3 * (proveneff2 ==3) + risk_se1 * (riskse2==1) + risk_se2 * (riskse2==2) +
risk_se3 * (riskse2==3)

### Enumerate alternatives and availability, and select choice variable.
mnl_settings1 = list(
alternatives = c(alt1=1, alt2=2),
avail = list(alt1=1, alt2=1),
choiceVar = (chosen_option),
V = V
)

### Compute choice probabilities using MNL model
P[['model']] = apollo_mnl(mnl_settings1, 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)

}

# ################################################################# #
##### ESTIMATE THE MODEL AND GET OUTPUT ####
# ################################################################# #

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

apollo_modelOutput(model)


# ----------------------------------------------------------------- #
#---- FORMATTED OUTPUT (TO FILE, using model name) ----
# ----------------------------------------------------------------- #

#apollo_saveOutput(model)


Many thanks in advance for your kind help.

Best,
Wee
stephanehess
Site Admin
Posts: 1355
Joined: 24 Apr 2020, 16:29

Re: Parameter does not influence the log-likelihood of your model!

Post by stephanehess »

Hi

in your case, it's likely the line breaks. See the point at https://apollochoicemodelling.com/faq.html

Search for Why do I get an error saying that one of my parameters does not influence the likelihood, even though I am using it in a utility function?

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
kiatkiat94
Posts: 2
Joined: 16 Jul 2025, 15:21

Re: Parameter does not influence the log-likelihood of your model!

Post by kiatkiat94 »

Much appreciated, Stephane!
Post Reply