.. 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_gamma_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_gamma_estimation.py: Gamma-profile MDCEV estimation ================================= Michel Bierlaire, EPFL Fri Jul 25 2025, 16:36:50 Estimation of a MDCEV model with the "gamma_profile" specification. .. GENERATED FROM PYTHON SOURCE LINES 8-28 .. 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 gamma_specification import the_gamma_profile from process_data import database, number_chosen from specification import consumed_quantities # % logger = blog.get_screen_logger(level=blog.INFO) logger.info('Example: gamma profile') # % results = the_gamma_profile.estimate_parameters( database=database, number_of_chosen_alternatives=number_chosen, consumed_quantities=consumed_quantities, ) .. rst-class:: sphx-glr-script-out .. code-block:: none Example: gamma profile Default values of the Biogeme parameters are used. File biogeme.toml has been created *** Initial values of the parameters are obtained from the file __gamma_profile.iter Cannot read file __gamma_profile.iter. Statement is ignored. Starting values for the algorithm: {} Analytical Hessian method: full 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 2e+04 0.19 0.5 -1.7 - 1 2e+04 0.19 0.25 0.017 - 2 1.9e+04 0.24 0.25 0.59 + 3 1.9e+04 0.19 0.25 0.63 + 4 1.8e+04 0.041 2.5 1 ++ 5 1.8e+04 0.041 1.2 -0.78 - 6 1.8e+04 0.07 1.2 0.83 + 7 1.7e+04 0.021 1.2 0.45 + 8 1.7e+04 0.016 12 0.98 ++ 9 1.7e+04 0.019 1.2e+02 1.2 ++ 10 1.7e+04 0.0098 1.2e+03 1.2 ++ 11 1.7e+04 0.0077 1.2e+04 1.2 ++ 12 1.7e+04 0.0018 1.2e+05 1.1 ++ 13 1.7e+04 0.00061 1.2e+06 0.99 ++ 14 1.7e+04 0.0054 1.2e+07 1 ++ 15 1.7e+04 0.0002 1.2e+08 1 ++ 16 1.7e+04 0.0002 1.2e+09 1 ++ 17 1.7e+04 0.00014 1e+10 1 ++ 18 1.7e+04 9.5e-05 1e+10 1 ++ 19 1.7e+04 0.00012 1e+10 1 ++ 20 1.7e+04 7.8e-05 1e+10 1 ++ 21 1.7e+04 9.9e-05 1e+10 1 ++ 22 1.7e+04 6.5e-05 1e+10 1 ++ 23 1.7e+04 8.3e-05 1e+10 1 ++ 24 1.7e+04 5.6e-05 1e+10 1 ++ 25 1.7e+04 7e-05 1e+10 1 ++ 26 1.7e+04 9.7e-05 1e+10 1 ++ 27 1.7e+04 5e-05 1e+10 1 ++ 28 1.7e+04 3.4e-05 1e+10 1 ++ 29 1.7e+04 4.3e-05 1e+10 1 ++ 30 1.7e+04 2.8e-05 1e+10 1 ++ 31 1.7e+04 3.6e-05 1e+10 1 ++ 32 1.7e+04 2.4e-05 1e+10 1 ++ 33 1.7e+04 3.1e-05 1e+10 1 ++ 34 1.7e+04 2e-05 1e+10 1 ++ 35 1.7e+04 2.6e-05 1e+10 1 ++ 36 1.7e+04 1.7e-05 1e+10 1 ++ 37 1.7e+04 2.2e-05 1e+10 1 ++ 38 1.7e+04 1.4e-05 1e+10 1 ++ 39 1.7e+04 1.8e-05 1e+10 1 ++ 40 1.7e+04 1.5e-05 1e+10 1 ++ 41 1.7e+04 1.5e-05 1e+10 1 ++ 42 1.7e+04 2.1e-05 1e+10 1 ++ 43 1.7e+04 2.6e-06 1e+10 1 ++ Optimization algorithm has converged. Relative gradient: 2.6067938427699187e-06 Cause of termination: Relative gradient = 2.6e-06 <= 6.1e-06 Number of function evaluations: 127 Number of gradient evaluations: 83 Number of hessian evaluations: 41 Algorithm: Newton with trust region for simple bound constraints Number of iterations: 44 Proportion of Hessian calculation: 41/41 = 100.0% Optimization time: 0:00:01.808035 Optimization is complete. Save recoverable results in gamma_profile.yaml. File gamma_profile.yaml has been generated. Calculate final gradient and BHHH File gamma_profile.yaml has been generated. Calculate second derivatives File gamma_profile.yaml has been generated. File gamma_profile.html has been generated. File gamma_profile.yaml has been generated. .. GENERATED FROM PYTHON SOURCE LINES 29-31 .. code-block:: Python print(results.short_summary()) .. rst-class:: sphx-glr-script-out .. code-block:: none Results for model gamma_profile Nbr of parameters: 26 Sample size: 4413 Excluded data: 0 Final log likelihood: -16989.22 Akaike Information Criterion: 34030.45 Bayesian Information Criterion: 34196.65 .. GENERATED FROM PYTHON SOURCE LINES 32-33 Get the results in a pandas table .. GENERATED FROM PYTHON SOURCE LINES 33-37 .. 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 t-stat. Robust p-value 0 scale 3.831701 ... 17.001567 0.000000e+00 1 cte_shopping -0.736120 ... -13.540967 0.000000e+00 2 metropolitan_shopping 0.061970 ... 2.763011 5.727077e-03 3 male_shopping 0.097856 ... 5.470505 4.487549e-08 4 age_15_40_shopping 0.075506 ... 3.822044 1.323502e-04 5 spouse_shopping 0.062738 ... 3.784831 1.538130e-04 6 employed_shopping 0.046167 ... 2.721993 6.488959e-03 7 gamma_shopping 3.494804 ... 12.106872 0.000000e+00 8 cte_socializing -0.508421 ... -13.547466 0.000000e+00 9 number_members_socializing 0.016610 ... 4.053622 5.043075e-05 10 male_socializing 0.126931 ... 8.501148 0.000000e+00 11 age_41_60_socializing -0.064554 ... -3.481732 4.981824e-04 12 bachelor_socializing -0.050948 ... -3.692299 2.222361e-04 13 sunday_socializing 0.096276 ... 6.726759 1.734834e-11 14 gamma_socializing 11.100915 ... 10.831089 0.000000e+00 15 cte_recreation -0.836408 ... -14.790841 0.000000e+00 16 number_members_recreation 0.019838 ... 3.591793 3.284101e-04 17 male_recreation 0.218898 ... 10.816356 0.000000e+00 18 age_15_40_recreation 0.120917 ... 5.810086 6.244075e-09 19 spouse_recreation -0.065594 ... -3.998945 6.362543e-05 20 gamma_recreation 15.400449 ... 11.788563 0.000000e+00 21 age_41_60_personal -0.055052 ... -2.816150 4.860303e-03 22 bachelor_personal -0.045503 ... -2.977899 2.902319e-03 23 white_personal -0.088397 ... -5.488807 4.046566e-08 24 sunday_personal 0.090621 ... 6.019759 1.746771e-09 25 gamma_personal 1.562740 ... 12.208060 0.000000e+00 [26 rows x 5 columns]} .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.933 seconds) .. _sphx_glr_download_auto_examples_mdcev_no_outside_good_plot_gamma_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_gamma_estimation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_gamma_estimation.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_gamma_estimation.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_