Page 1 of 1

Identification problem

Posted: 12 May 2020, 00:45
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)

Re: Identification problem

Posted: 12 May 2020, 13:31
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