Note
Go to the end to download the full example code
One model among many
We consider the model with 432 specifications defined in Combination of many specifications. We select one specification and estimate it. See Bierlaire and Ortelli (2023).
- author:
Michel Bierlaire, EPFL
- date:
Sat Jul 15 15:46:56 2023
import biogeme.biogeme_logging as blog
import biogeme.biogeme as bio
from everything_spec import model_catalog, database, av
logger = blog.get_screen_logger(level=blog.INFO)
The code characterizing the specification should be copied from the .pareto file generated by the algorithm, or from one of the glossaries illustrated in earlier examples.
SPEC_ID = (
'ASC:GA-LUGGAGE;'
'B_COST_gen_altspec:generic;'
'B_TIME:FIRST;'
'B_TIME_gen_altspec:generic;'
'model_catalog:logit;'
'train_tt_catalog:power'
)
the spec_id, and used as usual.
the_biogeme = bio.BIOGEME.from_configuration(
config_id=SPEC_ID,
expression=model_catalog,
database=database,
)
the_biogeme.modelName = 'my_favorite_model'
File biogeme.toml has been parsed.
Calculate of the null log-likelihood for reporting.
the_biogeme.calculateNullLoglikelihood(av)
-6964.662979191462
Estimate the parameters.
results = the_biogeme.estimate()
*** Initial values of the parameters are obtained from the file __my_favorite_model.iter
Cannot read file __my_favorite_model.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_CAR_GA ASC_CAR_one_lug ASC_CAR_several ASC_TRAIN ASC_TRAIN_GA ASC_TRAIN_one_l ASC_TRAIN_sever B_COST B_TIME B_TIME_1st_clas cube_tt_coef square_tt_coef Function Relgrad Radius Rho
0 0 0 0 0 0 0 0 0 0 0 0 0 0 7e+03 0.27 0.5 -1.7 -
1 -0.068 -0.065 -0.064 -0.0096 -0.5 0.024 -0.5 -0.026 -0.15 -0.5 -0.5 0 0 5.6e+03 8 5 1.1 ++
2 -0.068 -0.065 -0.064 -0.0096 -0.5 0.024 -0.5 -0.026 -0.15 -0.5 -0.5 0 0 5.6e+03 8 2.5 -9.2 -
3 -0.068 -0.065 -0.064 -0.0096 -0.5 0.024 -0.5 -0.026 -0.15 -0.5 -0.5 0 0 5.6e+03 8 1.2 -8.9 -
4 -0.068 -0.065 -0.064 -0.0096 -0.5 0.024 -0.5 -0.026 -0.15 -0.5 -0.5 0 0 5.6e+03 8 0.62 -8.5 -
5 -0.068 -0.065 -0.064 -0.0096 -0.5 0.024 -0.5 -0.026 -0.15 -0.5 -0.5 0 0 5.6e+03 8 0.31 -5.6 -
6 -0.068 -0.065 -0.064 -0.0096 -0.5 0.024 -0.5 -0.026 -0.15 -0.5 -0.5 0 0 5.6e+03 8 0.16 -3.2 -
7 -0.068 -0.065 -0.064 -0.0096 -0.5 0.024 -0.5 -0.026 -0.15 -0.5 -0.5 0 0 5.6e+03 8 0.078 -2.7 -
8 -0.068 -0.065 -0.064 -0.0096 -0.5 0.024 -0.5 -0.026 -0.15 -0.5 -0.5 0 0 5.6e+03 8 0.039 -2.7 -
9 -0.068 -0.065 -0.064 -0.0096 -0.5 0.024 -0.5 -0.026 -0.15 -0.5 -0.5 0 0 5.6e+03 8 0.02 -3 -
10 -0.068 -0.065 -0.064 -0.0096 -0.5 0.024 -0.5 -0.026 -0.15 -0.5 -0.5 0 0 5.6e+03 8 0.0098 -3.2 -
11 -0.068 -0.065 -0.064 -0.0096 -0.5 0.024 -0.5 -0.026 -0.15 -0.5 -0.5 0 0 5.6e+03 8 0.0049 -3.4 -
12 -0.068 -0.065 -0.064 -0.0096 -0.5 0.024 -0.5 -0.026 -0.15 -0.5 -0.5 0 0 5.6e+03 8 0.0024 -2.2 -
13 -0.068 -0.065 -0.064 -0.0096 -0.5 0.024 -0.5 -0.026 -0.15 -0.5 -0.5 0 0 5.6e+03 8 0.0012 -1.5 -
14 -0.068 -0.065 -0.064 -0.0096 -0.5 0.024 -0.5 -0.026 -0.15 -0.5 -0.5 0 0 5.6e+03 8 0.00061 -0.8 -
15 -0.068 -0.065 -0.064 -0.0096 -0.5 0.024 -0.5 -0.026 -0.15 -0.5 -0.5 0 0 5.6e+03 8 0.00031 -0.045 -
16 -0.068 -0.066 -0.064 -0.0099 -0.5 0.024 -0.5 -0.026 -0.15 -0.5 -0.5 -0.00031 0.00031 5.6e+03 3 0.00031 0.7 +
17 -0.068 -0.066 -0.064 -0.0099 -0.5 0.025 -0.5 -0.026 -0.15 -0.5 -0.5 -0.00026 0.00061 5.6e+03 1 0.00031 0.87 +
18 -0.068 -0.066 -0.064 -0.0099 -0.5 0.025 -0.5 -0.026 -0.16 -0.5 -0.5 -0.00027 0.00092 5.6e+03 0.069 0.0031 1 ++
19 -0.068 -0.066 -0.065 -0.01 -0.5 0.026 -0.5 -0.026 -0.16 -0.5 -0.5 -0.00023 0.004 5.6e+03 4.5 0.031 1 ++
20 -0.069 -0.072 -0.069 -0.011 -0.51 0.043 -0.49 -0.027 -0.19 -0.52 -0.51 -0.00043 0.034 5.5e+03 1.5 0.31 0.99 ++
21 -0.048 -0.13 -0.097 -0.02 -0.56 0.23 -0.34 -0.03 -0.49 -0.63 -0.6 -0.001 0.18 5.4e+03 1.2 3.1 0.98 ++
22 -0.048 -0.13 -0.097 -0.02 -0.56 0.23 -0.34 -0.03 -0.49 -0.63 -0.6 -0.001 0.18 5.4e+03 1.2 1.5 -19 -
23 -0.048 -0.13 -0.097 -0.02 -0.56 0.23 -0.34 -0.03 -0.49 -0.63 -0.6 -0.001 0.18 5.4e+03 1.2 0.76 -2.6 -
24 0.027 -0.3 -0.14 -0.053 -0.75 0.87 0.12 -0.037 -1.3 -0.92 -0.82 0.00035 -0.14 5.2e+03 11 0.76 0.31 +
25 0.044 -0.32 -0.061 -0.081 -0.84 1.2 0.32 -0.026 -1.2 -1.7 -1.2 -0.00012 -0.029 5.1e+03 10 0.76 0.35 +
26 0.044 -0.32 -0.061 -0.081 -0.84 1.2 0.32 -0.026 -1.2 -1.7 -1.2 -0.00012 -0.029 5.1e+03 10 0.38 -4.1 -
27 0.044 -0.32 -0.061 -0.081 -0.84 1.2 0.32 -0.026 -1.2 -1.7 -1.2 -0.00012 -0.029 5.1e+03 10 0.19 -1.5 -
28 0.044 -0.32 -0.061 -0.081 -0.84 1.2 0.32 -0.026 -1.2 -1.7 -1.2 -0.00012 -0.029 5.1e+03 10 0.095 -0.45 -
29 0.049 -0.32 -0.058 -0.081 -0.83 1.2 0.32 -0.026 -1.2 -1.7 -1.2 0.00026 -0.12 5e+03 32 0.095 0.71 +
30 0.085 -0.33 -0.037 -0.09 -0.93 1.3 0.31 -0.022 -1.2 -1.7 -1.2 0.00022 -0.11 4.9e+03 5.2 0.95 0.96 ++
31 -0.054 -0.27 -0.015 -0.37 -1.4 1.8 0.62 0.29 -1.2 -1.7 -0.85 0.00021 -0.11 4.9e+03 1.4 9.5 1 ++
32 -0.055 -0.27 -0.0067 -0.45 -1.5 1.8 0.65 0.41 -1.2 -1.7 -0.87 0.00022 -0.11 4.9e+03 0.12 95 1 ++
33 -0.056 -0.27 -0.0065 -0.45 -1.5 1.8 0.65 0.41 -1.2 -1.7 -0.87 0.00022 -0.11 4.9e+03 0.00038 9.5e+02 1 ++
34 -0.055 -0.27 -0.0066 -0.45 -1.5 1.8 0.65 0.41 -1.2 -1.7 -0.87 0.00022 -0.11 4.9e+03 9e-06 9.5e+03 1 ++
35 -0.055 -0.27 -0.0066 -0.45 -1.5 1.8 0.65 0.41 -1.2 -1.7 -0.87 0.00022 -0.11 4.9e+03 3.1e-08 9.5e+03 1 ++
print(results.short_summary())
Results for model my_favorite_model
Nbr of parameters: 13
Sample size: 6768
Excluded data: 3960
Null log likelihood: -6964.663
Final log likelihood: -4893.276
Likelihood ratio test (null): 4142.773
Rho square (null): 0.297
Rho bar square (null): 0.296
Akaike Information Criterion: 9812.552
Bayesian Information Criterion: 9901.212
Get the results in a pandas table
pandas_results = results.getEstimatedParameters()
pandas_results
Total running time of the script: (0 minutes 1.803 seconds)