Mixed Logit Model in Julia

Hi everyone!

I’ve created a script to estimate Mixed Logit Models based on the codes of Kenneth Train (https://eml.berkeley.edu/~train/software.html) for MATLAB.

The code and an example can be found here: https://github.com/ighdez/MultiLogit

The main script (test_mixlogit_KT.jl) is a replication of the example of Train’s MATLAB code using the same dataset. It calls the required Log-Likelihood function (llf_mxl.jl), some additional functions such as the MLHS sampler (misc.jl) and a BFGS minimizer written for this purpose (bfgsmin.jl).

My idea is to make this code available for those who want to use it for their research and education purposes, but you’re free to contribute/modify/share the code if you want :wink:

¡Saludos!

3 Likes

For these goals, perhaps it would be better to organize into a Julia package, with a Project.toml, tests, etc. In contrast to MATLAB, where the culture is to pass scripts around, Julia library software is usually packaged. See

https://julialang.github.io/Pkg.jl/v1/creating-packages/

I was reading the code, and you use a lot of numerical derivatives, maybe you can offer an option with Algorithmic Differenciation (ForwardDiff.jl), for example:

function numhess(f,param; ep=1e-05)
# your code
end

can be obtained directly from ForwardDiff! (a magic thing indeed):

using ForwardDiff
numhess(f,param) = ForwardDiff.Hessian(f,param)

Thanks for your suggestion, Tamas. I will do it.

Agree! I will see how it performs. Thanks!

1 Like

https://github.com/Nosferican/Econometrics.jl has basic mlogit and ologit. clogit in the works. I would be happy to host the code if you so wish. Feel free to look at the code if that helps.

2 Likes

Hello Jose,
a very good project. Have you moved this forward? Indeed it is the only application of Julia to mixed logit I found. I tried it and it is pretty fast. Its use could be made more versatile if there was the option to fix some of the random coefficients means to zero, so as to use random error component (with variance, but zero mean) and produce correlation patterns across random coefficients. Do you have any suggestion on how to achieve this in the current set-up?
Ric

1 Like