-
Notifications
You must be signed in to change notification settings - Fork 37
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
Bug: Incorrect prediction with WLS anf fixed effects and newdata not None #678
Comments
@all-contributors please add @marcandre259 for bug |
I've put up a pull request to add @marcandre259! 🎉 |
In all likelihood, the bug hence stems from the In particular, the least squares problem solved via pyfixest/pyfixest/estimation/feols_.py Line 1535 in 5250fc3
|
Hi @marcandre259 & also @leostimpfle , I found the bug: For a regression without weights, we are fitting a regression model of the following form: After fitting We can then solve for If we have weights, we need to multiply D, X and Y with the standard All of this (minus the part about weights) is nicely explained in the lfe vignette: link. I'll prepare the PR for this now + add some tests. @leostimpfle, this is also what we have to use for retrieving the alphas in the Poisson class (with the correct weights from the Poisson fit), as the strategy to fit GLMs in PyFixest is to implement an iterated weighted least squares algo (and therefore, the link function does not matter). For the same reason, |
For WLS estimation with newdata argument provided, the output of predict is incorrect.
For all other cases, it matched
fixest
.See examples below:
No newdata, no weights
No newdata, weights
newdata, no weights
newdata, weights
@all-contributors please add @marcandre259 for bug
The text was updated successfully, but these errors were encountered: