Econometrics.jl icon indicating copy to clipboard operation
Econometrics.jl copied to clipboard

Add McFadden's choice model

Open tyleransom opened this issue 6 years ago • 10 comments
trafficstars

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.

tyleransom avatar May 21 '19 18:05 tyleransom

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.

Nosferican avatar May 21 '19 18:05 Nosferican

it might require a Hessian which I could not analytically code after many attempts

Definitely not worth it to hand-code the Hessian!

tyleransom avatar May 21 '19 18:05 tyleransom

From my understanding the steps to implement McFadden would be the following,

  1. Implement the conditional logistic regression clogit
  2. McFadden's is a special case of it with structure given by asclogit

or

  1. Implement Cox (or use Survival.jl implementation)
  2. 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.

Nosferican avatar May 26 '19 03:05 Nosferican

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.

tyleransom avatar May 27 '19 11:05 tyleransom

@matthieugomez, could FixedEffects.jl support GLM features absorption? Stammann (2018) has the algorithm and there is an implementation in CRAN's alpaca.

Nosferican avatar Jul 13 '19 04:07 Nosferican

No, sorry, I don’t have the time to do it.

matthieugomez avatar Jul 13 '19 12:07 matthieugomez

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.

Nosferican avatar Jul 13 '19 12:07 Nosferican

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?

Gkreindler avatar Jul 18 '23 02:07 Gkreindler

I would have to take a look at it. Potentially.

Nosferican avatar Jul 18 '23 02:07 Nosferican

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.

Gkreindler avatar Jul 18 '23 03:07 Gkreindler