Biogeme is an excellent open source package for estimating discrete choice models. Model syntax can be specified in Python and run through highly optimized numerical optimization algorithms.
Biogeme runs easily within a Linux/UNIX environment, but has difficulties on Windows. BIObox is meant to provide a light-weight virtual machine for use in prototyping and testing Biogeme code (a more powerful, optimized system is likely to be necessary for processing any substantially sized data or complex models).
The examples
folder includes two codes worth mentioning as they are not explicitly tied to being used within BIObox and may be relevant more broadly:
nest_depth2.py
utilizes a slightly modified piece of Python code to estimate a multilevel nested logit (this functionality is not immediately obvious to execute in Biogeme). This code is based on a non-functioning snippet originally posted to the Biogeme User Group by j_newman_60625.CreateBiogemeCode.py
automates a large portion of writing Pythonbiogeme scripts. Further explanation is included below.
- Download and install VirtualBox
- Download and install Vagrant
- Create a new folder on your computer to hold shared documents for BIObox
cd
to this directory and runvagrant init
- Run
vagrant box add <BIObox> http://lyte.id.au/vagrant/sl6-64-lyte.box
- Pull codes from this git repository into the new folder
- Run
vagrant up
- Run
vagrant ssh
- Use something like PuTTY to log into your virtual machine with the ssh information given by the above
- Within PuTTY
cd /vagrant
. This folder is shared with Windows, so it should be straightforward to place existing codes and datasets there and run them using a command likepythonbiogeme <filename> dataset.dat
.
Although powerful, Pythonbiogeme's syntax is quite verbose, particularly as the number of alternatives, variables, or latent classes increases. In these cases, CreateBiogemeCode.py can be used to generate an approximate skeleton Pythonbiogeme code in a few short lines. This skeleton code should technically run, but adjustments are likely to be necessary to ensure mathematical accuracy. To test CreateBiogemeCode.py's functionality:
- Within PuTTY
cd /vagrant/examples
- Run
./test_create_biogeme_code.py
. This code uses CreateBiogeme.py to create several example skeleton codes. - Once the appropriate edits are made (see comments at the top of each file) use a command like
pythonbiogeme mnl mock.dat
to run themnl.py
code.