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.
Dian3426
Posts: 1
Joined: 05 Jul 2023, 04:34

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

Post by Dian3426 »

Hi Stephane and David,

Hope you are doing great!

I am trying to use the Apollo package (0.2.9) to run the MNL_RP model.

Here is the error message I got from R (version 4.2.0; RStudio2022.02.1):
"Error in apollo_estimateHB(apollo_beta, apollo_fixed, apollo_probabilities, :
SPECIFICATION ISSUE - Parameter b_disc.d2 does not influence the log-likelihood of your model!"


Below is the code I used to run the analysis.

# Import

dce = read.csv(file=paste0(PATHDAT,'dce_wide.csv'), header = T, stringsAsFactors = F)

load(paste0(PATHOBJ,'List of model specifications.RData')) # l.spe
load(paste0(PATHOBJ,'List of attributes.RData')) # l.att


# Manage --------------------------------------------------

###
MODL = 'RPL_effect'
OBJT = 'RPL_effect - Model estimates_child'
SAMP = 'Overall'

### META Variables
N = 'record'
Ta = 'SP_task'
Y = "choice"
nJ = 2

###
nfac = 1000
nBURN = 300*nfac
nCONV = 30*nfac
nSKIP = 10
SEED = 12345


# Specification -----------------------------------------------------------

lD = as.list(NULL)
for (i in 1) {
###
D = dce

###
lA = l.att
S0 = l.spe[['eff0']]
S1 = l.spe[['eff1']]

### Model specification
lX = paste0("b_",S1)
lparam = rep(0,length(lX))
names(lparam) = lX

###
hbd = NULL
hbd = rep('N',length(lX))
names(hbd) = lX

###
l.uti = as.list(NULL)
l.uti = lapply(1:nJ, function(x){
a = paste0(lX,"*alt",x,'_',sub('b\\_','',lX),collapse=" +")
return(a)})

###
nN = length(unique(D[,N]))
nY = nrow(D)
nP = 2*length(hbd)
LL0 = nY*log(1/nJ)
nD = nrow(D)

###
mID = D[!duplicated(D[,'ID']),c('ID',N)]

###
lk = as.list(NULL)
lk[['lA']] = lA
lk[['S0']] = S0
lk[['S1']] = S1
lk[['D']] = D
lk[['nN']] = nN
lk[['nY']] = nY
lk[['nP']] = nP
lk[['LL0']] = LL0
lk[['hbd']] = hbd
lk[['lparam']] = lparam
lk[['l.uti']] = l.uti
lk[['mID']] = mID
lk[['nD']] = nD

lD[] = lk}

# Estimation ------------------------------------------------------------------------

###
l.res = as.list(NULL)

IDXTOT = length(lD)

