.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/indicators/plot_b02estimation.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_indicators_plot_b02estimation.py: Estimation and simulation of a nested logit model ================================================= We estimate a nested logit model and we perform simulation using the estimated model. :author: Michel Bierlaire, EPFL :date: Wed Apr 12 21:05:16 2023 .. GENERATED FROM PYTHON SOURCE LINES 13-21 .. code-block:: Python from IPython.core.display_functions import display from biogeme import models import biogeme.biogeme as bio from biogeme.data.optima import read_data from scenarios import scenario .. GENERATED FROM PYTHON SOURCE LINES 22-24 Obtain the specification for the default scenario. The definition of the scenarios is available in :ref:`scenarios`. .. GENERATED FROM PYTHON SOURCE LINES 24-26 .. code-block:: Python V, nests, Choice, _ = scenario() .. GENERATED FROM PYTHON SOURCE LINES 27-29 The choice model is a nested logit, with availability conditions For estimation, we need the log of the probability. .. GENERATED FROM PYTHON SOURCE LINES 29-31 .. code-block:: Python logprob = models.lognested(util=V, availability=None, nests=nests, choice=Choice) .. GENERATED FROM PYTHON SOURCE LINES 32-33 Get the database .. GENERATED FROM PYTHON SOURCE LINES 33-34 .. code-block:: Python database = read_data() .. GENERATED FROM PYTHON SOURCE LINES 35-36 Create the Biogeme object for estimation. .. GENERATED FROM PYTHON SOURCE LINES 36-39 .. code-block:: Python the_biogeme = bio.BIOGEME(database, logprob) the_biogeme.modelName = 'b02estimation' .. GENERATED FROM PYTHON SOURCE LINES 40-41 Estimate the parameters. Perform bootstrapping. .. GENERATED FROM PYTHON SOURCE LINES 41-44 .. code-block:: Python the_biogeme.bootstrap_samples = 100 results = the_biogeme.estimate(run_bootstrap=True) .. rst-class:: sphx-glr-script-out .. code-block:: none 0%| | 0/100 [00:00` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_b02estimation.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_b02estimation.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_