Mixtures of logit with Monte-Carlo 10_000 antithetic MLHS drawsΒΆ

Estimation of a mixtures of logit models where the integral is approximated using MonteCarlo integration with antithetic MLHS draws.

Michel Bierlaire, EPFL Tue Apr 29 2025, 12:18:23

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_specification_mlhs_anti.py')
Example b07estimation_specification_mlhs_anti.py
R = 10_000
the_draws = Draws('b_time_rnd', 'NORMAL_MLHS_ANTI')
the_biogeme = get_biogeme(the_draws=the_draws, number_of_draws=R)
the_biogeme.model_name = 'b07estimation_monte_carlo_mlhs_anti'
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_mlhs_anti
Nbr of parameters:              5
Sample size:                    10719
Excluded data:                  9
Final log likelihood:           -8571.213
Akaike Information Criterion:   17152.43
Bayesian Information Criterion: 17188.82

Get the results in a pandas table

pandas_results = get_pandas_estimated_parameters(
    estimation_results=results,
)
display(pandas_results)
{'Estimated parameters':         Name     Value  Robust std err.  Robust t-stat.  Robust p-value
0  asc_train -0.467496         0.047980       -9.743554    0.000000e+00
1     b_time -1.862680         0.076037      -24.496887    0.000000e+00
2   b_time_s  1.208254         0.088641       13.630802    0.000000e+00
3     b_cost -0.845435         0.057668      -14.660421    0.000000e+00
4    asc_car  0.179972         0.035163        5.118242    3.083975e-07}

Total running time of the script: (0 minutes 1.451 seconds)

Gallery generated by Sphinx-Gallery