for (i in IDXTOT){
###
lparam = lD[][['lparam']]
l.uti = lD[][['l.uti']]
hbd = lD[][['hbd']]
database = lD[][['D']]
nD = lD[][['nD']]
nY = lD[][['nY']]
nN = lD[][['nN']]
nP = lD[][['nP']]
LL0 = lD[][['LL0']]
mID = lD[[i]][['mID']]
S0 = lD[[i]][['S0']]
S1 = lD[[i]][['S1']]
lA = lD[[i]][['lA']]

### Initialise code
apollo_initialise()

### Set core controls
apollo_control = list(
modelName =MODL,
modelDescr =MODL,
indivID ='ID',
HB =T)

### Declare parameters
apollo_beta = lparam
apollo_fixed = c()

###
apollo_HB = list(
hbDist =hbd,
gINFOSKIP =nSKIP,
gNCREP =nBURN,
gNEREP =nCONV,
gSeed =SEED,
verbose =F,
nodiagnostics=T,
gFULLCV =F)

### VALIDATE INPUTS
apollo_inputs = apollo_validateInputs()

### DEFINE MODEL
apollo_probabilities = function(apollo_beta, apollo_inputs, functionality="estimate"){
###
apollo_attach(apollo_beta, apollo_inputs)
on.exit(apollo_detach(apollo_beta, apollo_inputs))

### Create list of probabilities P
P = list()

### Likelihood of choices
V = list()
V[['alt1']] = (b_adpro.d2 * alt1_adpro.d2 +
b_inj.d2 * alt1_inj.d2 + b_inj.d3 * alt1_inj.d3 +
b_disc.d2 * alt1_disc.d2 + b_disc.d3 * alt1_disc.d3 +
b_dos.d2 * alt1_dos.d2 + b_dos.d3 * alt1_dos.d3 +
b_visits.d2 * alt1_visits.d2 + b_visits.d3 * alt1_visits.d3)
V[['alt2']] = (b_adpro.d2 * alt2_adpro.d2 +
b_inj.d2 * alt2_inj.d2 + b_inj.d3 * alt2_inj.d3 +
b_disc.d2 * alt2_disc.d2 + b_disc.d3 * alt2_disc.d3 +
b_dos.d2 * alt2_dos.d2 + b_dos.d3 * alt2_dos.d3 +
b_visits.d2 * alt2_visits.d2 + b_visits.d3 * alt2_visits.d3)

### Define MNL settings
mnl_settings = list(
alternatives=c(alt1=1, alt2=2),
avail = list(alt1=1, alt2=1),
choiceVar = choice,
V = V)

### Compute probabilities using MNL model
P[['model']] = apollo_mnl(mnl_settings, functionality)

### Prepare and return outputs of function
P = apollo_prepareProb(P, apollo_inputs, functionality)
return(P)}

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

.......



Do you have any suggestions to solve this error? Thank you very much in advance for your help

Best regards,
Dian
stephanehess
Site Admin
Posts: 1350
Joined: 24 Apr 2020, 16:29

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

Post by stephanehess »

Hi

this would happen if there are no differences between the alternatives in the associated attribute, i.e. alt1_disc.d2 and alt2_disc.d2

Can you confirm that in your data, these do differ?

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
gabystephanie
Posts: 3
Joined: 10 Mar 2025, 01:09

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

Post by gabystephanie »

Hi Stephane and David,

Hope you are doing great!
I have been struggling with this issue for a while, and your help would be greatly appreciated.
I am trying to use the Apollo package to estimate the prior from my pilot test, but I keep getting this error message "Parameter does not influence the log-likelihood of your model!".

Below is the code I used to run the analysis.

apollo_initialise()
database<-data_long1
apollo_control=list(modelName = "dce pilot", modelDescr = "MNL model", indivID = "ID")
str(database)

apollo_beta<-c(asc_app1 = 0, asc_app2 = 0, b_ht_bud = 0, b_ht_stan = 0, b_ht_lux = 0, b_tc_low = 0, b_tc_med = 0, b_tc_high = 0, b_ev_low = 0, b_ev_med = 0, b_ev_high = 0)
apollo_fixed<-c("asc_app2", "b_ht_bud", "b_tc_low", "b_ev_low")
apollo_control
apollo_readBeta
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()
V<-list()
V[['alt1']]=(asc_app1+b_ht_bud*(ht_bud==1)+b_ht_stan*(ht_stan==2)+b_ht_lux*(ht_lux==3)+b_tc_low*(tc_low==1)+b_tc_med*(tc_med==2)+b_tc_high*(tc_high==3)+b_ev_low*(ev_low==1)+b_ev_med*(ev_med==2)+b_ev_high*(ev_high==3))
V[['alt2']]=(asc_app2+b_ht_bud*(ht_bud==1)+b_ht_stan*(ht_stan==2)+b_ht_lux*(ht_lux==3)+b_tc_low*(tc_low==1)+b_tc_med*(tc_med==2)+b_tc_high*(tc_high==3)+b_ev_low*(ev_low==1)+b_ev_med*(ev_med==2)+b_ev_high*(ev_high==3))
mnl_settings<-list(alternatives=c(alt1=1,alt2=2), avail=list(alt1=1,alt2=1), choiceVar=choice, V=V)
P[['model']] <- apollo_mnl(mnl_settings, functionality)
P<- apollo_panelProd(P, apollo_inputs, functionality)
P<- apollo_prepareProb(P, apollo_inputs, functionality)
return(P)
}

model<-apollo_estimate(apollo_beta,apollo_fixed,apollo_probabilities,apollo_inputs)
apollo_modelOutput(model)

Preparing user-defined functions.

Testing likelihood function...

Overview of choices for MNL model component :
alt1 alt2
Times available 456 456
Times chosen 228 228
Percentage chosen overall 50 50
Percentage chosen when available 50 50


Pre-processing likelihood function...

Testing influence of parametersError in apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, :
SPECIFICATION ISSUE - Parameters b_ht_stan, b_ht_lux, b_tc_med, b_tc_high, b_ev_med, b_ev_high do not influence the log-likelihood of your model!
------------------------------------------------------------------------------------------------------------------------
Do you have any suggestions to solve this error? Thank you very much in advance for your help!

Best regards,
Gaby
stephanehess
Site Admin
Posts: 1350
Joined: 24 Apr 2020, 16:29

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

