.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/hybrid_choice/plot_b05_mimic_bayes.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_hybrid_choice_plot_b05_mimic_bayes.py: 5. MIMIC model - Bayesian estimation ==================================== This script estimates a **pure MIMIC model** (latent-variable structural and measurement equations only) using **Bayesian estimation** in Biogeme, without an associated discrete choice model. It is primarily intended to: - assess identification and normalization under Bayesian inference, - inspect posterior distributions of latent-variable parameters, and - provide a Bayesian benchmark for comparison with the maximum likelihood MIMIC specification. The configuration is defined locally in this file and passed to the generic estimation pipeline via :func:`estimate_model`. Michel Bierlaire Thu Dec 25 2025, 08:27:04 .. GENERATED FROM PYTHON SOURCE LINES 22-40 .. rst-class:: sphx-glr-script-out .. code-block:: none Biogeme parameters read from biogeme.toml. Loaded NetCDF file size: 3.7 GB load finished in 19600 ms (19.60 s) Results are read from the file saved_results/b05_mimic_bayes.nc. posterior_predictive_loglike finished in 409 ms expected_log_likelihood finished in 38 ms best_draw_log_likelihood finished in 15 ms /Users/bierlair/python_envs/venv313/lib/python3.13/site-packages/arviz/stats/stats.py:1667: UserWarning: For one or more samples the posterior variance of the log predictive densities exceeds 0.4. This could be indication of WAIC starting to fail. See http://arxiv.org/abs/1507.04544 for details warnings.warn( waic_res finished in 917 ms waic finished in 917 ms /Users/bierlair/python_envs/venv313/lib/python3.13/site-packages/arviz/stats/stats.py:1057: RuntimeWarning: overflow encountered in exp weights = 1 / np.exp(len_scale - len_scale[:, None]).sum(axis=1) /Users/bierlair/python_envs/venv313/lib/python3.13/site-packages/numpy/_core/_methods.py:52: RuntimeWarning: overflow encountered in reduce return umr_sum(a, axis, dtype, out, keepdims, initial, where) /Users/bierlair/python_envs/venv313/lib/python3.13/site-packages/arviz/stats/stats.py:797: UserWarning: Estimated shape parameter of Pareto distribution is greater than 0.70 for one or more samples. You should consider using a more robust model, this is because importance sampling is less likely to work well if the marginal posterior and LOO posterior are very different. This is more likely to happen with a non-robust model and highly influential observations. warnings.warn( loo_res finished in 111674 ms (1.86 min) loo finished in 111674 ms (1.86 min) Sample size 896 Sampler NUTS Number of chains 4 Number of draws per chain 20000 Total number of draws 80000 Acceptance rate target 0.9 Run time 1:22:03.523915 Posterior predictive log-likelihood (sum of log mean p) -15711.05 Expected log-likelihood E[log L(Y|θ)] -16076.55 Best-draw log-likelihood (posterior upper bound) -15859.21 WAIC (Widely Applicable Information Criterion) -16719.13 WAIC Standard Error 133.66 Effective number of parameters (p_WAIC) 1008.08 LOO (Leave-One-Out Cross-Validation) -17075.85 LOO Standard Error 134.29 Effective number of parameters (p_LOO) 1364.79 Diagnostics computation took 413.1 seconds (cached). Name ... ESS (tail) 0 measurement_intercept_Mobil09 ... 25.676998 1 measurement_coefficient_car_centric_attitude_M... ... 68.310889 2 struct_car_centric_attitude_high_education ... 64.250043 3 struct_car_centric_attitude_top_manager ... 413.443208 4 struct_car_centric_attitude_employees ... 25.717927 5 struct_car_centric_attitude_age_30_less ... 60.226576 6 struct_car_centric_attitude_ScaledIncome ... 25.319067 7 struct_car_centric_attitude_car_oriented_parents ... 26.318717 8 measurement_intercept_Mobil10 ... 38.177817 9 measurement_coefficient_car_centric_attitude_M... ... 127.304390 10 measurement_intercept_Envir06 ... 6055.927755 11 measurement_coefficient_car_centric_attitude_E... ... 34812.325368 12 measurement_coefficient_environmental_attitude... ... 27.970389 13 struct_environmental_attitude_childSuburb ... 25.899591 14 struct_environmental_attitude_ScaledIncome ... 25.521342 15 struct_environmental_attitude_city_center_as_kid ... 26.723825 16 struct_environmental_attitude_artisans ... 37.236990 17 struct_environmental_attitude_high_education ... 25.021854 18 struct_environmental_attitude_low_education ... 27.069041 19 measurement_intercept_Envir03 ... 25.187457 20 measurement_coefficient_environmental_attitude... ... 27.100477 21 measurement_intercept_Envir05 ... 28.519236 22 measurement_coefficient_environmental_attitude... ... 26.992859 23 measurement_intercept_LifSty01 ... 384.332414 24 measurement_coefficient_environmental_attitude... ... 25.635101 25 measurement_intercept_Envir04 ... 26.890580 26 measurement_coefficient_environmental_attitude... ... 27.437842 27 measurement_intercept_Mobil05 ... 24.809665 28 measurement_coefficient_car_centric_attitude_M... ... 20833.296376 29 measurement_intercept_Mobil12 ... 26.343255 30 measurement_coefficient_environmental_attitude... ... 25.090585 31 measurement_intercept_Mobil03 ... 25.343171 32 measurement_coefficient_car_centric_attitude_M... ... 95.766135 33 measurement_intercept_NbCar ... 24.899076 34 measurement_coefficient_car_centric_attitude_N... ... 28.352519 35 measurement_intercept_Mobil08 ... 74.374083 36 measurement_coefficient_car_centric_attitude_M... ... 380.310761 37 measurement_intercept_LifSty07 ... 316.056785 38 measurement_coefficient_car_centric_attitude_L... ... 51.445363 39 measurement_coefficient_environmental_attitude... ... 27.079945 40 measurement_coefficient_car_centric_attitude_E... ... 25.840077 41 struct_car_centric_attitude_sigma ... 26.535305 42 measurement_Mobil09_sigma ... 26.612312 43 likert_delta_0 ... 26.672270 44 likert_delta_1 ... 27.549451 45 measurement_Mobil10_sigma ... 56.812297 46 struct_environmental_attitude_sigma ... 26.876701 47 measurement_Envir06_sigma ... 27.270297 48 measurement_Envir03_sigma ... 26.200351 49 measurement_Envir05_sigma ... 26.459742 50 measurement_LifSty01_sigma ... 26.301306 51 measurement_Envir04_sigma ... 26.522483 52 measurement_Mobil05_sigma ... 25.416288 53 measurement_Mobil12_sigma ... 24.639963 54 measurement_Mobil03_sigma ... 25.997392 55 cars_delta_1 ... 34.868446 56 cars_delta_2 ... 64.370845 57 measurement_Mobil08_sigma ... 25.170287 58 measurement_LifSty07_sigma ... 26.071971 59 measurement_Envir02_sigma ... 27.232333 [60 rows x 12 columns] | .. code-block:: Python import biogeme.biogeme_logging as blog from config import Config from estimate import estimate_model logger = blog.get_screen_logger(level=blog.INFO) the_config = Config( name='b05_mimic_bayes', latent_variables="two", choice_model="no", estimation="bayes", number_of_bayesian_draws_per_chain=20_000, number_of_monte_carlo_draws=20_000, ) estimate_model(config=the_config) .. rst-class:: sphx-glr-timing **Total running time of the script:** (9 minutes 15.259 seconds) .. _sphx_glr_download_auto_examples_hybrid_choice_plot_b05_mimic_bayes.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_b05_mimic_bayes.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_b05_mimic_bayes.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_b05_mimic_bayes.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_