Skip to content

py-econometrics/pyfixest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,400 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

PyFixest: Fast High-Dimensional Fixed Effects Regression in Python

License Python Versions PyPI Version Coverage Downloads Downloads

Project Chat

Docs · Quickstart · Function & API Reference · DeepWiki · Benchmarks · Contributing · 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 questions on PyFixest, head over to our GitHub discussions, or join our Discord server.

Features

  • Estimation
    • OLS, WLS, IV, and GLMs (Poisson, logit, probit, gaussian) with high-dimensional fixed effects
    • Different demeaning backends (MAP, within, LSMR) on CPU and GPU
    • Fast quantile regression via an interior-point solver
    • Difference-in-differences estimators, including TWFE, Did2s, local projections, and Sun-Abraham event studies
    • Regression decomposition following Gelbach (2016)
    • Multiple estimation syntax
  • Inference
    • Several robust, cluster-robust, and HAC variance-covariance estimators
    • Wild cluster bootstrap inference via wildboottest
    • Multiple hypothesis corrections and simultaneous confidence intervals
    • Fast randomization inference
    • The causal cluster variance estimator (CCV)
  • Post-Estimation & Reporting

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
Optional dependencies

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

python -m pip install pyfixest[plots]

matplotlib is included by default, so plotting works without this extra.

For GPU-accelerated fixed-effects demeaning via CuPy, install the build matching your CUDA version:

pip install cupy-cuda11x
pip install cupy-cuda12x
pip install cupy-cuda13x

Then use the typed demeaner API for GPU execution:

pf.feols(
    "Y ~ X1 | f1 + f2",
    data=data,
    demeaner=pf.LsmrDemeaner(backend="cupy", precision="float32"),
)

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

PyFixest also supports multiple estimation syntax:

fit = pf.feols("Y + Y2 ~ X1 | csw0(f1, f2)", data=data, vcov={"CRV1": "group_id"})
fit.etable()

For more examples, see the quickstart, the formula syntax tutorial, and the Poisson & GLMs tutorial.

Benchmarks

The dgps follow the "simple" and "difficult" dgps from the fixest benchmarks.

Simple DGP Difficult DGP

For the full benchmark suite, see the benchmarks/ directory and the note on difficult fixed effects problems.

Learn More

Acknowledgements

First and foremost, we want to acknowledge Laurent Bergé's formidable fixest, which is so good we decided to stick to its API and conventions as closely as Python allows. Without fixest, PyFixest likely wouldn't exist - or at the very least, it would look very different.

For a full list of software packages and papers that have influenced PyFixest, please take a look at the Acknowledgements page.

We thank all institutions that have funded or supported work on PyFixest!

How to Cite

If you want to cite PyFixest, you can use the following BibTeX entry:

@software{pyfixest,
  author  = {{The PyFixest Authors}},
  title   = {{pyfixest: Fast high-dimensional fixed effect estimation in Python}},
  year    = {2025},
  url     = {https://github.com/py-econometrics/pyfixest}
}

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.

Call for Contributions

Thanks for showing interest in contributing to pyfixest! We appreciate all contributions and constructive feedback, whether that be reporting bugs, requesting new features, or suggesting improvements to documentation.

If you'd like to get involved, but are not yet sure how, please feel free to send us an email. Some familiarity with either Python or econometrics will help, but you really don't need to be a numpy core developer or have published in Econometrica =) We'd be more than happy to invest time to help you get started!

Contributors ✨

Thanks goes to these wonderful people:

styfenschaer
styfenschaer

💻
Niall Keleher
Niall Keleher

🚇 💻
Wenzhi Ding
Wenzhi Ding

💻
Apoorva Lal
Apoorva Lal

💻 🐛
Juan Orduz
Juan Orduz

🚇 💻
Alexander Fischer
Alexander Fischer

💻 🚇
aeturrell
aeturrell

📖 📣
leostimpfle
leostimpfle

💻 🐛
baggiponte
baggiponte

📖
Sanskriti
Sanskriti

🚇
Jaehyung
Jaehyung

💻
Alex
Alex

📖
Hayden Freedman
Hayden Freedman

💻 📖
Aziz Mamatov
Aziz Mamatov

💻
rafimikail
rafimikail

💻
Benjamin Knight
Benjamin Knight

💻
Dirk Sliwka
Dirk Sliwka

💻 📖
daltonm-bls
daltonm-bls

🐛
Marc-André
Marc-André

💻 🐛
Kyle F Butts
Kyle F Butts

🔣
Marco Edward Gorelli
Marco Edward Gorelli

👀
Vincent Arel-Bundock
Vincent Arel-Bundock

💻
IshwaraHegde97
IshwaraHegde97

💻
Tobias Schmidt
Tobias Schmidt

📖
escherpf
escherpf

🐛 💻
Iván Higuera Mendieta
Iván Higuera Mendieta

💻
Ádám Vig
Ádám Vig

💻
Szymon Sacher
Szymon Sacher

💻
AronNemeth
AronNemeth

💻
Dmitri Tchebotarev
Dmitri Tchebotarev

💻
FuZhiyu
FuZhiyu

🐛 💻
Marcelo Ortiz M.
Marcelo Ortiz M.

📖
Joseph Stover
Joseph Stover

📖
JaapCTJ
JaapCTJ

💻
Matt Shapiro
Matt Shapiro

💻
Kristof Schröder
Kristof Schröder

💻
Wiktor
Wiktor

💻
Daman Dhaliwal
Daman Dhaliwal

💻
Jaakko Markkanen
Jaakko Markkanen

🐛
Jonas Skjold Raaschou-Pedersen
Jonas Skjold Raaschou-Pedersen

💻 📖
Bobby Ho
Bobby Ho

📖
Erica Ryan
Erica Ryan

💻
Souhil Abdelmalek Louddad
Souhil Abdelmalek Louddad

📖
Demetri Pananos
Demetri Pananos

💻 👀
Patrick Doupe
Patrick Doupe

💻
Ariadna Albors Zumel
Ariadna Albors Zumel

💻
Martien Lubberink
Martien Lubberink

💻
jonpcohen
jonpcohen

📖
rhstanton
rhstanton

📓 🐛
mdizadi
mdizadi

📖
Tim Mensinger
Tim Mensinger

🚇
Nicholas Junge
Nicholas Junge

💻 🚇
Abel Abate
Abel Abate

💻
Jan Teusen (né Boelts)
Jan Teusen (né Boelts)

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

About

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

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors