amrei-stammann / alpaca

An R-package for fitting glm's with high-dimensional k-way fixed effects
43 stars 6 forks source link

`predict(..., newdata)` #21

Open grantmcdermott opened 4 days ago

grantmcdermott commented 4 days ago

Hi @amrei-stammann,

Would it be possible to support a newdata argument as part of the predict.feglm method?

This, in turn, would open up support for marginaleffects (c.f. https://github.com/vincentarelbundock/marginaleffects/issues/786), which would be quite useful.

(Although, I think that https://github.com/amrei-stammann/alpaca/issues/14 would probably need to be resolved too.)

Thanks for considering and for this very useful package!

amrei-stammann commented 13 hours ago

Hi,

thanks for your suggestion. I agree, it would be awesome to have a working integration with the marginaleffects package, especially to easily compute bias-corrected APEs for functional forms (e.g. interactions or quadratics).

Since I’m also developing bias corrections on the econometric theory side, I just want to note that opening the newdata argument in predict alone would not be enough. Just to name two crucial points:

1) Bias-correcting APEs requires more than just inserting an adjusted linear index into the standard APE derivatives. 2) Computing APEs is tricky with perfectly classified observations.

We definitely want to offer a user friendly way to compute (bias-corrected) APEs for functional forms in the near future and I will explore what will be the best way to do so.

Best wishes, Amrei

PS. We actually did not support the newdata option in predict because usually people want to use it for out-of-sample predictions, which requires some not so inncocent assumptions in the fixed effects context.

grantmcdermott commented 6 hours ago

Thanks Amrei, that all makes sense to me. Happy to test drive once you settle on an implementation. Cheers.