Post by stephanehess »

Hi Gaby

only differences in utility matter. If you include e.g.

Code: Select all

b_ht_stan*(ht_stan==2)
in both utilities, then it will simply drop out

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
mboer
Posts: 3
Joined: 19 May 2025, 13:47

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

Post by mboer »

Dear dr. Hess,

I'm struggling with fitting a latent class MNL model. Please find my code below.

I keep getting the following error message: Error in apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, :
SPECIFICATION ISSUE - Parameters b_reistijd_1_a, b_reistijd_2_a, b_frequentie_2_a, b_frequentie_3_a, b_frequentie_4_a, b_frequentie_5_a, b_reistijd_1_b, b_reistijd_2_b, b_frequentie_2_b, b_frequentie_3_b, b_frequentie_4_b, b_frequentie_5_b do not influence the log-likelihood of your model!

I have read your reply in this post and checked whether 'frequentie' differs across choice option 1 and 2, and it does, so I don't think that is the issue. For some reason, when I remove the +-sign in the equation for 'alt2' before defining the frequentie-dummy variables (see comment after @@), the model runs, but then I am afraid that it does not use all data for 'alt2'. Could you perhaps see what goes wrong? Any help is much appreciated.

Best,

M.

apollo_initialise()
apollo_control <- list(
modelName = "LCA_pilot_2classes",
modelDescr = "Latent class analysis pilot study",
indivID = "id",
outputDirectory = "Results/Pilot/LCA"
)

database <- readRDS("Data/Pilot/database_pilot.rds")

# Initialize betas
apollo_beta <- c(
b_reistijd_1_a = 0,
b_reistijd_2_a = 0,
b_reistijd_3_a = 0,
b_frequentie_1_a = 0,
b_frequentie_2_a = 0,
b_frequentie_3_a = 0,
b_frequentie_4_a = 0,
b_frequentie_5_a = 0,
b_reistijd_1_b = 0,
b_reistijd_2_b = 0,
b_reistijd_3_b = 0,
b_frequentie_1_b = 0,
b_frequentie_2_b = 0,
b_frequentie_3_b = 0,
b_frequentie_4_b = 0,
b_frequentie_5_b = 0,
delta_a = 0,
delta_b = 0,
b_asc_1 = 0,
b_asc_2 = 0,
b_out = 0
)

# Refcat
apollo_fixed <- c(
"b_reistijd_3_a", "b_frequentie_1_a",
"b_reistijd_3_b", "b_frequentie_1_b", "delta_a", "b_asc_1")

apollo_lcPars = function(apollo_beta, apollo_inputs) {
lcpars = list()
lcpars[["b_reistijd_1"]] = list(b_reistijd_1_a, b_reistijd_1_b)
lcpars[["b_reistijd_2"]] = list(b_reistijd_2_a, b_reistijd_2_b)
lcpars[["b_reistijd_3"]] = list(b_reistijd_3_a, b_reistijd_3_b)
lcpars[["b_frequentie_1"]] = list(b_frequentie_1_a, b_frequentie_1_b)
lcpars[["b_frequentie_2"]] = list(b_frequentie_2_a, b_frequentie_2_b)
lcpars[["b_frequentie_3"]] = list(b_frequentie_3_a, b_frequentie_3_b)
lcpars[["b_frequentie_4"]] = list(b_frequentie_4_a, b_frequentie_4_b)
lcpars[["b_frequentie_5"]] = list(b_frequentie_5_a, b_frequentie_5_b)

#Utilities of class allocation model
V = list()
V[["class_a"]] = delta_a
V[["class_b"]] = delta_b

#Settings for class allocation models
classAlloc_settings = list(
classes = c(class_a = 1, class_b = 2),
utilities = V
)
lcpars[["pi_values"]] = apollo_classAlloc(classAlloc_settings)
return(lcpars)

}

# Check inputs
apollo_inputs <- apollo_validateInputs()

