Importing model specificationΒΆ

The Python language allows to organize your model specification in different files.

Michel Bierlaire, EPFL Thu May 16 13:24:56 2024

from biogeme.biogeme import BIOGEME
from biogeme.models import loglogit
from biogeme.results_processing import get_pandas_estimated_parameters

After having imported the necessary packages, the database and the choice variable are imported from the file tutorial_data.py

from tutorial_data import biogeme_database, choice

Similarly, the specification of the utility functions is imported from the file tutorial_model.py.

from tutorial_model import utilities

Once the ingredients have been imported, the rest of the script is exactly the same.

log_choice_probability = loglogit(utilities, None, choice)
biogeme_object = BIOGEME(biogeme_database, log_choice_probability)
biogeme_object.model_name = 'first_model'
biogeme_object.calculate_null_loglikelihood(avail={0: 1, 1: 1})
results = biogeme_object.estimate()
print(results.short_summary())
print(get_pandas_estimated_parameters(estimation_results=results))
Results for model first_model
Nbr of parameters:              2
Sample size:                    21
Excluded data:                  0
Null log likelihood:            -14.55609
Final log likelihood:           -6.166042
Likelihood ratio test (null):           16.7801
Rho square (null):                      0.576
Rho bar square (null):                  0.439
Akaike Information Criterion:   16.33208
Bayesian Information Criterion: 18.42113

      Name     Value  Robust std err.  Robust t-stat.  Robust p-value
0  asc_car -0.237573         0.805174       -0.295058        0.767950
1   b_time -0.053110         0.021672       -2.450673        0.014259

Total running time of the script: (0 minutes 0.744 seconds)

Gallery generated by Sphinx-Gallery