Econometrics.jl
Econometrics.jl copied to clipboard
Add McFadden's choice model
I have written code to estimate McFadden's choice model (asclogit in Stata). I am not sure how to incorporate it into your package, though.
What I had in mind was to add it as another method in solvers.jl. However, I don't quite follow the custom types you've created. Also, in McFadden's choice model, Z is the array that stores alternative-specific variables, so one would need to clarify that that's not referring to an instrumental variable for that method.
If you're interested in seeing the code I have so far, here's a gist that includes it. It exactly replicates the example from the Stata help entry for asclogit.
Finally, I think your ordered logit code can be improved by making use of the fg! method in Optim. However, I'm still trying to figure this out myself (see here), so I can't help you just yet.
I saw the code from the Discourse post and had planned to go over it in the next couple days. Thanks! I have a few improvements I haven't push just yet and will check if I it covers fg! methods (it might require a Hessian which I could not analytically code after many attempts or maybe be included automatically through the use of Twicedifferentiable). I will try to look at it and see how best to incorporate McFadden's choice as a dispatch.
it might require a Hessian which I could not analytically code after many attempts
Definitely not worth it to hand-code the Hessian!
From my understanding the steps to implement McFadden would be the following,
- Implement the conditional logistic regression clogit
- McFadden's is a special case of it with structure given by asclogit
or
- Implement Cox (or use Survival.jl implementation)
- Adapt the data to à la survival
I think either approach should eventually yield the same functionality. I took a look at the code and got some of it, but not all. Could you post some references that might help me understand the code/implementation or any edits to comment the code for make it more transparent would help.
If you are attending JuliaCon we could also meet then to further this development.
will check if I it covers
fg!methods
The functionality we need currently has a bug, but the Optim.jl contributors have been made aware. So for now what you've got is the best we can do.
The route I've taken is "clogit --> asclogit" but you're correct that I need to add some more annotations. I will do that soon and point you to the right place.
@matthieugomez, could FixedEffects.jl support GLM features absorption? Stammann (2018) has the algorithm and there is an implementation in CRAN's alpaca.
No, sorry, I don’t have the time to do it.
No worries, if I end up implementing it or if/when it happens I will let you know in case you want to port it there.
This conversation is above my level, but does https://github.com/jmboehm/GLFixedEffectModels.jl now implement GLM features absorption? Could that help with clogit here?
I would have to take a look at it. Potentially.
Thank you for this entire package and no worries!
The context on my side is that I am looking for a way to include fixed effects (not too large, but too much to type by hand) in a discrete choice model. I've looked at DiscreteChoiceModels.jl but I don't know how to do that there. This is why I found this thread interesting.