pyhdfe is a Python library for absorbing high-dimensional fixed effects, implementing the algorithm developed by Gaure (2013). It is primarily used in econometrics and statistics for estimating models with several high-dimensional fixed effects, optimized for sparse data structures. The current version is 0.2.0, with an intermittent release cadence.
pip install pyhdfeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `hdfe.hdfe_cluster_col` to absorb multiple high-dimensional fixed effects from a feature matrix `X` and a target vector `y`. It generates synthetic data with several fixed effect columns and then applies the absorption, returning the transformed (residualized) `X` and `y`.
Consider downsampling, using more memory-efficient data types, or processing data in chunks if memory becomes a bottleneck. The library is optimized for sparse matrix operations, ensuring your input data structures (e.g., pandas Series/DataFrame) are appropriate can help.
If convergence issues arise, consider increasing `max_iter` or `tol` parameters if available (not directly exposed in `hdfe_cluster_col` but for other related functions). Review the structure of your fixed effects for potential issues, or simplify the model if necessary.
Ensure that `fixed_effects` is structured as `[pd.Series(fe1), pd.Series(fe2), ...]`. Each Series/array should contain the categorical identifiers for that specific fixed effect.