Ali Karami
unread,Jul 31, 2025, 11:33:24 AMJul 31Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Biogeme
Dear Prof. Bierlaire,
I hope this email finds you well.
First of all, I would like to sincerely thank you for developing the comprehensive and powerful Python Biogeme package. It has been an invaluable tool in my research.
I am currently working on a hybrid choice model that includes two latent variables. However, I’ve encountered a persistent issue during estimation:
Final log likelihood: nan
McFadden's rho-squared: 0.0
Despite reviewing the documentation and examples, I have not been able to resolve the problem. I would be very grateful if you could kindly help me identify any potential issues in my implementation.
Below, I’ve outlined the key components of my model:
Structural Equations for Latent Variables
γe_age = Beta('γe_age', 0, None, None, 0)
γe_gender = Beta('γe_gender', 0, None, None, 0)
γe_inc = Beta('γe_inc', 0, None, None, 0)
η_env = bioDraws('ETA_ENV', 'NORMAL')
sigma_s_Env = Beta('sigma_s_Env', 1, None, None, 0)
LV_env = γe_age * Age \
+ γe_gender * Gender \
+ γe_inc * Income \
+ sigma_s_Env * η_env
Measurement Equations (Example)
INTER_alfa_Enviro1 = Beta('INTER_alfa_Enviro1', 0, -10000, 10000, 1)
B_Enviro_Loading1 = Beta('B_Enviro_Loading1', -1, -10000, 10000, 1)
MODEL_Enviro1 = INTER_alfa_Enviro1 + B_Enviro_Loading1 * LV_env
SIGMA_STAR_Enviro1 = Beta('SIGMA_STAR_Enviro1', 1, 1e-6, None, 1)
tau_1_Enviro1 = -delta_1_Enviro1 - delta_2_Enviro1
tau_2_Enviro1 = -delta_1_Enviro1
tau_3_Enviro1 = delta_1_Enviro1
tau_4_Enviro1 = delta_1_Enviro1 + delta_2_Enviro1
Enviro1_tau_1 = (tau_1_Enviro1 - MODEL_Enviro1) / SIGMA_STAR_Enviro1
Enviro1_tau_2 = (tau_2_Enviro1 - MODEL_Enviro1) / SIGMA_STAR_Enviro1
Enviro1_tau_3 = (tau_3_Enviro1 - MODEL_Enviro1) / SIGMA_STAR_Enviro1
Enviro1_tau_4 = (tau_4_Enviro1 - MODEL_Enviro1) / SIGMA_STAR_Enviro1
Ind_Enviro1 = {
1: Φ(Enviro1_tau_1),
2: Φ(Enviro1_tau_2) - Φ(Enviro1_tau_1),
3: Φ(Enviro1_tau_3) - Φ(Enviro1_tau_2),
4: Φ(Enviro1_tau_4) - Φ(Enviro1_tau_3),
5: 1 - Φ(Enviro1_tau_4),
6: 1.0
}
P_Enviro1 = Elem(Ind_Enviro1, Envir01)
This process is repeated for all indicators.
Choice Model Specification
ASC_car = Beta('ASC_car', 0, None, None, 0)
ASC_pt = Beta('ASC_pt', 0, None, None, 0)
ASC_oth = Beta('ASC_oth', 0, None, None, 0)
β_time = Beta('β_time', 0, None, None, 0)
β_cost = Beta('β_cost', 0, None, None, 0)
δ_env = Beta('δ_env', 0, None, None, 0)
δ_mob = Beta('δ_mob', 0, None, None, 0)
V = {
0: β_time * TimeCar + β_cost * CostCar + δ_env * LV_env + δ_mob * LV_mob,
1: ASC_pt + β_time * TimePT + β_cost * CostPT + δ_env * LV_env + δ_mob * LV_mob,
2: ASC_oth + δ_env * LV_env + δ_mob * LV_mob
}
avail = {0: 1, 1: 1, 2: 1}
prob_choice = loglogit(V, avail, Choice)
Joint Likelihood and Monte Carlo Integration
cond_prob = log(prob_choice) \
+ log(P_Enviro1) + log(P_Enviro2) + log(P_Enviro3) \
+ log(P_Mobil1) + log(P_Mobil2)
loglike = MonteCarlo(cond_prob)
biogeme_obj = BIOGEME(database, loglike, numberOfDraws=100)
biogeme_obj.modelName = "OPT_HCM_SigmaEnhanced"
# Estimate and grab results
results = biogeme_obj.estimate()
Despite following the recommended structure, the estimation returns nan for the log-likelihood and 0.0 for McFadden’s rho-squared. I suspect the issue may lie in the integration or the measurement equations, but I would deeply appreciate your expert insight.
Thank you very much for your time and consideration. I look forward to any guidance you may be able to offer.
Warm regards,
Ali