Note
Go to the end to download the full example code.
Mixtures of logit with Monte-Carlo 2000 antithetic MLHS draws
Estimation of a mixtures of logit models where the integral is approximated using MonteCarlo integration with antithetic MLHS draws.
- author:
Michel Bierlaire, EPFL
- date:
Thu Apr 13 23:40:02 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_specification_mlhs_anti_500.py')
Example b07estimation_specification_mlhs_anti_500.py
R = 500
the_draws = bioDraws('b_time_rnd', 'NORMAL_MLHS_ANTI')
the_biogeme = get_biogeme(the_draws=the_draws, number_of_draws=R)
the_biogeme.modelName = 'b07estimation_monte_carlo_mlhs_anti_500'
Biogeme parameters read from biogeme.toml.
results = the_biogeme.estimate()
As the model is rather complex, we cancel the calculation of second derivatives. If you want to control the parameters, change the name of the algorithm in the TOML file from "automatic" to "simple_bounds"
*** Initial values of the parameters are obtained from the file __b07estimation_monte_carlo_mlhs_anti_500.iter
Cannot read file __b07estimation_monte_carlo_mlhs_anti_500.iter. Statement is ignored.
The number of draws (500) is low. The results may not be meaningful.
As the model is rather complex, we cancel the calculation of second derivatives. If you want to control the parameters, change the name of the algorithm in the TOML file from "automatic" to "simple_bounds"
Optimization algorithm: hybrid Newton/BFGS with simple bounds [simple_bounds]
** Optimization: BFGS with trust region for simple bounds
Iter. asc_car asc_train b_cost b_time b_time_s Function Relgrad Radius Rho
0 1 -1 -1 -1 2 9.8e+03 0.15 1 0.23 +
1 0 -0.79 0 -2 2.3 9e+03 0.065 1 0.32 +
2 0.4 -0.64 -1 -2 2.2 8.7e+03 0.033 1 0.61 +
3 0.4 -0.64 -1 -2 2.2 8.7e+03 0.033 0.5 -1.4 -
4 0.4 -0.64 -1 -2 2.2 8.7e+03 0.033 0.25 0.04 -
5 0.15 -0.45 -0.75 -2.2 2 8.6e+03 0.015 0.25 0.66 +
6 0.33 -0.45 -0.94 -2.3 1.7 8.6e+03 0.017 0.25 0.34 +
7 0.33 -0.45 -0.94 -2.3 1.7 8.6e+03 0.017 0.12 -0.53 -
8 0.2 -0.33 -0.9 -2.2 1.7 8.6e+03 0.0093 0.12 0.35 +
9 0.31 -0.39 -0.81 -2.1 1.6 8.6e+03 0.0072 0.12 0.56 +
10 0.31 -0.39 -0.81 -2.1 1.6 8.6e+03 0.0072 0.062 -0.11 -
11 0.31 -0.39 -0.81 -2.1 1.6 8.6e+03 0.0072 0.031 0.007 -
12 0.28 -0.42 -0.85 -2.1 1.6 8.6e+03 0.0055 0.031 0.52 +
13 0.25 -0.39 -0.88 -2.1 1.5 8.6e+03 0.0032 0.031 0.59 +
14 0.24 -0.42 -0.86 -2.1 1.5 8.6e+03 0.0048 0.031 0.88 +
15 0.23 -0.39 -0.86 -2.1 1.5 8.6e+03 0.0029 0.031 0.73 +
16 0.24 -0.42 -0.86 -2.1 1.4 8.6e+03 0.0033 0.031 0.79 +
17 0.22 -0.41 -0.86 -2 1.4 8.6e+03 0.002 0.031 0.87 +
18 0.23 -0.43 -0.86 -2 1.4 8.6e+03 0.0019 0.031 0.8 +
19 0.2 -0.43 -0.85 -2 1.4 8.6e+03 0.0015 0.031 0.81 +
20 0.21 -0.45 -0.85 -2 1.3 8.6e+03 0.0014 0.031 0.76 +
21 0.19 -0.44 -0.85 -1.9 1.3 8.6e+03 0.001 0.031 0.75 +
22 0.19 -0.46 -0.85 -1.9 1.3 8.6e+03 0.0013 0.031 0.73 +
23 0.19 -0.46 -0.85 -1.9 1.3 8.6e+03 0.0013 0.016 0.027 -
24 0.19 -0.45 -0.85 -1.9 1.3 8.6e+03 0.0007 0.016 0.59 +
25 0.18 -0.46 -0.84 -1.9 1.2 8.6e+03 0.00062 0.016 0.75 +
26 0.18 -0.46 -0.84 -1.9 1.2 8.6e+03 0.00062 0.0078 -0.46 -
27 0.19 -0.47 -0.85 -1.9 1.2 8.6e+03 0.00073 0.0078 0.18 +
28 0.18 -0.46 -0.84 -1.9 1.2 8.6e+03 0.00021 0.078 0.94 ++
29 0.18 -0.46 -0.84 -1.9 1.2 8.6e+03 0.00021 0.039 -40 -
30 0.18 -0.46 -0.84 -1.9 1.2 8.6e+03 0.00021 0.02 -2.6 -
31 0.18 -0.47 -0.85 -1.9 1.2 8.6e+03 0.00019 0.02 0.61 +
32 0.18 -0.47 -0.85 -1.9 1.2 8.6e+03 0.00019 0.0098 -6.5 -
33 0.18 -0.47 -0.85 -1.9 1.2 8.6e+03 0.00019 0.0049 -1.6 -
34 0.18 -0.47 -0.84 -1.9 1.2 8.6e+03 0.00036 0.0049 0.12 +
35 0.18 -0.47 -0.84 -1.9 1.2 8.6e+03 0.00025 0.0049 0.25 +
36 0.18 -0.47 -0.84 -1.9 1.2 8.6e+03 0.00025 0.0024 -0.84 -
37 0.18 -0.47 -0.84 -1.9 1.2 8.6e+03 7.1e-05 0.0024 0.65 -
Results saved in file b07estimation_monte_carlo_mlhs_anti_500.html
Results saved in file b07estimation_monte_carlo_mlhs_anti_500.pickle
print(results.short_summary())
Results for model b07estimation_monte_carlo_mlhs_anti_500
Nbr of parameters: 5
Sample size: 10719
Excluded data: 9
Final log likelihood: -8571.894
Akaike Information Criterion: 17153.79
Bayesian Information Criterion: 17190.19
pandas_results = results.get_estimated_parameters()
pandas_results
Total running time of the script: (1 minutes 47.963 seconds)