Mixtures of logit with Monte-Carlo 2000 draws

Estimation of a mixtures of logit models where the integral is approximated using MonteCarlo integration.

author:

Michel Bierlaire, EPFL

date:

Thu Apr 13 21:04:47 2023

import biogeme.biogeme_logging as blog
from biogeme.expressions import bioDraws
from b07estimation_specification import get_biogeme
logger = blog.get_screen_logger(level=blog.INFO)
logger.info('Example b07estimation_monte_carlo.py')
Example b07estimation_monte_carlo.py
R = 2000
the_draws = bioDraws('B_TIME_RND', 'NORMAL')
the_biogeme = get_biogeme(the_draws=the_draws, number_of_draws=R)
the_biogeme.modelName = 'b07estimation_monte_carlo'
File /var/folders/rp/ppksq7xd6_x7p0jb0t73x7vw0000gq/T/tmpkxuy7qyg/f76f6f0e-c22c-4824-b4c3-b1aae35dff83 has been parsed.
results = the_biogeme.estimate()
*** Initial values of the parameters are obtained from the file __b07estimation_monte_carlo.iter
Cannot read file __b07estimation_monte_carlo.iter. Statement is ignored.
Optimization algorithm: hybrid Newton/BFGS with simple bounds [simple_bounds]
** Optimization: Newton with trust region for simple bounds
Iter.         asc_car       asc_train          b_cost          b_time        b_time_s     Function    Relgrad   Radius      Rho
    0          -0.082           -0.79           -0.32              -1            0.87      5.4e+03      0.046       10        1   ++
    1            0.02           -0.56           -0.99            -1.6            0.93      5.2e+03     0.0088    1e+02      1.1   ++
    2             0.1           -0.42            -1.2            -2.1             1.4      5.2e+03     0.0054    1e+03      1.1   ++
    3            0.13            -0.4            -1.3            -2.2             1.6      5.2e+03    0.00075    1e+04      1.1   ++
    4            0.14            -0.4            -1.3            -2.3             1.7      5.2e+03    1.5e-05    1e+05        1   ++
    5            0.14            -0.4            -1.3            -2.3             1.7      5.2e+03    5.2e-09    1e+05        1   ++
print(results.short_summary())
Results for model b07estimation_monte_carlo
Nbr of parameters:              5
Sample size:                    6768
Excluded data:                  3960
Final log likelihood:           -5213.489
Akaike Information Criterion:   10436.98
Bayesian Information Criterion: 10471.08
pandas_results = results.getEstimatedParameters()
pandas_results
Value Rob. Std err Rob. t-test Rob. p-value
asc_car 0.138119 0.051727 2.670175 7.581183e-03
asc_train -0.400959 0.066011 -6.074165 1.246349e-09
b_cost -1.284884 0.086349 -14.880049 0.000000e+00
b_time -2.264317 0.116781 -19.389360 0.000000e+00
b_time_s 1.663548 0.132216 12.582038 0.000000e+00


Total running time of the script: (4 minutes 52.780 seconds)

Gallery generated by Sphinx-Gallery