Re: Parameter does not influence the log-likelihood of your model!
Posted: 10 Nov 2025, 09:56
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
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