BUG: Adjust eval environment for stack depth
- [x] closes #9037
- [x] tests added / passed.
- [x] properly formatted commit message. See NumPy's guide.
This PR fixes the formula environment for the conditional logit and Poisson, the proportional hazards model, GEE, and QIF.
Overall PR looks good. Do you know if other formulas suffer, or is this the full extent fo the problem?
There are a few linting issues that need to be fixed. You can ignore MICE errors (needs a deep dive).
The problem appears in several other from_formulas, but gets more complicated because multiple formulas are used. For example, BetaModel takes both the main formula and an optional exog_precision_formula. That second formula isn't parsed with an eval environment, so I expect that it would similarly grab the environment from a statsmodels file rather than the user's environment.
I was trying to sidestep those cases for my first contribution (sorry about the linting error) but I just noticed GEE.from_formula has an optional second formula too. If you don't mind a longer PR, I can extend the fix to those other implementations and their other formulas.
What do you think about putting eval_env into the method signatures directly? I'm not sure if it would have to be a keyword-only argument to avoid breaking possible uses.