question about null log-likelihood on different model but using same datset

27 views
Skip to first unread message

Mike Sri

unread,
May 2, 2024, 2:08:46 AMMay 2
to Biogeme
Hi Prof. Bierlaire,

I have been working on comparing MNL model with the Choice Set Formation model. When comparing the results they have different null log-likelihoods that make it difficult to compare them. I previously thought the null log-likelihood should be the same if we used the same dataset. So, the problem might be with defining V or AV? 

Please feel free to correct me. 

I have provide my CSF script here

### Class membership utility


CONSTRAINT_one = (
    coef_intercept_1 +\
        BCSF_INCOME_LOW_1 * low_income +\
        BCSF_INCOME_HIGH_1 * high_income
       )


CONSTRAINT_two = (
    coef_intercept_2 +\
        BCSF_INCOME_LOW_2 * low_income +\
        BCSF_INCOME_HIGH_2 * high_income
        )

delta_zero = 1 #zero car choice always considered

delta_one = exp(CONSTRAINT_one)/(1+ exp(CONSTRAINT_one)) #one car or more choice is probability

delta_two = exp(CONSTRAINT_two)/(1+ exp(CONSTRAINT_two)) #multiple cars choice is probability

#P({i}) is the probability of considering the choice set composed with i alternative
#derive from Bonucci and Ben-Akiva equation

PROB_CLASS_A = (1-delta_one)*(1-delta_two)
PROB_CLASS_B = delta_one * (1-delta_two)
PROB_CLASS_C = delta_one * delta_two

### The contribution to the log likelihood functions is the logarithm of a CSF model

#### CSF Model (Choice Set Formation) (MANSKI's)

# Associate utility functions with the numbering of alternatives
V_class_A = {1: V10, 2: 0, 3: 0}
V_class_B = {1: V10, 2: V11, 3: 0}
V_class_C = {1: V10, 2: V11, 3: V21}

av_class_A = {1.0: 1, 2 :0, 3: 0 }
av_class_B = {1.0: 1, 2 :1, 3: 0 }
av_class_C = {1.0: 1, 2 :1, 3: 1 }

# #CSF
# # #The choice model is a discrete mixture of logit, with availability conditions
prob_util_class_A = models.logit(V_class_A, av_class_A, multiveh)
prob_util_class_B = models.logit(V_class_B, av_class_B, multiveh)
prob_util_class_C = models.logit(V_class_C, av_class_C, multiveh)

prob = prob_util_class_A*(PROB_CLASS_A) + prob_util_class_B*(PROB_CLASS_B) +  prob_util_class_C*(PROB_CLASS_C)

logprob = log(prob)

Michel Bierlaire

unread,
May 2, 2024, 3:23:42 AMMay 2
to tats...@gmail.com, Michel Bierlaire, Biogeme


> On 2 May 2024, at 00:48, Mike Sri <tats...@gmail.com> wrote:
>
> Hi Prof. Bierlaire,
>
> I have been working on comparing MNL model with the Choice Set Formation model. When comparing the results they have different null log-likelihoods that make it difficult to compare them. I previously thought the null log-likelihood should be the same if we used the same dataset. So, the problem might be with defining V or AV?

By default, Biogeme does not calculate the null loglikelihood. What is reported is the *initial* log-likelihood, calculated at the initial value of the parameters.

If you want to include the null loglikelihood in the report, add the following statement:
the_biogeme.calculateNullLoglikelihood(av)
> --
> You received this message because you are subscribed to the Google Groups "Biogeme" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to biogeme+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/biogeme/66fb92c1-ec56-48ba-a41a-baed9d89f09cn%40googlegroups.com.

Michel Bierlaire
Transport and Mobility Laboratory
School of Architecture, Civil and Environmental Engineering
EPFL - Ecole Polytechnique Fédérale de Lausanne
http://transp-or.epfl.ch
http://people.epfl.ch/michel.bierlaire

Mike Sri

unread,
May 2, 2024, 1:41:03 PMMay 2
to Biogeme
Thank you for the response

If that is the case, is it possible that two models (MNL, CSF) using the same dataset have different initial log-likelihood? 

Michel Bierlaire

unread,
May 2, 2024, 1:55:18 PMMay 2
to tats...@gmail.com, Michel Bierlaire, Biogeme


> On 2 May 2024, at 17:21, Mike Sri <tats...@gmail.com> wrote:
>
> Thank you for the response
>
> If that is the case, is it possible that two models (MNL, CSF) using the same dataset have different initial log-likelihood?


Yes. The initial log likelihood depends on the initial value of the parameters which, by default, is read in the file with extension .iter.

The null loglikelihood depends only on the data.
Reply all
Reply to author
Forward
0 new messages