Note
Go to the end to download the full example code.
11a. Cross-nested logitΒΆ
Example of a cross-nested logit model with two nests:
one with existing alternatives (car and train),
one with public transportation alternatives (train and Swissmetro)
Michel Bierlaire, EPFL Sat Jun 21 2025, 16:33:38
from IPython.core.display_functions import display
import biogeme.biogeme_logging as blog
from biogeme.biogeme import BIOGEME
from biogeme.expressions import Beta
from biogeme.models import logcnl
from biogeme.nests import NestsForCrossNestedLogit, OneNestForCrossNestedLogit
from biogeme.results_processing import (
EstimationResults,
get_pandas_estimated_parameters,
)
See the data processing script: Data preparation for Swissmetro.
from swissmetro_data import (
CAR_AV_SP,
CAR_CO_SCALED,
CAR_TT_SCALED,
CHOICE,
GA,
SM_AV,
SM_COST_SCALED,
SM_HE,
SM_TT_SCALED,
TRAIN_AV_SP,
TRAIN_COST_SCALED,
TRAIN_HE,
TRAIN_TT_SCALED,
database,
)
logger = blog.get_screen_logger(level=blog.INFO)
logger.info('Example b11a_cnl.py')
Example b11a_cnl.py
Parameters to be estimated.
asc_car = Beta('asc_car', 0, None, None, 0)
asc_train = Beta('asc_train', 0, None, None, 0)
asc_sm = Beta('asc_sm', 0, None, None, 1)
b_time_swissmetro = Beta('b_time_swissmetro', 0, None, None, 0)
b_time_train = Beta('b_time_train', 0, None, None, 0)
b_time_car = Beta('b_time_car', 0, None, None, 0)
b_cost = Beta('b_cost', 0, None, None, 0)
b_headway_swissmetro = Beta('b_headway_swissmetro', 0, None, None, 0)
b_headway_train = Beta('b_headway_train', 0, None, None, 0)
ga_train = Beta('ga_train', 0, None, None, 0)
ga_swissmetro = Beta('ga_swissmetro', 0, None, None, 0)
existing_nest_parameter = Beta('existing_nest_parameter', 1, 1, 5, 0)
public_nest_parameter = Beta('public_nest_parameter', 1, 1, 5, 0)
Nest membership parameters.
alpha_existing = Beta('alpha_existing', 0.5, 0, 1, 0)
alpha_public = 1 - alpha_existing
Definition of the utility functions
v_train = (
asc_train
+ b_time_train * TRAIN_TT_SCALED
+ b_cost * TRAIN_COST_SCALED
+ b_headway_train * TRAIN_HE
+ ga_train * GA
)
v_swissmetro = (
asc_sm
+ b_time_swissmetro * SM_TT_SCALED
+ b_cost * SM_COST_SCALED
+ b_headway_swissmetro * SM_HE
+ ga_swissmetro * GA
)
v_car = asc_car + b_time_car * CAR_TT_SCALED + b_cost * CAR_CO_SCALED
Associate utility functions with the numbering of alternatives
v = {1: v_train, 2: v_swissmetro, 3: v_car}
Associate the availability conditions with the alternatives
av = {1: TRAIN_AV_SP, 2: SM_AV, 3: CAR_AV_SP}
Definition of nests.
nest_existing = OneNestForCrossNestedLogit(
nest_param=existing_nest_parameter,
dict_of_alpha={1: alpha_existing, 2: 0.0, 3: 1.0},
name='existing',
)
nest_public = OneNestForCrossNestedLogit(
nest_param=public_nest_parameter,
dict_of_alpha={1: alpha_public, 2: 1.0, 3: 0.0},
name='public',
)
nests = NestsForCrossNestedLogit(
choice_set=[1, 2, 3], tuple_of_nests=(nest_existing, nest_public)
)
The choice model is a cross-nested logit, with availability conditions.
log_probability = logcnl(v, av, nests, CHOICE)
Create the Biogeme object
the_biogeme = BIOGEME(database, log_probability)
the_biogeme.model_name = 'b11a_cnl'
Biogeme parameters read from biogeme.toml.
Estimate the parameters.
try:
results = EstimationResults.from_yaml_file(
filename=f'saved_results/{the_biogeme.model_name}.yaml'
)
except FileNotFoundError:
results = the_biogeme.estimate()
*** Initial values of the parameters are obtained from the file __b11a_cnl.iter
Cannot read file __b11a_cnl.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. asc_train b_time_train b_cost b_headway_train ga_train alpha_existing existing_nest_p b_time_swissmet b_headway_swiss ga_swissmetro asc_car b_time_car public_nest_par Function Relgrad Radius Rho
0 0 0 0 0 0 0.5 1 0 0 0 0 0 1 7e+03 16 0.5 -0.93 -
1 0 0 0 0 0 0.5 1 0 0 0 0 0 1 7e+03 16 0.25 -0.79 -
2 0 0 0 0 0 0.5 1 0 0 0 0 0 1 7e+03 16 0.12 -0.66 -
3 0 0 0 0 0 0.5 1 0 0 0 0 0 1 7e+03 16 0.062 -0.48 -
4 0 0 0 0 0 0.5 1 0 0 0 0 0 1 7e+03 16 0.031 -0.22 -
5 -0.031 -0.031 -0.031 -0.031 0.031 0.5 1 0.031 0.031 0.031 -0.031 -0.031 1 6.5e+03 6.1 0.031 0.1 +
6 -0.032 -0.036 -0.039 -0.029 0.036 0.5 1 0.031 0 0.028 -0.031 -0.035 1 6.2e+03 4.4 0.031 0.72 +
7 -0.032 -0.036 -0.039 -0.029 0.036 0.5 1 0.031 0 0.028 -0.031 -0.035 1 6.2e+03 4.4 0.016 -0.49 -
8 -0.016 -0.02 -0.055 -0.013 0.051 0.52 1 0.047 0.016 0.013 -0.047 -0.051 1 5.9e+03 0.56 0.016 0.57 +
9 -0.016 -0.02 -0.055 -0.013 0.051 0.52 1 0.047 0.016 0.013 -0.047 -0.051 1 5.9e+03 0.56 0.0078 -2.2 -
10 -0.016 -0.02 -0.055 -0.013 0.051 0.52 1 0.047 0.016 0.013 -0.047 -0.051 1 5.9e+03 0.56 0.0039 -1.5 -
11 -0.016 -0.02 -0.055 -0.013 0.051 0.52 1 0.047 0.016 0.013 -0.047 -0.051 1 5.9e+03 0.56 0.002 -0.45 -
12 -0.018 -0.022 -0.057 -0.015 0.053 0.52 1 0.049 0.018 0.011 -0.049 -0.053 1 5.9e+03 0.72 0.002 0.37 +
13 -0.018 -0.023 -0.057 -0.013 0.053 0.52 1 0.049 0.019 0.011 -0.049 -0.053 1 5.9e+03 0.19 0.002 0.73 +
14 -0.019 -0.025 -0.059 -0.014 0.055 0.52 1 0.049 0.02 0.0098 -0.049 -0.054 1 5.9e+03 0.2 0.002 0.66 +
15 -0.019 -0.027 -0.061 -0.013 0.056 0.52 1 0.049 0.019 0.0091 -0.049 -0.055 1 5.9e+03 0.066 0.02 1 ++
16 -0.025 -0.046 -0.08 -0.017 0.066 0.52 1 0.051 0.013 0.0019 -0.049 -0.064 1 5.9e+03 1.4 0.02 0.19 +
17 -0.031 -0.065 -0.1 -0.013 0.077 0.52 1 0.053 0.021 -0.0054 -0.049 -0.074 1 5.8e+03 0.38 0.2 0.91 ++
18 -0.031 -0.065 -0.1 -0.013 0.077 0.52 1 0.053 0.021 -0.0054 -0.049 -0.074 1 5.8e+03 0.38 0.098 -15 -
19 -0.031 -0.065 -0.1 -0.013 0.077 0.52 1 0.053 0.021 -0.0054 -0.049 -0.074 1 5.8e+03 0.38 0.049 -23 -
20 -0.031 -0.065 -0.1 -0.013 0.077 0.52 1 0.053 0.021 -0.0054 -0.049 -0.074 1 5.8e+03 0.38 0.024 -37 -
21 -0.031 -0.065 -0.1 -0.013 0.077 0.52 1 0.053 0.021 -0.0054 -0.049 -0.074 1 5.8e+03 0.38 0.012 -17 -
22 -0.031 -0.065 -0.1 -0.013 0.077 0.52 1 0.053 0.021 -0.0054 -0.049 -0.074 1 5.8e+03 0.38 0.0061 -12 -
23 -0.031 -0.065 -0.1 -0.013 0.077 0.52 1 0.053 0.021 -0.0054 -0.049 -0.074 1 5.8e+03 0.38 0.0031 -2.3 -
24 -0.031 -0.065 -0.1 -0.013 0.077 0.52 1 0.053 0.021 -0.0054 -0.049 -0.074 1 5.8e+03 0.38 0.0015 -0.37 -
25 -0.032 -0.067 -0.1 -0.011 0.079 0.52 1 0.051 0.019 -0.0069 -0.047 -0.075 1 5.8e+03 0.62 0.0015 0.37 +
26 -0.032 -0.067 -0.1 -0.013 0.079 0.52 1 0.051 0.018 -0.0071 -0.047 -0.075 1 5.8e+03 0.14 0.0015 0.77 +
27 -0.033 -0.069 -0.1 -0.012 0.08 0.52 1 0.052 0.017 -0.0077 -0.047 -0.076 1 5.8e+03 0.11 0.015 0.97 ++
28 -0.037 -0.084 -0.12 -0.012 0.089 0.52 1.1 0.053 0.021 -0.014 -0.047 -0.084 1 5.8e+03 0.3 0.15 0.92 ++
29 -0.08 -0.23 -0.27 -0.011 0.18 0.52 1.1 0.063 0.01 -0.072 -0.048 -0.16 1 5.6e+03 0.42 0.15 0.89 +
30 -0.12 -0.37 -0.42 -0.0023 0.27 0.53 1.2 0.062 0.02 -0.14 -0.053 -0.24 1.1 5.5e+03 2.4 0.15 0.47 +
31 -0.15 -0.49 -0.58 -0.0073 0.38 0.55 1.3 0.045 -0.001 -0.21 -0.065 -0.33 1.1 5.3e+03 0.71 0.15 0.73 +
32 -0.16 -0.58 -0.73 -0.0042 0.53 0.59 1.4 -0.024 0.002 -0.3 -0.099 -0.44 1.2 5.2e+03 0.75 0.15 0.83 +
33 -0.17 -0.66 -0.86 -0.0063 0.68 0.65 1.5 -0.14 -0.0061 -0.39 -0.13 -0.54 1.3 5.1e+03 0.54 0.15 0.74 +
34 -0.18 -0.74 -0.94 -0.004 0.8 0.7 1.6 -0.3 0.0027 -0.45 -0.16 -0.59 1.3 5.1e+03 0.81 0.15 0.86 +
35 -0.2 -0.84 -1 -0.0067 0.91 0.74 1.7 -0.43 -0.0018 -0.49 -0.24 -0.74 1.3 5e+03 0.6 0.15 0.69 +
36 -0.2 -0.84 -1 -0.0067 0.91 0.74 1.7 -0.43 -0.0018 -0.49 -0.24 -0.74 1.3 5e+03 0.6 0.076 0.089 -
37 -0.22 -0.9 -0.99 -0.0046 0.93 0.75 1.7 -0.51 -0.0017 -0.48 -0.24 -0.7 1.3 5e+03 0.19 0.076 0.58 +
38 -0.21 -0.9 -0.98 -0.0052 0.95 0.78 1.8 -0.56 -0.0062 -0.47 -0.3 -0.78 1.4 5e+03 1 0.076 0.14 +
39 -0.23 -0.98 -1 -0.0045 0.98 0.78 1.8 -0.64 0.0014 -0.47 -0.3 -0.75 1.4 5e+03 0.49 0.076 0.54 +
40 -0.22 -0.97 -0.96 -0.0062 0.97 0.8 1.8 -0.71 -0.005 -0.42 -0.38 -0.81 1.4 5e+03 0.04 0.076 0.71 +
41 -0.25 -1 -0.94 -0.0041 0.97 0.79 1.8 -0.78 -0.0033 -0.39 -0.4 -0.77 1.4 5e+03 0.066 0.076 0.56 +
42 -0.26 -1.1 -0.97 -0.0049 1 0.79 1.9 -0.85 -0.0045 -0.37 -0.47 -0.84 1.4 5e+03 0.14 0.076 0.58 +
43 -0.28 -1.1 -0.97 -0.0043 1 0.76 1.9 -0.93 -0.0032 -0.33 -0.51 -0.81 1.4 5e+03 0.14 0.076 0.44 +
44 -0.31 -1.1 -0.92 -0.005 1 0.72 1.8 -0.95 -0.0086 -0.28 -0.58 -0.85 1.5 5e+03 0.039 0.076 0.26 +
45 -0.33 -1.1 -1 -0.0047 1.1 0.73 1.8 -0.97 -0.0068 -0.28 -0.59 -0.85 1.5 5e+03 0.044 0.076 0.51 +
46 -0.33 -1.1 -1 -0.0047 1.1 0.73 1.8 -0.97 -0.0068 -0.28 -0.59 -0.85 1.5 5e+03 0.044 0.038 -5.3 -
47 -0.33 -1.1 -1 -0.0047 1.1 0.73 1.8 -0.97 -0.0068 -0.28 -0.59 -0.85 1.5 5e+03 0.044 0.019 -1.7 -
48 -0.33 -1.1 -1 -0.0047 1.1 0.73 1.8 -0.97 -0.0068 -0.28 -0.59 -0.85 1.5 5e+03 0.044 0.0095 -0.17 -
49 -0.33 -1.1 -0.99 -0.0045 1.1 0.72 1.8 -0.97 -0.0068 -0.28 -0.59 -0.84 1.5 5e+03 0.0089 0.0095 0.49 +
50 -0.33 -1.1 -0.99 -0.0045 1.1 0.72 1.8 -0.97 -0.0068 -0.28 -0.59 -0.84 1.5 5e+03 0.0089 0.0048 -0.78 -
51 -0.33 -1.1 -0.98 -0.0047 1.1 0.72 1.8 -0.97 -0.0075 -0.27 -0.59 -0.85 1.5 5e+03 0.034 0.0048 0.39 +
52 -0.33 -1.1 -0.98 -0.0047 1.1 0.72 1.8 -0.97 -0.007 -0.27 -0.59 -0.85 1.5 5e+03 0.038 0.0048 0.3 +
53 -0.34 -1.1 -0.98 -0.0046 1.1 0.72 1.8 -0.98 -0.007 -0.27 -0.59 -0.85 1.5 5e+03 0.0093 0.048 0.94 ++
54 -0.37 -1.1 -0.96 -0.0047 1.1 0.71 1.8 -1 -0.0078 -0.23 -0.61 -0.86 1.6 5e+03 0.051 0.048 0.64 +
55 -0.37 -1.1 -0.96 -0.0047 1.1 0.71 1.8 -1 -0.0078 -0.23 -0.61 -0.86 1.6 5e+03 0.051 0.024 -0.36 -
56 -0.37 -1.1 -0.99 -0.0044 1.1 0.71 1.8 -0.99 -0.0078 -0.23 -0.61 -0.86 1.6 5e+03 0.031 0.024 0.31 +
57 -0.36 -1.1 -0.97 -0.0046 1.2 0.69 1.8 -1 -0.0074 -0.22 -0.61 -0.86 1.6 5e+03 0.015 0.024 0.54 +
58 -0.36 -1.1 -0.97 -0.0046 1.2 0.69 1.8 -1 -0.0074 -0.22 -0.61 -0.86 1.6 5e+03 0.015 0.012 -0.21 -
59 -0.37 -1.1 -0.98 -0.0045 1.1 0.7 1.8 -0.99 -0.0081 -0.2 -0.61 -0.86 1.6 5e+03 0.01 0.012 0.6 +
60 -0.37 -1.1 -0.98 -0.0045 1.1 0.7 1.8 -0.99 -0.0081 -0.2 -0.61 -0.86 1.6 5e+03 0.01 0.006 -0.22 -
61 -0.37 -1.1 -0.98 -0.0045 1.1 0.7 1.8 -1 -0.0076 -0.2 -0.61 -0.86 1.6 5e+03 0.0093 0.006 0.47 +
62 -0.37 -1.1 -0.98 -0.0045 1.2 0.7 1.8 -1 -0.008 -0.2 -0.61 -0.86 1.6 5e+03 0.00044 0.006 0.68 +
63 -0.36 -1.1 -0.98 -0.0046 1.2 0.7 1.8 -1 -0.0078 -0.19 -0.61 -0.86 1.6 5e+03 0.0083 0.006 0.73 +
64 -0.36 -1.1 -0.98 -0.0045 1.2 0.69 1.8 -1 -0.0079 -0.19 -0.61 -0.86 1.6 5e+03 0.0029 0.006 0.81 +
65 -0.36 -1.1 -0.98 -0.0045 1.2 0.69 1.8 -1 -0.0077 -0.19 -0.61 -0.86 1.6 5e+03 0.00042 0.006 0.89 +
66 -0.36 -1.1 -0.98 -0.0045 1.2 0.69 1.8 -1 -0.008 -0.18 -0.61 -0.87 1.6 5e+03 0.0036 0.006 0.78 +
67 -0.36 -1.1 -0.98 -0.0045 1.2 0.69 1.8 -1 -0.0078 -0.18 -0.61 -0.86 1.6 5e+03 0.0063 0.006 0.87 +
68 -0.36 -1.1 -0.98 -0.0045 1.2 0.69 1.8 -1 -0.008 -0.18 -0.61 -0.87 1.7 5e+03 0.005 0.06 0.9 ++
69 -0.34 -1.1 -0.97 -0.0045 1.2 0.67 1.7 -1 -0.0076 -0.14 -0.6 -0.87 1.7 5e+03 0.028 0.06 0.61 +
70 -0.34 -1.1 -0.97 -0.0045 1.2 0.67 1.7 -1 -0.0076 -0.14 -0.6 -0.87 1.7 5e+03 0.028 0.03 -14 -
71 -0.34 -1.1 -0.97 -0.0045 1.2 0.67 1.7 -1 -0.0076 -0.14 -0.6 -0.87 1.7 5e+03 0.028 0.015 -5.4 -
72 -0.34 -1.1 -0.97 -0.0045 1.2 0.67 1.7 -1 -0.0076 -0.14 -0.6 -0.87 1.7 5e+03 0.028 0.0075 -1.5 -
73 -0.34 -1.1 -0.97 -0.0045 1.2 0.67 1.7 -1 -0.0076 -0.14 -0.6 -0.87 1.7 5e+03 0.028 0.0037 -0.1 -
74 -0.34 -1.1 -0.98 -0.0044 1.2 0.67 1.7 -1 -0.0079 -0.15 -0.6 -0.87 1.7 5e+03 0.013 0.0037 0.53 +
75 -0.34 -1.1 -0.98 -0.0045 1.2 0.67 1.7 -1 -0.0077 -0.14 -0.6 -0.87 1.7 5e+03 0.00096 0.0037 0.23 +
76 -0.34 -1.1 -0.98 -0.0045 1.2 0.67 1.7 -1 -0.0078 -0.15 -0.6 -0.87 1.7 5e+03 0.0015 0.0037 0.89 +
77 -0.34 -1.1 -0.98 -0.0045 1.2 0.67 1.7 -1 -0.0077 -0.15 -0.6 -0.87 1.7 5e+03 0.0081 0.0037 0.62 +
78 -0.34 -1.1 -0.98 -0.0044 1.2 0.67 1.7 -1 -0.0079 -0.15 -0.6 -0.87 1.7 5e+03 0.0091 0.0037 0.8 +
79 -0.34 -1.1 -0.97 -0.0045 1.2 0.67 1.7 -1 -0.0077 -0.15 -0.6 -0.87 1.7 5e+03 0.0054 0.0037 0.6 +
80 -0.34 -1.1 -0.98 -0.0045 1.2 0.67 1.8 -1 -0.0078 -0.15 -0.6 -0.87 1.7 5e+03 0.0024 0.0037 0.78 +
81 -0.34 -1.1 -0.97 -0.0045 1.2 0.67 1.8 -1 -0.0078 -0.15 -0.6 -0.87 1.7 5e+03 0.0075 0.0037 0.75 +
82 -0.34 -1.1 -0.98 -0.0045 1.2 0.67 1.8 -1 -0.0077 -0.15 -0.6 -0.86 1.7 5e+03 0.0012 0.0037 0.77 +
83 -0.33 -1.1 -0.98 -0.0044 1.2 0.67 1.8 -1 -0.0078 -0.15 -0.6 -0.86 1.7 5e+03 0.0049 0.0037 0.75 +
84 -0.33 -1.1 -0.97 -0.0044 1.2 0.67 1.8 -1 -0.0077 -0.15 -0.6 -0.86 1.7 5e+03 0.0018 0.0037 0.9 +
85 -0.33 -1.1 -0.98 -0.0044 1.2 0.66 1.8 -1 -0.0078 -0.15 -0.6 -0.86 1.8 5e+03 0.0025 0.037 0.99 ++
86 -0.33 -1.1 -0.98 -0.0044 1.2 0.66 1.8 -1 -0.0078 -0.15 -0.6 -0.86 1.8 5e+03 0.0025 0.019 -0.31 -
87 -0.33 -1.1 -0.97 -0.0044 1.2 0.66 1.8 -1 -0.0076 -0.15 -0.6 -0.86 1.8 5e+03 0.02 0.019 0.38 +
88 -0.33 -1.1 -0.97 -0.0044 1.2 0.66 1.8 -1 -0.0076 -0.15 -0.6 -0.86 1.8 5e+03 0.02 0.0093 -1 -
89 -0.32 -1.1 -0.97 -0.0044 1.2 0.66 1.8 -1 -0.0078 -0.14 -0.61 -0.86 1.8 5e+03 0.0038 0.0093 0.19 +
90 -0.32 -1.1 -0.98 -0.0044 1.2 0.66 1.8 -1 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.0028 0.0093 0.24 +
91 -0.32 -1.1 -0.97 -0.0044 1.2 0.65 1.8 -0.99 -0.0076 -0.15 -0.61 -0.86 1.8 5e+03 0.0044 0.0093 0.35 +
92 -0.32 -1.1 -0.97 -0.0044 1.2 0.65 1.8 -0.99 -0.0076 -0.15 -0.61 -0.86 1.8 5e+03 0.0044 0.0047 -0.36 -
93 -0.32 -1.1 -0.97 -0.0044 1.2 0.66 1.8 -0.99 -0.0079 -0.14 -0.6 -0.86 1.8 5e+03 0.0017 0.0047 0.12 +
94 -0.32 -1.1 -0.98 -0.0044 1.2 0.65 1.8 -1 -0.0077 -0.14 -0.6 -0.86 1.8 5e+03 0.012 0.0047 0.82 +
95 -0.32 -1.1 -0.98 -0.0044 1.2 0.65 1.8 -1 -0.0077 -0.14 -0.6 -0.86 1.8 5e+03 0.012 0.0023 -0.35 -
96 -0.32 -1.1 -0.97 -0.0044 1.2 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.001 0.0023 0.7 +
97 -0.32 -1.1 -0.98 -0.0044 1.2 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.0035 0.0023 0.74 +
98 -0.32 -1.1 -0.98 -0.0044 1.2 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.0035 0.0012 -0.11 -
99 -0.32 -1.1 -0.97 -0.0044 1.2 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.0024 0.0012 0.46 +
100 -0.32 -1.1 -0.97 -0.0044 1.2 0.65 1.8 -0.99 -0.0078 -0.14 -0.61 -0.86 1.8 5e+03 0.00023 0.012 0.94 ++
101 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.0089 0.012 0.49 +
102 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.0089 0.0058 -2.1 -
103 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.0089 0.0029 -0.82 -
104 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.6 -0.86 1.8 5e+03 0.00039 0.0029 0.31 +
105 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.6 -0.86 1.8 5e+03 0.00039 0.0015 -0.23 -
106 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0078 -0.14 -0.61 -0.86 1.8 5e+03 0.00041 0.0015 0.79 +
107 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00033 0.0015 0.68 +
108 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00069 0.0015 0.72 +
109 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00011 0.015 0.99 ++
110 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00011 0.0073 -1.3 -
111 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00011 0.0036 -0.07 -
112 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.0057 0.0036 0.2 +
113 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.0057 0.0018 -0.83 -
114 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00087 0.0018 0.3 +
115 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00087 0.00091 -3.9 -
116 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00087 0.00045 -0.26 -
117 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.0019 0.00045 0.58 +
118 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.0012 0.00045 0.67 +
119 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00032 0.00045 0.6 +
120 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.0002 0.00045 0.86 +
121 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00012 0.00045 0.77 +
122 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00023 0.0045 0.9 ++
123 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00023 0.0023 -0.23 -
124 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00019 0.0023 0.47 +
125 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00019 0.0011 -0.35 -
126 -0.31 -1.1 -0.97 -0.0044 1.1 0.64 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.0018 0.0011 0.2 +
127 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 6e-05 0.0011 0.57 +
128 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 6e-05 0.00057 -1.7 -
129 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 6e-05 0.00028 0.029 -
130 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00049 0.00028 0.38 +
131 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 5.6e-05 0.00028 0.61 +
132 -0.31 -1.1 -0.97 -0.0044 1.1 0.65 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 5.6e-05 0.00014 -1 -
133 -0.31 -1.1 -0.97 -0.0044 1.1 0.64 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00028 0.00014 0.29 +
134 -0.31 -1.1 -0.97 -0.0044 1.1 0.64 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 1.3e-05 0.0014 0.92 ++
135 -0.31 -1.1 -0.97 -0.0044 1.1 0.64 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00011 0.0014 0.22 +
136 -0.31 -1.1 -0.97 -0.0044 1.1 0.64 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00011 0.00071 -12 -
137 -0.31 -1.1 -0.97 -0.0044 1.1 0.64 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00011 0.00036 -3.7 -
138 -0.31 -1.1 -0.97 -0.0044 1.1 0.64 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 0.00011 0.00018 -0.6 -
139 -0.31 -1.1 -0.97 -0.0044 1.1 0.64 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 2.2e-05 0.00018 0.46 +
140 -0.31 -1.1 -0.97 -0.0044 1.1 0.64 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 2.2e-05 8.9e-05 -1.4 -
141 -0.31 -1.1 -0.97 -0.0044 1.1 0.64 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 2.5e-05 8.9e-05 0.61 +
142 -0.31 -1.1 -0.97 -0.0044 1.1 0.64 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 2.5e-05 4.4e-05 -4.7 -
143 -0.31 -1.1 -0.97 -0.0044 1.1 0.64 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 2.5e-05 2.2e-05 -0.8 -
144 -0.31 -1.1 -0.97 -0.0044 1.1 0.64 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 1.3e-05 2.2e-05 0.25 +
145 -0.31 -1.1 -0.97 -0.0044 1.1 0.64 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 1.2e-05 0.00022 0.9 ++
146 -0.31 -1.1 -0.97 -0.0044 1.1 0.64 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 1.2e-05 0.00011 -1.8 -
147 -0.31 -1.1 -0.97 -0.0044 1.1 0.64 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 1.2e-05 5.6e-05 -1.3 -
148 -0.31 -1.1 -0.97 -0.0044 1.1 0.64 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 1.2e-05 2.8e-05 -0.22 -
149 -0.31 -1.1 -0.97 -0.0044 1.1 0.64 1.8 -0.99 -0.0077 -0.14 -0.61 -0.86 1.8 5e+03 1e-06 2.8e-05 0.66 -
Optimization algorithm has converged.
Relative gradient: 1.011991302601317e-06
Cause of termination: Relative gradient = 1e-06 <= 6.1e-06
Number of function evaluations: 341
Number of gradient evaluations: 191
Number of hessian evaluations: 0
Algorithm: BFGS with trust region for simple bound constraints
Number of iterations: 150
Proportion of Hessian calculation: 0/95 = 0.0%
Optimization time: 0:00:03.365394
Calculate second derivatives and BHHH
File b11a_cnl.html has been generated.
File b11a_cnl.yaml has been generated.
print(results.short_summary())
Results for model b11a_cnl
Nbr of parameters: 13
Sample size: 6768
Excluded data: 3960
Final log likelihood: -4997.865
Akaike Information Criterion: 10021.73
Bayesian Information Criterion: 10110.39
pandas_results = get_pandas_estimated_parameters(estimation_results=results)
display(pandas_results)
Name Value ... Robust t-stat. Robust p-value
0 asc_train -0.308465 ... -1.541500 1.231951e-01
1 b_time_train -1.073896 ... -7.579054 3.486100e-14
2 b_cost -0.973726 ... -14.711229 0.000000e+00
3 b_headway_train -0.004366 ... -4.491560 7.070336e-06
4 ga_train 1.142978 ... 4.934247 8.046038e-07
5 alpha_existing 0.644707 ... 3.744259 1.809270e-04
6 existing_nest_parameter 1.771215 ... 7.695616 1.398881e-14
7 b_time_swissmetro -0.991511 ... -5.574074 2.488505e-08
8 b_headway_swissmetro -0.007724 ... -2.601172 9.290596e-03
9 ga_swissmetro -0.138849 ... -0.861538 3.889421e-01
10 asc_car -0.606265 ... -4.886097 1.028545e-06
11 b_time_car -0.857011 ... -6.760465 1.375500e-11
12 public_nest_parameter 1.839948 ... 3.953511 7.701258e-05
[13 rows x 5 columns]
Total running time of the script: (0 minutes 10.165 seconds)