Biogeme: Python Library  2.5
Functions
Functions calculating statistics on the sample

Functions

def statistics.nullLoglikelihood (availability, iterator)
 Computes the null log likelihood from the sample and ask Biogeme to include it in the output file. More...
 
def statistics.choiceStatistics (choiceSet, choice, iterator)
 Computes the number of times each alternative is chosen in the data set and ask Biogeme to include it in the output file. More...
 
def statistics.availabilityStatistics (availability, iterator)
 Computes the number of times each alternative is declared available in the data set and ask Biogeme to include it in the output file. More...
 
def statistics.cteLoglikelihood (choiceSet, choice, iterator)
 Computes the constant loglikelihood from the sample and ask Biogeme to include it in the output file. More...
 

Detailed Description

Function Documentation

def statistics.availabilityStatistics (   availability,
  iterator 
)

Computes the number of times each alternative is declared available in the data set and ask Biogeme to include it in the output file.

Parameters
availabilityDictionary containing for each alternative the expression for its availability.
iteratorAn iterator on the data file.
Returns
A dictionary n with an entry n[i] for each alternative i containing the number of times it is available.

Definition at line 44 of file statistics.py.

def statistics.choiceStatistics (   choiceSet,
  choice,
  iterator 
)

Computes the number of times each alternative is chosen in the data set and ask Biogeme to include it in the output file.

Parameters
choiceSetlist containing the alternatives for which statistics must be computed.
choiceexpression producing the id of the chosen alternative.
iteratorAn iterator on the data file.
Returns
A dictionary n with an entry n[i] for each alternative i containing the number of times it is chosen.
Note
Note that availability is ignored here.

Definition at line 30 of file statistics.py.

def statistics.cteLoglikelihood (   choiceSet,
  choice,
  iterator 
)

Computes the constant loglikelihood from the sample and ask Biogeme to include it in the output file.

It assumes that the full choice set is available for each observation.

Parameters
choiceSetlist containing the alternatives in the choice set.
choiceexpression producing the id of the chosen alternative.
iteratorAn iterator on the data file.
Returns
log likelihood of a logit model where the only parameters are the alternative specific constants. If $n_i$ is the number of times alternative $i$ is chosen, then it is given by

\[ \mathcal{L} = \sum_i n_i \ln(n_i) - n \ln(n) \]

where $ n = \sum_i n_i $ is the total number of observations.
Note
Note that availability is ignored here.

Definition at line 60 of file statistics.py.

def statistics.nullLoglikelihood (   availability,
  iterator 
)

Computes the null log likelihood from the sample and ask Biogeme to include it in the output file.

Parameters
availabilityA dictionary mapping each alternative ID with its availability condition.
iteratorAn iterator on the data file.
Returns
log likelihood of a model where the choice probability for observation $n$ is given by is $1/J_n$, where $J_n$ is the number of available alternatives, i.e.

\[ \mathcal{L} = -\sum_n \ln(J_n) \]

Definition at line 13 of file statistics.py.

Copyright 2016 Michel Bierlaire