.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/swissmetro/plot_b15a_panel_discrete.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_swissmetro_plot_b15a_panel_discrete.py: .. _plot_b15a_panel_discrete: 15a. Discrete mixture with panel data ===================================== Example of a discrete mixture of logit models, also called latent class model. The datafile is organized as panel data. Michel Bierlaire, EPFL Sat Jun 21 2025, 17:16:14 .. GENERATED FROM PYTHON SOURCE LINES 14-32 .. code-block:: Python import biogeme.biogeme_logging as blog from IPython.core.display_functions import display from biogeme.biogeme import BIOGEME from biogeme.expressions import ( Beta, Draws, ExpressionOrNumeric, MonteCarlo, PanelLikelihoodTrajectory, log, ) from biogeme.models import logit from biogeme.results_processing import ( EstimationResults, get_pandas_estimated_parameters, ) .. GENERATED FROM PYTHON SOURCE LINES 33-34 See the data processing script: :ref:`swissmetro_panel`. .. GENERATED FROM PYTHON SOURCE LINES 34-51 .. code-block:: Python from swissmetro_panel import ( CAR_AV_SP, CAR_CO_SCALED, CAR_TT_SCALED, CHOICE, SM_AV, SM_COST_SCALED, SM_TT_SCALED, TRAIN_AV_SP, TRAIN_COST_SCALED, TRAIN_TT_SCALED, database, ) logger = blog.get_screen_logger(level=blog.INFO) logger.info('Example b15panel_discrete.py') .. rst-class:: sphx-glr-script-out .. code-block:: none Example b15panel_discrete.py .. GENERATED FROM PYTHON SOURCE LINES 52-53 Parameters to be estimated. One version for each latent class. .. GENERATED FROM PYTHON SOURCE LINES 53-56 .. code-block:: Python NUMBER_OF_CLASSES = 2 b_cost = [Beta(f'b_cost_class{i}', 0, None, None, 0) for i in range(NUMBER_OF_CLASSES)] .. GENERATED FROM PYTHON SOURCE LINES 57-59 Define a random parameter, normally distributed across individuals, designed to be used for Monte-Carlo simulation .. GENERATED FROM PYTHON SOURCE LINES 59-61 .. code-block:: Python b_time = [Beta(f'b_time_class{i}', 0, None, None, 0) for i in range(NUMBER_OF_CLASSES)] .. GENERATED FROM PYTHON SOURCE LINES 62-63 It is advised not to use 0 as starting value for the following parameter. .. GENERATED FROM PYTHON SOURCE LINES 63-71 .. code-block:: Python b_time_s = [ Beta(f'b_time_s_class{i}', 1, None, None, 0) for i in range(NUMBER_OF_CLASSES) ] b_time_rnd: list[ExpressionOrNumeric] = [ b_time[i] + b_time_s[i] * Draws(f'b_time_rnd_class{i}', 'NORMAL_ANTI') for i in range(NUMBER_OF_CLASSES) ] .. GENERATED FROM PYTHON SOURCE LINES 72-73 We do the same for the constants, to address serial correlation. .. GENERATED FROM PYTHON SOURCE LINES 73-104 .. code-block:: Python asc_car = [ Beta(f'asc_car_class{i}', 0, None, None, 0) for i in range(NUMBER_OF_CLASSES) ] asc_car_s = [ Beta(f'asc_car_s_class{i}', 1, None, None, 0) for i in range(NUMBER_OF_CLASSES) ] asc_car_rnd = [ asc_car[i] + asc_car_s[i] * Draws(f'asc_car_rnd_class{i}', 'NORMAL_ANTI') for i in range(NUMBER_OF_CLASSES) ] asc_train = [ Beta(f'asc_train_class{i}', 0, None, None, 0) for i in range(NUMBER_OF_CLASSES) ] asc_train_s = [ Beta(f'asc_train_s_class{i}', 1, None, None, 0) for i in range(NUMBER_OF_CLASSES) ] asc_train_rnd = [ asc_train[i] + asc_train_s[i] * Draws(f'asc_train_rnd_class{i}', 'NORMAL_ANTI') for i in range(NUMBER_OF_CLASSES) ] asc_sm = [Beta(f'asc_sm_class{i}', 0, None, None, 1) for i in range(NUMBER_OF_CLASSES)] asc_sm_s = [ Beta(f'asc_sm_s_class{i}', 1, None, None, 0) for i in range(NUMBER_OF_CLASSES) ] asc_sm_rnd = [ asc_sm[i] + asc_sm_s[i] * Draws(f'asc_sm_rnd_class{i}', 'NORMAL_ANTI') for i in range(NUMBER_OF_CLASSES) ] .. GENERATED FROM PYTHON SOURCE LINES 105-106 Class membership probability. .. GENERATED FROM PYTHON SOURCE LINES 106-110 .. code-block:: Python score_class_0 = Beta('score_class_0', -1.7, None, None, 0) probability_class_0 = logit({0: score_class_0, 1: 0}, None, 0) probability_class_1 = logit({0: score_class_0, 1: 0}, None, 1) .. GENERATED FROM PYTHON SOURCE LINES 111-112 In class 0, it is assumed that the time coefficient is zero. .. GENERATED FROM PYTHON SOURCE LINES 112-114 .. code-block:: Python b_time_rnd[0] = 0 .. GENERATED FROM PYTHON SOURCE LINES 115-116 Utility functions. .. GENERATED FROM PYTHON SOURCE LINES 116-133 .. code-block:: Python v_train_per_class = [ asc_train_rnd[i] + b_time_rnd[i] * TRAIN_TT_SCALED + b_cost[i] * TRAIN_COST_SCALED for i in range(NUMBER_OF_CLASSES) ] v_swissmetro_per_class = [ asc_sm_rnd[i] + b_time_rnd[i] * SM_TT_SCALED + b_cost[i] * SM_COST_SCALED for i in range(NUMBER_OF_CLASSES) ] v_car_per_class = [ asc_car_rnd[i] + b_time_rnd[i] * CAR_TT_SCALED + b_cost[i] * CAR_CO_SCALED for i in range(NUMBER_OF_CLASSES) ] v_per_class = [ {1: v_train_per_class[i], 2: v_swissmetro_per_class[i], 3: v_car_per_class[i]} for i in range(NUMBER_OF_CLASSES) ] .. GENERATED FROM PYTHON SOURCE LINES 134-135 Associate the availability conditions with the alternatives. .. GENERATED FROM PYTHON SOURCE LINES 135-137 .. code-block:: Python av = {1: TRAIN_AV_SP, 2: SM_AV, 3: CAR_AV_SP} .. GENERATED FROM PYTHON SOURCE LINES 138-140 The choice model is a discrete mixture of logit, with availability conditions We calculate the conditional probability for each class. .. GENERATED FROM PYTHON SOURCE LINES 140-145 .. code-block:: Python choice_probability_per_class = [ PanelLikelihoodTrajectory(logit(v_per_class[i], av, CHOICE)) for i in range(NUMBER_OF_CLASSES) ] .. GENERATED FROM PYTHON SOURCE LINES 146-147 Conditional to the random variables, likelihood for the individual. .. GENERATED FROM PYTHON SOURCE LINES 147-152 .. code-block:: Python choice_probability = ( probability_class_0 * choice_probability_per_class[0] + probability_class_1 * choice_probability_per_class[1] ) .. GENERATED FROM PYTHON SOURCE LINES 153-154 We integrate over the random variables using Monte-Carlo. .. GENERATED FROM PYTHON SOURCE LINES 154-156 .. code-block:: Python log_probability = log(MonteCarlo(choice_probability)) .. GENERATED FROM PYTHON SOURCE LINES 157-160 The model is complex, and there are numerical issues when calculating the second derivatives. Therefore, we instruct Biogeme not to evaluate the second derivatives. As a consequence, the statistics reported after estimation are based on the BHHH matrix instead of the Rao-Cramer bound. .. GENERATED FROM PYTHON SOURCE LINES 160-169 .. code-block:: Python the_biogeme = BIOGEME( database, log_probability, number_of_draws=5_000, calculating_second_derivatives='never', seed=1223, ) the_biogeme.model_name = 'b15a_panel_discrete' .. rst-class:: sphx-glr-script-out .. code-block:: none Biogeme parameters read from biogeme.toml. .. GENERATED FROM PYTHON SOURCE LINES 170-171 Estimate the parameters. .. GENERATED FROM PYTHON SOURCE LINES 171-178 .. code-block:: Python try: results = EstimationResults.from_yaml_file( filename=f'saved_results/{the_biogeme.model_name}.yaml' ) except FileNotFoundError: results = the_biogeme.estimate() .. rst-class:: sphx-glr-script-out .. code-block:: none Flattening database [(6768, 38)]. Database flattened [(752, 362)] *** Initial values of the parameters are obtained from the file __b15a_panel_discrete.iter Cannot read file __b15a_panel_discrete.iter. Statement is ignored. Starting values for the algorithm: {} As the model is rather complex, we cancel the calculation of second derivatives. If you want to control the parameters, change the algorithm from "automatic" to "simple_bounds" in the TOML file. Optimization algorithm: hybrid Newton/BFGS with simple bounds [simple_bounds] ** Optimization: BFGS with trust region for simple bounds Iter. score_class_0 asc_train_class asc_train_s_cla b_cost_class0 asc_sm_s_class0 asc_car_class0 asc_car_s_class asc_train_class asc_train_s_cla b_time_class1 b_time_s_class1 b_cost_class1 asc_sm_s_class1 asc_car_class1 asc_car_s_class Function Relgrad Radius Rho 0 -2.7 -1 2 -1 2 1 2 -1 2 -1 2 -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 3.1 3.5e+03 0.0036 1.1 -7 - 13 -2.3 -0.3 2.7 -0.57 3.2 -0.85 3.7 -0.74 2.2 -6.1 3.1 -4.3 0.82 0.55 3.1 3.5e+03 0.0036 0.53 -1.5 - 14 -2.3 -0.3 2.7 -0.57 3.2 -0.85 3.7 -0.74 2.2 -6.1 3.1 -4.3 0.82 0.55 3.1 3.5e+03 0.0036 0.27 -0.018 - 15 -2.1 -0.26 2.7 -0.65 3.1 -0.94 3.7 -0.47 2.3 -6.2 3.1 -4.5 0.87 0.58 3.1 3.5e+03 0.008 0.27 0.56 + 16 -2.1 -0.27 2.6 -0.77 3.1 -1.1 3.8 -0.5 2.1 -6.5 3.1 -4.6 0.93 0.68 3.1 3.5e+03 0.0024 2.7 1 ++ 17 -2.1 -0.27 2.6 -0.77 3.1 -1.1 3.8 -0.5 2.1 -6.5 3.1 -4.6 0.93 0.68 3.1 3.5e+03 0.0024 1.2 -16 - 18 -2.1 -0.27 2.6 -0.77 3.1 -1.1 3.8 -0.5 2.1 -6.5 3.1 -4.6 0.93 0.68 3.1 3.5e+03 0.0024 0.6 -2.5 - 19 -2.1 -0.27 2.6 -0.77 3.1 -1.1 3.8 -0.5 2.1 -6.5 3.1 -4.6 0.93 0.68 3.1 3.5e+03 0.0024 0.3 -0.21 - 20 -1.8 -0.28 2.5 -0.95 3 -1.3 3.9 -0.33 2.1 -6.8 3.1 -4.6 1.1 0.64 3.1 3.5e+03 0.0024 0.3 0.26 + 21 -1.8 -0.36 2.4 -1.1 2.8 -1.6 4 -0.31 1.9 -6.6 3.2 -4.8 1.2 0.95 3.1 3.5e+03 0.0096 0.3 0.33 + 22 -1.8 -0.36 2.4 -1.1 2.8 -1.6 4 -0.31 1.9 -6.6 3.2 -4.8 1.2 0.95 3.1 3.5e+03 0.0096 0.15 -0.6 - 23 -2 -0.51 2.3 -0.94 2.7 -1.7 4.2 -0.46 1.8 -6.8 3.1 -4.7 1.4 0.79 2.9 3.5e+03 0.0075 0.15 0.13 + 24 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.046 -4.9 6.1 -0.33 1.8 -6.9 3.3 -4.8 1.7 1 2.9 3.5e+03 0.00017 42 0.27 + 72 -1.8 -1 3.1 -1.2 0.046 -4.9 6.1 -0.33 1.8 -6.9 3.3 -4.8 1.7 1 2.9 3.5e+03 0.00017 0.083 -1.4 - 73 -1.8 -1 3.1 -1.2 0.046 -4.9 6.1 -0.33 1.8 -6.9 3.3 -4.8 1.7 1 2.9 3.5e+03 0.00017 0.042 0.011 - 74 -1.8 -1.1 3.1 -1.2 0.033 -4.9 6.1 -0.32 1.8 -7 3.3 -4.8 1.7 1 2.9 3.5e+03 4.7e-05 0.042 0.82 + 75 -1.8 -1 3.1 -1.2 0.042 -4.9 6.1 -0.32 1.8 -7 3.3 -4.8 1.7 1 2.9 3.5e+03 1.7e-05 0.042 0.72 + 76 -1.8 -1 3.1 -1.2 0.042 -4.9 6.1 -0.32 1.8 -7 3.3 -4.8 1.7 1 2.9 3.5e+03 5.1e-06 0.042 0.46 + Optimization algorithm has converged. Relative gradient: 5.130375656584178e-06 Cause of termination: Relative gradient = 5.1e-06 <= 6.1e-06 Number of function evaluations: 180 Number of gradient evaluations: 103 Number of hessian evaluations: 0 Algorithm: BFGS with trust region for simple bound constraints Number of iterations: 77 Proportion of Hessian calculation: 0/51 = 0.0% Optimization time: 0:02:24.118658 Calculate BHHH File b15a_panel_discrete.html has been generated. File b15a_panel_discrete.yaml has been generated. .. GENERATED FROM PYTHON SOURCE LINES 179-181 .. code-block:: Python print(results.short_summary()) .. rst-class:: sphx-glr-script-out .. code-block:: none Results for model b15a_panel_discrete Nbr of parameters: 15 Sample size: 752 Observations: 6768 Excluded data: 0 Final log likelihood: -3524.886 Akaike Information Criterion: 7079.772 Bayesian Information Criterion: 7149.113 .. GENERATED FROM PYTHON SOURCE LINES 182-184 .. code-block:: Python pandas_results = get_pandas_estimated_parameters(estimation_results=results) display(pandas_results) .. rst-class:: sphx-glr-script-out .. code-block:: none Name Value BHHH std err. BHHH t-stat. BHHH p-value 0 score_class_0 -1.759444 0.226120 -7.781031 7.105427e-15 1 asc_train_class0 -1.049639 0.682672 -1.537545 1.241599e-01 2 asc_train_s_class0 3.111880 0.640508 4.858454 1.183061e-06 3 b_cost_class0 -1.172640 0.535508 -2.189773 2.854071e-02 4 asc_sm_s_class0 0.029721 6.383987 0.004656 9.962854e-01 5 asc_car_class0 -4.864336 1.630491 -2.983356 2.851058e-03 6 asc_car_s_class0 6.075086 1.857124 3.271233 1.070798e-03 7 asc_train_class1 -0.320075 0.284611 -1.124607 2.607558e-01 8 asc_train_s_class1 1.756651 0.457972 3.835721 1.251964e-04 9 b_time_class1 -6.956658 0.367302 -18.939904 0.000000e+00 10 b_time_s_class1 3.281167 0.353407 9.284384 0.000000e+00 11 b_cost_class1 -4.756216 0.253114 -18.790787 0.000000e+00 12 asc_sm_s_class1 1.699272 0.333530 5.094815 3.490818e-07 13 asc_car_class1 1.020660 0.215778 4.730134 2.243718e-06 14 asc_car_s_class1 2.874639 0.260598 11.030949 0.000000e+00 .. rst-class:: sphx-glr-timing **Total running time of the script:** (2 minutes 37.191 seconds) .. _sphx_glr_download_auto_examples_swissmetro_plot_b15a_panel_discrete.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_b15a_panel_discrete.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_b15a_panel_discrete.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_b15a_panel_discrete.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_