Numerical and index errors in Ordinal logit and latent class model

217 views
Skip to first unread message

Ishant Sharma

unread,
Dec 8, 2018, 6:40:25 AM12/8/18
to Biogeme
Dear Prof  Bierlaire,

I have been trying to run ordered logit and hybrid choice model in pythonbiogeme (python scripts attached). Its been one week since I have been using biogeme and I am pretty new to the software. 

I am following Swiss metro examples for both ordered logit and latent class hybrid choice model, but I am getting following  errors in both the models:

  1. /usr/local/bin/pythonbiogeme: line 52:  6131 Aborted                 (core dumped) "${bindir}/pybiogeme${versionsuffix}" "$p" "$d"
This error also adds a warning as 
Warning:  Index 6 not valid in expression Elem({1: ( 1 ) - ( ( 1 ) / ( 1 + exp(( -(( ( B_gender * gender + B_age * age + B_emptype * emptype + B_income * income + B_telework * TeleworkFreq + B_flex * ScheduleFlex + B_smartphone * Smartphone + B_radio * Radio + B_tv * TV + B_disability * Disability + B_hhsize * HHSize + B_hhincome * HHIncome + B_hhcars * HHCars + B_hhcarshist10 * HHCarsHist10 + B_hhcarshistused10 * HHCarsHistUsed10 + B_purfreq * CarPurchFreq + B_carnext * CarNext3 + B_WTP * WTP + B_WTPMaint * WTPMaint + B_socTies * NumSocialTies + B_commFreq * CommFreq ) - tau1 ) - ( 0 )) ) / ( 1 )) ) )},{2: ( ( 1 ) / ( 1 + exp(( -(( ( B_gender * gender + B_age * age + B_emptype * emptype + B_income * income + B_telework * TeleworkFreq + B_flex * ScheduleFlex + B_smartphone * Smartphone + B_radio * Radio + B_tv * TV + B_disability * Disability + B_hhsize * HHSize + B_hhincome * HHIncome + B_hhcars * HHCars + B_hhcarshist10 * HHCarsHist10 + B_hhcarshistused10 * HHCarsHistUsed10 + B_purfreq * CarPurchFreq + B_carnext * CarNext3 + B_WTP * WTP + B_WTPMaint * WTPMaint + B_socTies * NumSocialTies + B_commFreq * CommFreq ) - tau1 ) - ( 0 )) ) / ( 1 )) ) ) - ( ( 1 ) / ( 1 + exp(( -(( ( B_gender * gender + B_age * age + B_emptype * emptype + B_income * income + B_telework * TeleworkFreq + B_flex * ScheduleFlex + B_smartphone * Smartphone + B_radio * Radio + B_tv * TV + B_disability * Disability + B_hhsize * HHSize + B_hhincome * HHIncome + B_hhcars * HHCars + B_hhcarshist10 * HHCarsHist10 + B_hhcarshistused10 * HHCarsHistUsed10 + B_purfreq * CarPurchFreq + B_carnext * CarNext3 + B_WTP * WTP + B_WTPMaint * WTPMaint + B_socTies * NumSocialTies + B_commFreq * CommFreq ) - ( tau1 + delta2 ) ) - ( 0 )) ) / ( 1 )) ) )},{3: ( 1 ) / ( 1 + exp(( -(( ( B_gender * gender + B_age * age + B_emptype * emptype + B_income * income + B_telework * TeleworkFreq + B_flex * ScheduleFlex + B_smartphone * Smartphone + B_radio * Radio + B_tv * TV + B_disability * Disability + B_hhsize * HHSize + B_hhincome * HHIncome + B_hhcars * HHCars + B_hhcarshist10 * HHCarsHist10 + B_hhcarshistused10 * HHCarsHistUsed10 + B_purfreq * CarPurchFreq + B_carnext * CarNext3 + B_WTP * WTP + B_WTPMaint * WTPMaint + B_socTies * NumSocialTies + B_commFreq * CommFreq ) - ( tau1 + delta2 ) ) - ( 0 )) ) / ( 1 )) )}[CHOICE][02.

2.  Warning:  Error: There is a numerical problem with the initial log likelihood.
 It typically happens when one observation is associated with a very low probability,
 so that taking the log generates a very high number.
 Modify the starting values of the parameters.
 You may want to use the SIMULATE feature of pythonbiogeme to identify the cause of the problem.

I have already tried increasing the starting value of sigma and other parameters, but it is not working. 

Please assist me in correcting this error. 

Thank you. 

Ishant Sharma
 
 
OL_trial1.py
latentv1.py

Michel Bierlaire

unread,
Dec 8, 2018, 7:16:00 AM12/8/18
to reachish...@gmail.com, Michel Bierlaire, Biogeme

On 8 Dec 2018, at 09:35, Ishant Sharma <reachish...@gmail.com> wrote:

Dear Prof  Bierlaire,

I have been trying to run ordered logit and hybrid choice model in pythonbiogeme (python scripts attached). Its been one week since I have been using biogeme and I am pretty new to the software. 

I am following Swiss metro examples for both ordered logit and latent class hybrid choice model, but I am getting following  errors in both the models:

  1. /usr/local/bin/pythonbiogeme: line 52:  6131 Aborted                 (core dumped) "${bindir}/pybiogeme${versionsuffix}" "$p" "$d"
This error also adds a warning as 
Warning:  Index 6 not valid in expression Elem({1: ( 1 ) - ( ( 1 ) / ( 1 + exp(( -(( ( B_gender * gender + B_age * age + B_emptype * emptype + B_income * income + B_telework * TeleworkFreq + B_flex * ScheduleFlex + B_smartphone * Smartphone + B_radio * Radio + B_tv * TV + B_disability * Disability + B_hhsize * HHSize + B_hhincome * HHIncome + B_hhcars * HHCars + B_hhcarshist10 * HHCarsHist10 + B_hhcarshistused10 * HHCarsHistUsed10 + B_purfreq * CarPurchFreq + B_carnext * CarNext3 + B_WTP * WTP + B_WTPMaint * WTPMaint + B_socTies * NumSocialTies + B_commFreq * CommFreq ) - tau1 ) - ( 0 )) ) / ( 1 )) ) )},{2: ( ( 1 ) / ( 1 + exp(( -(( ( B_gender * gender + B_age * age + B_emptype * emptype + B_income * income + B_telework * TeleworkFreq + B_flex * ScheduleFlex + B_smartphone * Smartphone + B_radio * Radio + B_tv * TV + B_disability * Disability + B_hhsize * HHSize + B_hhincome * HHIncome + B_hhcars * HHCars + B_hhcarshist10 * HHCarsHist10 + B_hhcarshistused10 * HHCarsHistUsed10 + B_purfreq * CarPurchFreq + B_carnext * CarNext3 + B_WTP * WTP + B_WTPMaint * WTPMaint + B_socTies * NumSocialTies + B_commFreq * CommFreq ) - tau1 ) - ( 0 )) ) / ( 1 )) ) ) - ( ( 1 ) / ( 1 + exp(( -(( ( B_gender * gender + B_age * age + B_emptype * emptype + B_income * income + B_telework * TeleworkFreq + B_flex * ScheduleFlex + B_smartphone * Smartphone + B_radio * Radio + B_tv * TV + B_disability * Disability + B_hhsize * HHSize + B_hhincome * HHIncome + B_hhcars * HHCars + B_hhcarshist10 * HHCarsHist10 + B_hhcarshistused10 * HHCarsHistUsed10 + B_purfreq * CarPurchFreq + B_carnext * CarNext3 + B_WTP * WTP + B_WTPMaint * WTPMaint + B_socTies * NumSocialTies + B_commFreq * CommFreq ) - ( tau1 + delta2 ) ) - ( 0 )) ) / ( 1 )) ) )},{3: ( 1 ) / ( 1 + exp(( -(( ( B_gender * gender + B_age * age + B_emptype * emptype + B_income * income + B_telework * TeleworkFreq + B_flex * ScheduleFlex + B_smartphone * Smartphone + B_radio * Radio + B_tv * TV + B_disability * Disability + B_hhsize * HHSize + B_hhincome * HHIncome + B_hhcars * HHCars + B_hhcarshist10 * HHCarsHist10 + B_hhcarshistused10 * HHCarsHistUsed10 + B_purfreq * CarPurchFreq + B_carnext * CarNext3 + B_WTP * WTP + B_WTPMaint * WTPMaint + B_socTies * NumSocialTies + B_commFreq * CommFreq ) - ( tau1 + delta2 ) ) - ( 0 )) ) / ( 1 )) )}[CHOICE][02.


The warning is quite explicit. The keys of this dictionary are 1,2 and 3, and there are observations where the variable CHOICE is 6. Therefore, 0 is returned, which is probably not the desired outcome. So the warning.  

2.  Warning:  Error: There is a numerical problem with the initial log likelihood.
 It typically happens when one observation is associated with a very low probability,
 so that taking the log generates a very high number.
 Modify the starting values of the parameters.
 You may want to use the SIMULATE feature of pythonbiogeme to identify the cause of the problem.

This is probably related to the previous error. Indeed, it just takes one observation associated with a zero likelihood to generate a numerical problem. The SIMULATE feature may help you identify which one.



I have already tried increasing the starting value of sigma and other parameters, but it is not working. 

Please assist me in correcting this error. 

Thank you. 

Ishant Sharma
 
 

--
You received this message because you are subscribed to the Google Groups "Biogeme" group.
To unsubscribe from this group and stop receiving emails from it, send an email to biogeme+u...@googlegroups.com.
To post to this group, send email to bio...@googlegroups.com.
Visit this group at https://groups.google.com/group/biogeme.
For more options, visit https://groups.google.com/d/optout.
<OL_trial1.py><latentv1.py>

Ishant Sharma

unread,
Dec 10, 2018, 6:14:29 AM12/10/18
to Biogeme
Dear Prof Bierlaire,


Thank you for the quick response.

I was able to identify the observations with SIMULATE command. 

Almost 75% of the observations are associated with zero likelihood, But I am not sure how to deal with them like will I have to exclude all these observations from my input dataset or there is a command which can exclude these observations?

Thank you
Reply all
Reply to author
Forward
0 new messages