SkillAgentSearch skills...

Pyfixest

Fast High-Dimensional Fixed Effects Regression in Python following fixest-syntax

Install / Use

/learn @py-econometrics/Pyfixest
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

PyFixest: Fast High-Dimensional Fixed Effects Regression in Python

License Python Versions PyPI -Version Project Chat image Known Bugs File an Issue Downloads Downloads Ruff Pixi Badge Open in Codespaces Donate | GiveDirectly PyPI Citation

Docs · Function & API Reference · DeepWiki · Report Bugs & Request Features · Changelog

PyFixest is a Python package for fast high-dimensional fixed effects regression.

The package aims to mimic the syntax and functionality of Laurent Bergé's formidable fixest package as closely as Python allows: if you know fixest well, the goal is that you won't have to read the docs to get started! In particular, this means that all of fixest's defaults are mirrored by PyFixest.

For a quick introduction, you can take a look at the quickstart or the regression chapter of Coding for Economists. You can find documentation of all user facing functions in the Function Reference section of the documentation.

For questions on PyFixest, head on over to our github discussions, or (more informally) join our Discord server.

Support PyFixest

If you enjoy using PyFixest, please consider donating to GiveDirectly and dedicating your donation to pyfixest.dev@gmail.com. You can also leave a message through the donation form - your support and encouragement mean a lot to the developers!

Features

  • OLS, WLS and IV Regression with Fixed-Effects Demeaning via Frisch-Waugh-Lovell
  • Poisson Regression following the pplmhdfe algorithm
  • Probit, Logit and Gaussian Family GLMs with High-Dimensional Fixed Effects
  • Quantile Regression using an Interior Point Solver
  • Multiple Estimation Syntax
  • Several Robust, Cluster Robust and HAC Variance-Covariance Estimators
  • Wild Cluster Bootstrap Inference (via wildboottest)
  • Difference-in-Differences Estimators:
  • Multiple Hypothesis Corrections following the Procedure by Romano and Wolf and Simultaneous Confidence Intervals using a Multiplier Bootstrap
  • Fast Randomization Inference as in the ritest Stata package
  • The Causal Cluster Variance Estimator (CCV) following Abadie et al.
  • Regression Decomposition following Gelbach (2016)
  • Publication-ready tables with Great Tables or LaTex booktabs

Installation

You can install the release version from PyPI by running

# inside an active virtual environment
python -m pip install pyfixest

or the development version from github by running

python -m pip install git+https://github.com/py-econometrics/pyfixest

For visualization features using the lets-plot backend, install the optional dependency:

python -m pip install pyfixest[plots]

Note that matplotlib is included by default, so you can always use the matplotlib backend for plotting even without installing the optional lets-plot dependency.

GPU Acceleration (Optional)

PyFixest supports GPU-accelerated fixed effects demeaning via CuPy. To enable GPU acceleration, install CuPy matching your CUDA version:

# For CUDA 11.x, 12.x, 13.x
pip install cupy-cuda11x
pip install cupy-cuda12x
pip install cupy-cuda13x

Once installed, you can use GPU-accelerated demeaning by setting the demean_backend parameter:

# Use GPU with float32 and float64 precision
pf.feols("Y ~ X1 | f1 + f2", data=data, demean_backend="cupy32")
pf.feols("Y ~ X1 | f1 + f2", data=data, demean_backend="cupy64")

Benchmarks

All benchmarks follow the fixest benchmarks. All non-pyfixest timings are taken from the fixest benchmarks.

Quickstart

import pyfixest as pf

data = pf.get_data()
pf.feols("Y ~ X1 | f1 + f2", data=data).summary()
###

Estimation:  OLS
Dep. var.: Y, Fixed effects: f1+f2
Inference:  CRV1
Observations:  997

| Coefficient   |   Estimate |   Std. Error |   t value |   Pr(>|t|) |   2.5% |   97.5% |
|:--------------|-----------:|-------------:|----------:|-----------:|-------:|--------:|
| X1            |     -0.919 |        0.065 |   -14.057 |      0.000 | -1.053 |  -0.786 |
---
RMSE: 1.441   R2: 0.609   R2 Within: 0.2

Multiple Estimation

You can estimate multiple models at once by using multiple estimation syntax:

# OLS Estimation: estimate multiple models at once
fit = pf.feols("Y + Y2 ~X1 | csw0(f1, f2)", data = data, vcov = {'CRV1':'group_id'})
# Print the results
fit.etable()
                           est1               est2               est3               est4               est5               est6
------------  -----------------  -----------------  -----------------  -----------------  -----------------  -----------------
depvar                        Y                 Y2                  Y                 Y2                  Y                 Y2
------------------------------------------------------------------------------------------------------------------------------
Intercept      0.919*** (0.121)   1.064*** (0.232)
X1            -1.000*** (0.117)  -1.322*** (0.211)  -0.949*** (0.087)  -1.266*** (0.212)  -0.919*** (0.069)  -1.228*** (0.194)
------------------------------------------------------------------------------------------------------------------------------
f2                            -                  -                  -                  -                  x                  x
f1                            -                  -                  x                  x                  x                  x
------------------------------------------------------------------------------------------------------------------------------
R2                        0.123              0.037              0.437              0.115              0.609              0.168
S.E. type          by: group_id       by: group_id       by: group_id       by: group_id       by: group_id       by: group_id
Observations                998                999                997                998                997                998
--

Related Skills

View on GitHub
GitHub Stars313
CategoryDevelopment
Updated1d ago
Forks82

Languages

Python

Security Score

95/100

Audited on Mar 30, 2026

No findings