jeffgortmaker / pyblp

BLP Demand Estimation with Python
https://pyblp.readthedocs.io
MIT License
240 stars 83 forks source link

Coding base level in categorical variables in pyblp #154

Closed claudiolucinda closed 7 months ago

claudiolucinda commented 8 months ago

Hi Jeff,

I have a model with a large(-ish) number of fixed effects in X1. Originally I absorbed them, which was OK, and then I realized I had to have the coefficients for these fixed effects. However, when I put them back in the "non-absorbed" part of X1 the optimizer seems to have some numerical difficulties. I tried using the patsy options for setting the default category on the "C" operator, but they do not seem to work and I read in pyblp docs that arguments are not supported. Is that correct? If so, is there another way to add these fixed effects or will I need to create them manually and add them to the model?

Thanks a lot for your time, Claudio Lucinda

jeffgortmaker commented 8 months ago

Hi Claudio -- that's right, I haven't added support for arguments. Contributions are always welcome, but you'll probably just have to manually add the dummy variables and append them to your formulation. This is what patsy's doing under the hood, so you won't be losing much in terms of speed.

jeffgortmaker commented 7 months ago

I'm going to close this for now, but feel free to keep commenting if you have other questions!