bashtage/linearmodels

Example of using PanelData.demean functionality outside of PanelOLS?

cranedroesch opened this issue · 3 comments

Hello, I'm looking to avoid coding my own de-meaning functionality for a project that I'm working on. Specifically I need the ability to do de-meaning in sklearn-style fit and transform steps. I wonder if you know of any open-source examples of your PanelData class -- and specifically PanelData.demean() -- being used in such a fashion. I'd be quite grateful if you could share them if so.

Obviously you'd need some way to store the group-level means for the transform step, and deal with unseen levels of the entity somehow.

I'm not aware of any but I haven't looked. I wrote the PanelData class to abstract the input type, whether ndarray, DataFrame or DataArray. The demean method can only handle entity, time, or both. If both, it uses an iterative procedure. This is not an especially fast method except when panels are balanced. The default demeaning in fixed effect estimators no longer uses this path. It is retained for testing since it is quite simple and robust, even if slow.

Thanks anyway for looking (perhaps I should learn the search better), and for the quick reply!