Skip to content

py-econometrics/pyfixest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1,399 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

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

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