The difference between 'logit' function and 'loglogit' function in models module

240 views
Skip to first unread message

Zheren Liu

unread,
Sep 13, 2021, 8:21:39 AM9/13/21
to Biogeme
Dear all, 

I have a question about the 'logit' function and the 'loglogit' function in the 'models' module of Biogeme. In  A short introduction to PandasBiogeme, the demo implement the choice model by models.loglogit. And I just tried the models.logit with the same swissmetro data. And found the results are different. 

This is the results estimated by the logit model:
屏幕截图 2021-09-13 201605.png
And this is the results estimated by the loglogit model:
屏幕截图 2021-09-13 201605.png

I checked the source code, and found that the only difference between 'logit' function and the 'loglogit' function is that  'loglogit ' returns the logarithm of the probability while the 'logit' return the original probability. I'm a little confused. In my view, although the expression of probability in these two models are different,  the estimated parameters should be the same, since the logarithm will not change the extreme point. However, actually the results are different. And I don‘t know why. 

I'd appreciate it if you could help. 

屏幕截图 2021-09-13 201611.png
屏幕截图 2021-09-13 201611.png

Best regards, 
Zheren Liu
Sept. 13th, 2021

Bierlaire Michel

unread,
Sep 13, 2021, 8:26:11 AM9/13/21
to zrli...@gmail.com, Bierlaire Michel, Biogeme
Biogeme requires the definition of the log of the likelihood function.
For logit, you can do it in two ways:

logprob = models.loglogit(V, av, CHOICE)

or

from biogeme.expressions import log
logprob = log(models.logit(V, av, CHOICE))

Both are entirely equivalent and provide the same results.

The former is more efficient from an implementation point of view. This is why it is made available.



> On 13 Sep 2021, at 14:20, Zheren Liu <zrli...@gmail.com> wrote:
>
> Dear all,
>
> I have a question about the 'logit' function and the 'loglogit' function in the 'models' module of Biogeme. In A short introduction to PandasBiogeme, the demo implement the choice model by models.loglogit. And I just tried the models.logit with the same swissmetro data. And found the results are different.
>
> This is the results estimated by the logit model:
> <屏幕截图 2021-09-13 201605.png>
> And this is the results estimated by the loglogit model:
> <屏幕截图 2021-09-13 201605.png>
>
> I checked the source code, and found that the only difference between 'logit' function and the 'loglogit' function is that 'loglogit ' returns the logarithm of the probability while the 'logit' return the original probability. I'm a little confused. In my view, although the expression of probability in these two models are different, the estimated parameters should be the same, since the logarithm will not change the extreme point. However, actually the results are different. And I don‘t know why.
>
> I'd appreciate it if you could help.
>
> <屏幕截图 2021-09-13 201611.png>
> <屏幕截图 2021-09-13 201611.png>
>
> Best regards,
> Zheren Liu
> Sept. 13th, 2021
>
> --
> 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/b0b95ea3-b0cd-44a8-9731-0898b6badd50n%40googlegroups.com.
> <屏幕截图 2021-09-13 201605.png><屏幕截图 2021-09-13 201611.png><屏幕截图 2021-09-13 201611.png><屏幕截图 2021-09-13 201605.png>

Reply all
Reply to author
Forward
0 new messages