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'
Biogeme parameters read from biogeme.toml.

Calculate of the null log-likelihood for reporting.

the_biogeme.calculate_null_loglikelihood(av)
np.float64(-11093.62734528626)

Estimate the parameters.

results = the_biogeme.estimate()
As the model is not too complex, we activate the calculation of second derivatives. If you want to change it, 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 __my_favorite_model.iter
Cannot read file __my_favorite_model.iter. Statement is ignored.
As the model is not too complex, we activate the calculation of second derivatives. If you want to change it, 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: 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.28            -1.3          -0.078           -0.48              -1             1.2            0.36            0.33            -0.7            -1.6           -0.62          0.0002            -0.1      8.2e+03          5       10        1   ++
    1            0.19            -1.2          -0.083           -0.54            -1.3             1.4             0.5            0.49           -0.77            -1.7           -0.66         0.00018            -0.1      8.1e+03        3.9    1e+02        1   ++
    2            0.19            -1.2          -0.082           -0.55            -1.3             1.4            0.52            0.53           -0.77            -1.7           -0.66         0.00019            -0.1      8.1e+03       0.34    1e+03        1   ++
    3            0.19            -1.2          -0.084           -0.55            -1.3             1.4            0.52            0.54           -0.77            -1.7           -0.67         0.00019            -0.1      8.1e+03     0.0027    1e+04        1   ++
    4            0.19            -1.2          -0.084           -0.55            -1.3             1.4            0.52            0.54           -0.77            -1.7           -0.67         0.00019            -0.1      8.1e+03    1.9e-05    1e+04        1   ++
Results saved in file my_favorite_model.html
Results saved in file my_favorite_model.pickle
print(results.short_summary())
Results for model my_favorite_model
Nbr of parameters:              13
Sample size:                    10719
Excluded data:                  9
Null log likelihood:            -11093.63
Final log likelihood:           -8148.851
Likelihood ratio test (null):           5889.553
Rho square (null):                      0.265
Rho bar square (null):                  0.264
Akaike Information Criterion:   16323.7
Bayesian Information Criterion: 16418.34

Get the results in a pandas table

pandas_results = results.get_estimated_parameters()
pandas_results
Value Rob. Std err Rob. t-test Rob. p-value
ASC_CAR 0.193082 0.044191 4.369289 1.246515e-05
ASC_CAR_GA -1.194867 0.157777 -7.573127 3.641532e-14
ASC_CAR_one_lugg -0.083509 0.051120 -1.633580 1.023471e-01
ASC_CAR_several_lugg -0.555367 0.217748 -2.550499 1.075688e-02
ASC_TRAIN -1.305348 0.077246 -16.898581 0.000000e+00
ASC_TRAIN_GA 1.389663 0.071916 19.323435 0.000000e+00
ASC_TRAIN_one_lugg 0.516139 0.080204 6.435337 1.231992e-10
ASC_TRAIN_several_lugg 0.538559 0.170977 3.149883 1.633356e-03
B_COST -0.773716 0.057310 -13.500567 0.000000e+00
B_TIME -1.693603 0.090434 -18.727546 0.000000e+00
B_TIME_1st_class -0.666023 0.087842 -7.582040 3.397282e-14
cube_tt_coef 0.000193 0.000031 6.270364 3.602061e-10
square_tt_coef -0.103596 0.005046 -20.531451 0.000000e+00


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

Gallery generated by Sphinx-Gallery