.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/mdcev_no_outside_good/plot_generalized_estimation.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_mdcev_no_outside_good_plot_generalized_estimation.py: File generalized_estimation.py Michel Bierlaire, EPFL Fri Jul 25 2025, 16:51:40 Estimation of a MDCEV model with the "generalized translated utility" specification. .. GENERATED FROM PYTHON SOURCE LINES 8-29 .. code-block:: Python from IPython.core.display_functions import display import biogeme.biogeme_logging as blog from biogeme.results_processing import get_pandas_estimated_parameters from generalized_specification import the_generalized from process_data import database, number_chosen from specification import consumed_quantities # % logger = blog.get_screen_logger(level=blog.INFO) logger.info('Example: generalized translated utility') # % results = the_generalized.estimate_parameters( database=database, number_of_chosen_alternatives=number_chosen, consumed_quantities=consumed_quantities, tolerance=4e-5, ) .. rst-class:: sphx-glr-script-out .. code-block:: none Example: generalized translated utility Biogeme parameters read from biogeme.toml. *** Initial values of the parameters are obtained from the file __generalized.iter Cannot read file __generalized.iter. Statement is ignored. Starting values for the algorithm: {} As the model is not too complex, we activate the calculation of second derivatives. To change this behavior, modify the algorithm to "simple_bounds" in the TOML file. Optimization algorithm: hybrid Newton/BFGS with simple bounds [simple_bounds] ** Optimization: Newton with trust region for simple bounds Iter. Function Relgrad Radius Rho 0 1.8e+04 0.37 10 0.91 ++ 1 1.8e+04 0.37 0.4 -2.1 - 2 1.8e+04 0.27 0.4 0.32 + 3 1.8e+04 0.42 0.4 0.14 + 4 1.7e+04 0.068 4 0.94 ++ 5 1.7e+04 0.068 1.1 -12 - 6 1.7e+04 0.068 0.53 -1.4 - 7 1.7e+04 0.058 0.53 0.22 + 8 1.7e+04 0.013 5.3 1.1 ++ 9 1.7e+04 0.013 0.48 0.04 - 10 1.7e+04 0.022 4.8 0.9 ++ 11 1.7e+04 0.0076 48 0.99 ++ 12 1.7e+04 0.02 4.8e+02 1.2 ++ 13 1.7e+04 0.0016 4.8e+03 1 ++ 14 1.7e+04 0.01 4.8e+04 1.2 ++ 15 1.7e+04 0.00087 4.8e+05 1 ++ 16 1.7e+04 0.0013 4.8e+06 1.3 ++ 17 1.7e+04 0.00062 4.8e+07 1 ++ 18 1.7e+04 0.0078 4.8e+08 1.2 ++ 19 1.7e+04 0.00058 4.8e+09 1.1 ++ 20 1.7e+04 0.0025 4.8e+09 0.87 + 21 1.7e+04 0.00089 1e+10 1 ++ 22 1.7e+04 0.0017 1e+10 1.1 ++ 23 1.7e+04 0.00062 1e+10 1 ++ 24 1.7e+04 0.0019 1e+10 1 ++ 25 1.7e+04 0.00029 1e+10 0.94 ++ 26 1.7e+04 0.0003 1e+10 1.1 ++ 27 1.7e+04 0.00027 1e+10 0.9 + 28 1.7e+04 0.00025 1e+10 1.1 ++ 29 1.7e+04 0.00025 1e+10 0.89 + 30 1.7e+04 0.00024 1e+10 1.1 ++ 31 1.7e+04 0.0015 1e+10 1.3 ++ 32 1.7e+04 0.00015 1e+10 0.99 ++ 33 1.7e+04 0.00033 1e+10 1 ++ 34 1.7e+04 0.00013 1e+10 1 ++ 35 1.7e+04 0.00014 1e+10 1 ++ 36 1.7e+04 0.00014 1e+10 0.96 ++ 37 1.7e+04 0.00014 1e+10 1 ++ 38 1.7e+04 0.00014 1e+10 0.97 ++ 39 1.7e+04 0.00014 1e+10 1 ++ 40 1.7e+04 0.00014 1e+10 0.97 ++ 41 1.7e+04 0.00013 1e+10 1 ++ 42 1.7e+04 0.00014 1e+10 0.97 ++ 43 1.7e+04 0.00013 1e+10 1 ++ 44 1.7e+04 0.00015 1e+10 0.97 ++ 45 1.7e+04 0.00013 1e+10 1 ++ 46 1.7e+04 0.00012 1e+10 1 ++ 47 1.7e+04 0.00012 1.1 -3 - 48 1.7e+04 0.0014 1.1 0.44 + 49 1.7e+04 0.00013 11 1 ++ 50 1.7e+04 0.00011 1.1e+02 1 ++ 51 1.7e+04 0.00011 1.3 -3 - 52 1.7e+04 0.0014 1.3 0.6 + 53 1.7e+04 0.00012 13 1 ++ 54 1.7e+04 0.0001 1.3e+02 1 ++ 55 1.7e+04 8.1e-05 1.3e+03 0.98 ++ 56 1.7e+04 9.9e-05 1.3e+04 1 ++ 57 1.7e+04 8.8e-05 1.3e+05 0.98 ++ 58 1.7e+04 9.5e-05 1.3e+06 1 ++ 59 1.7e+04 0.00011 1.3e+07 0.97 ++ 60 1.7e+04 9.6e-05 1.3e+08 1 ++ 61 1.7e+04 0.00021 1.3e+09 0.97 ++ 62 1.7e+04 0.0001 1e+10 1 ++ 63 1.7e+04 9.8e-05 1e+10 1 ++ 64 1.7e+04 9e-05 1e+10 1 ++ 65 1.7e+04 9e-05 3.2 -60 - 66 1.7e+04 9e-05 1.6 -5.8 - 67 1.7e+04 0.002 1.6 0.38 + 68 1.7e+04 0.0001 16 1 ++ 69 1.7e+04 8.2e-05 1.6e+02 1 ++ 70 1.7e+04 0.00012 1.6e+03 1 ++ 71 1.7e+04 8.1e-05 1.6e+04 1 ++ 72 1.7e+04 8e-05 1.6e+05 1 ++ 73 1.7e+04 5.1e-05 1.6e+06 0.99 ++ 74 1.7e+04 9.1e-05 1.6e+07 1 ++ 75 1.7e+04 8.1e-05 1.6e+08 1 ++ 76 1.7e+04 7.8e-05 1.6e+09 1 ++ 77 1.7e+04 0.00017 1e+10 1 ++ 78 1.7e+04 7.4e-05 1e+10 1 ++ 79 1.7e+04 4.6e-05 1e+10 0.99 ++ 80 1.7e+04 8.4e-05 1e+10 1 ++ 81 1.7e+04 7.6e-05 1e+10 1 ++ 82 1.7e+04 7.4e-05 1e+10 1 ++ 83 1.7e+04 0.00022 1e+10 1 ++ 84 1.7e+04 7.3e-05 1e+10 1 ++ 85 1.7e+04 7.1e-05 1e+10 1 ++ 86 1.7e+04 5.1e-05 1e+10 0.99 ++ 87 1.7e+04 8.1e-05 1e+10 1 ++ 88 1.7e+04 0.00011 1e+10 1 ++ 89 1.7e+04 8.8e-05 1e+10 1 ++ 90 1.7e+04 7e-05 1e+10 1 ++ 91 1.7e+04 4.1e-05 1e+10 1 ++ 92 1.7e+04 7.2e-05 1e+10 1 ++ 93 1.7e+04 7e-05 1e+10 1 ++ 94 1.7e+04 6.8e-05 1e+10 1 ++ 95 1.7e+04 0.00024 1e+10 1 ++ 96 1.7e+04 6.2e-05 1e+10 1 ++ 97 1.7e+04 4.6e-05 1e+10 1 ++ 98 1.7e+04 6.6e-05 1e+10 1 ++ 99 1.7e+04 6.4e-05 1e+10 1 ++ 100 1.7e+04 3.6e-05 1e+10 0.99 ++ Optimization algorithm has converged. Relative gradient: 3.552063021006307e-05 Cause of termination: Relative gradient = 3.6e-05 <= 4e-05 Number of function evaluations: 288 Number of gradient evaluations: 187 Number of hessian evaluations: 93 Algorithm: Newton with trust region for simple bound constraints Number of iterations: 101 Proportion of Hessian calculation: 93/93 = 100.0% Optimization time: 0:00:03.605825 Calculate second derivatives and BHHH File generalized.html has been generated. File generalized.yaml has been generated. .. GENERATED FROM PYTHON SOURCE LINES 30-32 .. code-block:: Python print(results.short_summary()) .. rst-class:: sphx-glr-script-out .. code-block:: none Results for model generalized Nbr of parameters: 30 Sample size: 4413 Excluded data: 0 Final log likelihood: -16963.25 Akaike Information Criterion: 33986.51 Bayesian Information Criterion: 34178.28 .. GENERATED FROM PYTHON SOURCE LINES 33-34 Get the results in a pandas table .. GENERATED FROM PYTHON SOURCE LINES 34-38 .. code-block:: Python pandas_results = get_pandas_estimated_parameters( estimation_results=results, ) display(pandas_results) .. rst-class:: sphx-glr-script-out .. code-block:: none {'Estimated parameters': Name Value ... Robust p-value Active bound 0 scale 6.303650 ... 2.617906e-13 False 1 cte_shopping -0.444308 ... 6.705303e-12 False 2 metropolitan_shopping 0.037571 ... 9.819136e-03 False 3 male_shopping 0.060013 ... 7.391579e-06 False 4 age_15_40_shopping 0.045919 ... 6.036156e-04 False 5 spouse_shopping 0.037958 ... 8.366987e-04 False 6 employed_shopping 0.028262 ... 9.638150e-03 False 7 alpha_shopping 0.598947 ... 2.220446e-16 False 8 gamma_shopping 2.070326 ... 1.294476e-09 False 9 cte_socializing -0.302124 ... 6.328937e-12 False 10 number_members_socializing 0.010207 ... 4.047780e-04 False 11 male_socializing 0.077207 ... 8.156199e-09 False 12 age_41_60_socializing -0.039601 ... 1.239482e-03 False 13 bachelor_socializing -0.029909 ... 8.734051e-04 False 14 sunday_socializing 0.059543 ... 1.323992e-07 False 15 alpha_socializing 0.780531 ... 0.000000e+00 False 16 gamma_socializing 2.868730 ... 6.641354e-13 False 17 cte_recreation -0.506586 ... 2.020828e-12 False 18 number_members_recreation 0.012189 ... 1.235823e-03 False 19 male_recreation 0.134111 ... 1.989271e-10 False 20 age_15_40_recreation 0.073541 ... 1.292171e-06 False 21 spouse_recreation -0.040493 ... 2.126226e-04 False 22 alpha_recreation 0.000100 ... 9.994634e-01 True 23 gamma_recreation 25.970931 ... 7.656160e-04 False 24 age_41_60_personal -0.033524 ... 7.536776e-03 False 25 bachelor_personal -0.027666 ... 4.837983e-03 False 26 white_personal -0.054425 ... 7.059435e-06 False 27 sunday_personal 0.055520 ... 1.128913e-06 False 28 alpha_personal 0.308225 ... 3.634916e-03 False 29 gamma_personal 1.863421 ... 0.000000e+00 False [30 rows x 6 columns]} .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 6.301 seconds) .. _sphx_glr_download_auto_examples_mdcev_no_outside_good_plot_generalized_estimation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_generalized_estimation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_generalized_estimation.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_generalized_estimation.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_