Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add McFadden's choice model #1

Open
tyleransom opened this issue May 21, 2019 · 10 comments
Open

Add McFadden's choice model #1

tyleransom opened this issue May 21, 2019 · 10 comments
Labels
enhancement New feature or request

Comments

@tyleransom
Copy link

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.

@Nosferican
Copy link
Owner

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.

@tyleransom
Copy link
Author

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

Definitely not worth it to hand-code the Hessian!

@Nosferican
Copy link
Owner

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.

@tyleransom
Copy link
Author

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.

@Nosferican Nosferican added the enhancement New feature or request label Jul 12, 2019
@Nosferican
Copy link
Owner

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

@matthieugomez
Copy link

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

@Nosferican
Copy link
Owner

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.

@Gkreindler
Copy link

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?

@Nosferican
Copy link
Owner

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

@Gkreindler
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants