biogeme.loglikelihood module

Functions to calculate the log likelihood

author:

Michel Bierlaire

date:

Fri Mar 29 17:11:44 2019

biogeme.loglikelihood.likelihoodregression(meas, model, sigma)[source]

Computes likelihood function of a regression model.

Parameters:
  • meas (Expression) – An expression providing the value \(y\) of the measure for the current observation.

  • model (Expression) – An expression providing the output \(m\) of the model for the current observation.

  • sigma (biogeme.expressions.Expression) – An expression (typically, a parameter) providing the standard error \(\sigma\) of the error term.

Return type:

Expression

Returns:

The likelihood of the regression, assuming a normal distribution, that is

\[\frac{1}{\sigma} \phi\left( \frac{y-m}{\sigma} \right)\]

where \(\phi(\cdot)\) is the pdf of the normal distribution.

biogeme.loglikelihood.loglikelihood(prob)[source]

Simply computes the log of the probability

Parameters:

prob (Expression) – An expression providing the value of the probability.

Return type:

Expression

Returns:

the logarithm of the probability.

biogeme.loglikelihood.loglikelihoodregression(meas, model, sigma)[source]

Computes log likelihood function of a regression model.

Parameters:
  • meas (Expression) – An expression providing the value \(y\) of the measure for the current observation.

  • model (Expression) – An expression providing the output \(m\) of the model for the current observation.

  • sigma (Expression) – An expression (typically, a parameter) providing the standard error \(\sigma\) of the error term.

Return type:

Expression

Returns:

the likelihood of the regression, assuming a normal distribution, that is

\[-\left( \frac{(y-m)^2}{2\sigma^2} \right) - \frac{1}{2}\log(\sigma^2) - \frac{1}{2}\log(2\pi)\]
biogeme.loglikelihood.mixedloglikelihood(prob)[source]

Compute a simulated loglikelihood function

Parameters:

prob (Expression) – An expression providing the value of the probability. Although it is not formally necessary, the expression should contain one or more random variables of a given distribution, and therefore is defined as

Return type:

Expression

\[P(i|\xi_1,\ldots,\xi_L)\]
Return type:

Expression

Returns:

the simulated loglikelihood, given by

\[\ln\left(\sum_{r=1}^R P(i|\xi^r_1,\ldots,\xi^r_L) \right)\]

where \(R\) is the number of draws, and \(\xi_j^r\) is the rth draw of the random variable \(\xi_j\).

Parameters:

prob (Expression)