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.

Identification problem

Ask questions about errors you encouunter. Please make sure to include full details about your model specifications, and ideally your model file.
Post Reply
EduardoValencia
Posts: 1
Joined: 11 May 2020, 22:20

Identification problem

Post by EduardoValencia »

Hello,

I have been testing the apollo package with a personal database. When trying to estimate an MNL model I receive the following error:

"Testing likelihood function ..Error in apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, :
Parameter b_female does not influence the log-likelihood of your model!"

for what reason can this happen?

the model tries to take as a dependent variable whether or not the individual leaves a certain reference distance. In this test I tried only to use variables that describe the individuals, I have not used characteristics of each alternative.

Thanks in advance for your time!

Eduardo Valencia.

--------------------------------------------------------------------------------------------------------------------------------------------------

rm(list = ls())

library(apollo)

apollo_initialise()

## Controles de apollo

apollo_control = list(
modelName = "Prueba 1",
modelDescr = "modelo MNL de largo de viaje con variables socio-económicas",
indivID = "ID",
panelData = FALSE)

## Cargar base de datos

library(readr)
database = read_delim("C:/Users/edova/OneDrive/Memoria de Titulo/Base de datos/BasesDatos_Finales/Modelación/Prueba 1/p11.csv",
";", escape_double = FALSE, trim_ws = TRUE)

database = na.omit(database)

View(database)
summary(database)

## Párametros del modelo
## definir valores iniciales de cada parámetros asociado a las variables
## o constantes especificas por alternativa.

apollo_beta=c(b_female = 0,
b_edad = 0,
b_escmadre = 0,
b_ingreso_b = 0,
b_ingreso_mb = 0,
b_ingreso_m = 0,
b_ingreso_ma = 0,
b_ingreso_a = 0,
b_nivelens_parv = 0,
b_nivelens_basi = 0,
b_nivelens_mediahc = 0,
b_nivelens_mediatp = 0)

apollo_fixed = c("b_ingreso_b", "b_nivelens_parv")

## Validación y preparación de los datos de entrada.
## Función de control para revisar que todo esté en orden.

apollo_inputs = apollo_validateInputs()

## Definición del modelo y función de verosimilitud.

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

### Permite llamar individualmente a cada objeto de la base de datos
apollo_attach(apollo_beta, apollo_inputs)
on.exit(apollo_detach(apollo_beta, apollo_inputs))

### Crear lista de probabilidades P
P = list()

### Lista de utilidades: Se deben usar los mismos nombres que en mnl_settings, orden irrelevante.
V = list()

V[['Dentro']] = b_female*femenino + b_edad*edad_alu + b_escmadre*esc_madre + b_ingreso_b*ingresobajo + b_ingreso_mb*ingresombajo + b_ingreso_m*ingresomedio + b_ingreso_ma*ingresomalto + b_ingreso_a*ingresoalto + b_nivelens_parv*ensparv + b_nivelens_basi*ensbasica + b_nivelens_mediahc*ensmediahc + b_nivelens_mediatp*ensmediatp

V[['Fuera']] = b_female*femenino + b_edad*edad_alu + b_escmadre*esc_madre + b_ingreso_b*ingresobajo + b_ingreso_mb*ingresombajo + b_ingreso_m*ingresomedio + b_ingreso_ma*ingresomalto + b_ingreso_a*ingresoalto + b_nivelens_parv*ensparv + b_nivelens_basi*ensbasica + b_nivelens_mediahc*ensmediahc + b_nivelens_mediatp*ensmediatp

### Define la configuración para los componentes del modelo MNL
mnl_settings = list(
alternatives = c(Dentro=1, Fuera=2),
avail = list(Dentro=1,Fuera=1),
choiceVar = choice,
V = V
)

### calcula las probabilidades usando MNL
P[["model"]] = apollo_mnl(mnl_settings, functionality)

### Tome el producto a través de la observación para el mismo individuo
## P = apollo_panelProd(P, apollo_inputs, functionality)

### Preparar y devolver salidas de función
P = apollo_prepareProb(P, apollo_inputs, functionality)
return(P)
}

## Estimación del modelo

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

## Salida del modelo

apollo_modelOutput(model)

apollo_saveOutput(model)
stephanehess
Site Admin
Posts: 1050
Joined: 24 Apr 2020, 16:29

Re: Identification problem

Post by stephanehess »

Hi Eduardo

you have included the same terms in both utilities, so the model is not identified. Apollo is telling you that b_female (the first parameter it tries) cannot change the log-likelihood as it influences both utilities in the same way.

Best wishes

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