Add offset option for fepois#805
Add offset option for fepois#805bradhackinen wants to merge 5 commits intopy-econometrics:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 6 files with indirect coverage changes 🚀 New features to boost your workflow:
|
|
pre-commit.ci autofix |
|
Hi @bradhackinen , looks like the unit tests I added fail, but almost pass, which is of course the worst that could happen as it isn't clear if the implementation is slightly off or the tolerance just too low 😅 . I will try to debug this in the next days, but might not find time this weekend as I am traveling. |
|
No worries @s3alfisc. Thanks for writing the tests. Let me know if there is something I can do to help resolve the problems. I can get rpy2 set up on my system next week if necessary. |
|
Hi @bradhackinen ! I believe the test failures on this PR may have been caused by a bug that has since been fixed in #900 (the dependent variable was being cast to integer in Poisson regression, causing information loss). We've been using your branch with that fix applied and the offset feature works as expected on our end. Could you please try rebasing on the latest master and rerunning the CI? Thanks in advance! |
|
Awesome, thanks for the info @marie-gar! I will take a look at this in the next days (unless @bradhackinen feels like he wants to take another stab at it). Brad - my apologies I kept this open for so long! I vaguely recall that I was busy implementing other things, and on top of that I had never used offsets and needed to do some reading first, which I of course never got too ... |
|
Actually, we moved quite a bit of code around, so likely best if I were to try to do the rebase? |
|
Sure, @s3alfisc, I'm happy to let you take the lead on integrating this. But let me know if there is something I can do to help. |
|
Tests seem to run now, how does it look to you @marie-gar @bradhackinen ? |
|
Awesome! Thanks @s3alfisc, @bradhackinen ! |
|
I somehow lost track of this again - I will merge and release this over the Easter break =) |
This code adds an offset option to
fepoisregressions so that the function can be used to model differences in outcome rates.weightsparameter infeolsregressions. So theoffsetargument takes a string that must refer to a column name in the data. If no argument is supplied, the _offset vector is set to 0. This required modifyingmodel_matrix_fixestto take an optional offset argument.I tested the code manually on the included poisson test data, a separation example (01.csv), and data from a current research project. The output the matches the R implementation of fixest (at least to the decimal places visible in the output) in with and without FE.