# Define model
apollo_probabilities <- function(apollo_beta, apollo_inputs, functionality = "estimate"){
apollo_attach(apollo_beta, apollo_inputs)
on.exit(apollo_detach(apollo_beta, apollo_inputs))

# List for probabilities
P <- list()

# MNL settings
mnl_settings <- list(
alternatives = c(alt1 = 1, alt2 = 2, alt3 = 3),
avail = list(alt1 = 1, alt2 = 1, alt3 = 1),
choiceVar = keuze
)

for(s in 1:length(pi_values)){
# List for utilities
V <- list()
# Define formulas
V[['alt1']] = b_asc_1 +
b_reistijd_1[[s]]*(reistijd_1 == 1) +
b_reistijd_2[[s]]*(reistijd_1 == 2) +
b_reistijd_3[[s]]*(reistijd_1 == 3) +
b_frequentie_1[[s]]*(frequentie_1 == 1) +
b_frequentie_2[[s]]*(frequentie_1 == 2) +
b_frequentie_3[[s]]*(frequentie_1 == 3) +
b_frequentie_4[[s]]*(frequentie_1 == 4) +
b_frequentie_5[[s]]*(frequentie_1 == 5)
V[['alt2']] = b_asc_2 +
b_reistijd_1[[s]]*(reistijd_2 == 1) +
b_reistijd_2[[s]]*(reistijd_2 == 2) +
b_reistijd_3[[s]]*(reistijd_2 == 3) + # @@If I remove the + here, then it runs
b_frequentie_1[[s]]*(frequentie_2 == 1) +
b_frequentie_2[[s]]*(frequentie_2 == 2) +
b_frequentie_3[[s]]*(frequentie_2 == 3) +
b_frequentie_4[[s]]*(frequentie_2 == 4) +
b_frequentie_5[[s]]*(frequentie_2 == 5)
V[['alt3']] = b_out

mnl_settings$utilities = V

### Compute within-class choice probabilities using MNL model
P[[paste0("Class_",s)]] = apollo_mnl(mnl_settings, functionality)

### Take product across observation for same individual
P[[paste0("Class_",s)]] = apollo_panelProd(P[[paste0("Class_",s)]], apollo_inputs ,functionality)
}

### Compute latent class model probabilities
lc_settings = list(inClassProb = P, classProb=pi_values)
P[["model"]] = apollo_lc(lc_settings, apollo_inputs, functionality)

### Prepare and return outputs of function
P = apollo_prepareProb(P, apollo_inputs, functionality)
return(P)

}


### model estimation
model = apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs)
stephanehess
Site Admin
Posts: 1350
Joined: 24 Apr 2020, 16:29

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

Post by stephanehess »

Hi

well, it seems like most of your parameters are not having an effect.

First, did you estimate an MNL model and can you confirm that that worked fine?
Second, what version of Apollo are you using?

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
mboer
Posts: 3
Joined: 19 May 2025, 13:47

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

Post by mboer »

Dear Stephane,

Thanks for your fast reply.

Yes, I first fitted an MNL model, which worked just fine, although in the ('1-class') MNL the parameters for 'frequentie' were either not in the expected direction or not significant.

Regarding your second question: I'm using Apollo version 0.3.4.

M.
stephanehess
Site Admin
Posts: 1350
Joined: 24 Apr 2020, 16:29

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

Post by stephanehess »

Hi

try to update to the newest version of Apollo and also use different starting values in the two classes. If that does not help, then please let me know

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
mboer
Posts: 3
Joined: 19 May 2025, 13:47

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

Post by mboer »

Dear Stephane,

I have updated Apollo to version 0.3.5 now. When I run the model with the script as specified as earlier, I get this message:

Error in apollo_lc(c(lc_settings, componentName2 = "model"), apollo_inputs, :
INPUT ISSUE - At your starting values, the probabilities are the same across some of the classes.Please use different starting values across classes. If you still wish to run your model in the current form, please set noValidation=TRUE in apollo_control.

I have tried to search for starting values using
apollo_beta=apollo_searchStart(apollo_beta, apollo_fixed,apollo_probabilities, apollo_inputs)

but then I get the following message:
Testing probability function (apollo_probabilities)
Apollo found a model component of type classAlloc without a componentName. The name was set to "classAlloc" by default.
INFORMATION: Setting "avail" is missing, so full availability is assumed.
Apollo found a model component of type MNL without a componentName. The name was set to "Class_1" by default.
Apollo found a model component of type MNL without a componentName. The name was set to "Class_2" by default.
Error in apollo_lc(c(lc_settings, componentName2 = "model"), apollo_inputs, :
INPUT ISSUE - At your starting values, the probabilities are the same across some of the classes.Please use different starting values across classes. If you still wish to run your model in the current form, please set noValidation=TRUE in apollo_control.

Can you see what is going wrong? Perhaps I made a coding error?
stephanehess
Site Admin
Posts: 1350
Joined: 24 Apr 2020, 16:29

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

Post by stephanehess »

Hi

just change the starting values in apollo_beta so they are not exactly the same for the different classes

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
Post Reply