biogeme.tools.likelihood_ratio module

class biogeme.tools.likelihood_ratio.LRTuple(message, statistic, threshold)[source]

Bases: NamedTuple

Tuple for the likelihood ratio test

Parameters:
  • message (str)

  • statistic (float)

  • threshold (float)

message: str

Alias for field number 0

statistic: float

Alias for field number 1

threshold: float

Alias for field number 2

biogeme.tools.likelihood_ratio.likelihood_ratio_test(model1, model2, significance_level=0.05)[source]

This function performs a likelihood ratio test between a restricted and an unrestricted model.

Parameters:
  • model1 (tuple[float, int]) – the final loglikelihood of one model, and the number of estimated parameters.

  • model2 (tuple[float, int]) – the final loglikelihood of the other model, and the number of estimated parameters.

  • significance_level (float) – level of significance of the test. Default: 0.05

Return type:

LRTuple

Returns:

a tuple containing:

  • a message with the outcome of the test

  • the statistic, that is minus two times the difference between the loglikelihood of the two models

  • the threshold of the chi square distribution.

Raises:

BiogemeError – if the unrestricted model has a lower log likelihood than the restricted model.