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. This may take a day or two at busy times. There is no need to submit the post multiple times.

Error: the variable does not influence the log-likelihood of your model

Ask questions about errors you encouunter. Please make sure to include full details about your model specifications, and ideally your model file.
Post Reply
oleggurshev
Posts: 1
Joined: 15 May 2021, 12:33

Error: the variable does not influence the log-likelihood of your model

Post by oleggurshev »

Hello professor,

We have been using your package in our classes (University of Warsaw) for micromodelling. We were modelling society choice (1 - society1, 2-society2, 3- opt-out of the survey). I have run into an issue where the function would not recognize any of my variables inside a utility (Error in apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, : Parameter asc_opt1 does not influence the log-likelihood of your model!).

I am including both data and my code.

### Load data
setwd("")
database <- read_xlsx('Data_relative.xlsx')

database <- transmute(database, #modify this if want logs / not logs
ID = ID,
income1 = log(income1),
income2 = log(income2),
choice = choice,
choice1 = choice1,
choice2 = choice2,
choice3 = choice3,
centile1 = log(centile1),
centile2 = log(centile2),
trend1 = trend1,
trend2 = trend2
)

database <- as.data.frame(database) #apollo does not work with tibbles

### Initialize code
apollo_initialise()

### Set core controls
apollo_control = list(
modelName ="Society_base",
modelDescr ="Simple MNL model on society choice data",
indivID ="ID"
)

# ################################################################# #
#### ANALYSIS OF CHOICES ####
# ################################################################# #
database$low_income1=database$income1<quantile(database$income1,0.25)
database$low_income2=database$income2<quantile(database$income2,0.25)


df <- database %>% select(income1:income2) #modify if want different explanators


choiceAnalysis_settings <- list(
alternatives = c(opt1 = 1, opt2 = 2, out = 3),
avail = with(database, list(
opt1 = choice1, opt2 = choice2, out = choice3
)),
choiceVar = database$choice,
explanators = database
)


apollo_choiceAnalysis(choiceAnalysis_settings, apollo_control, database) #this does not work, Error in if (x[1] == x[2]) { : missing value where TRUE/FALSE needed

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

### Vector of parameters, including any that are kept fixed in estimation
apollo_beta = c(
asc_opt1 = 0,
asc_opt2 = 0,
asc_out =0,
b_income = 0,
b_trend = 0,
b_centile = 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('asc_out')

# ################################################################# #
#### GROUP AND VALIDATE INPUTS ####
# ################################################################# #

apollo_inputs = apollo_validateInputs()

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

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

### List of utilities: these must use the same names as in mnl_settings, order is irrelevant
V = list()
V[['out']] = asc_out
V[['opt1']] = asc_opt1 + b_income * income1 + b_trend * trend1 + b_centile * centile1
V[['opt2']] = asc_opt2 + b_income * income2 + b_trend * trend2 + b_centile * centile2


### Define settings for MNL model component
mnl_settings = list(
alternatives = c(opt1=1, opt2=2, out=3),
avail = list(opt1=choice1, opt2 = choice2, out=choice3),
choiceVar = choice,
V = 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)
stephanehess
Site Admin
Posts: 998
Joined: 24 Apr 2020, 16:29

Re: Error: the variable does not influence the log-likelihood of your model

Post by stephanehess »

Hi

the data was not included, so we can't test this ourselves, but one suspicion is that it could be caused by loading the data from an Excel file. We recommend working with csv. If that doesn't solve it, then please send us the data and we'll have a look

Thanks

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