Note
Go to the end to download the full example code.
Mixtures of logit with Monte-Carlo 500 antithetic drawsΒΆ
Estimation of a mixtures of logit models where the integral is approximated using MonteCarlo integration with antithetic draws.
Michel Bierlaire, EPFL Sun Jun 29 2025, 06:47:25
from b07estimation_specification import get_biogeme
from IPython.core.display_functions import display
import biogeme.biogeme_logging as blog
from biogeme.expressions import Draws
from biogeme.results_processing import (
EstimationResults,
get_pandas_estimated_parameters,
)
logger = blog.get_screen_logger(level=blog.INFO)
logger.info('Example b07estimation_monte_carlo_anti_500.py')
Example b07estimation_monte_carlo_anti_500.py
R = 500
the_draws = Draws('b_time_rnd', 'NORMAL_ANTI')
the_biogeme = get_biogeme(the_draws=the_draws, number_of_draws=R)
the_biogeme.model_name = 'b07estimation_monte_carlo_anti_500'
results_file = f'saved_results/{the_biogeme.model_name}.yaml'
Biogeme parameters read from biogeme.toml.
try:
results = EstimationResults.from_yaml_file(filename=results_file)
except FileNotFoundError:
results = the_biogeme.estimate()
print(results.short_summary())
Results for model b07estimation_monte_carlo_anti_500
Nbr of parameters: 5
Sample size: 10719
Excluded data: 9
Final log likelihood: -8570.859
Akaike Information Criterion: 17151.72
Bayesian Information Criterion: 17188.12
Get the results in a pandas table
pandas_results = get_pandas_estimated_parameters(
estimation_results=results,
)
display(pandas_results)
Name Value Robust std err. Robust t-stat. Robust p-value
0 asc_train -0.466611 0.048004 -9.720336 0.000000e+00
1 b_time -1.862231 0.076534 -24.332180 0.000000e+00
2 b_time_s 1.205115 0.092049 13.092163 0.000000e+00
3 b_cost -0.844928 0.057569 -14.676881 0.000000e+00
4 asc_car 0.180405 0.035198 5.125364 2.969633e-07
Total running time of the script: (0 minutes 0.251 seconds)