Package: pyfixest
PyFixest: Fast High-Dimensional Fixed Effects Regression in PythonPyFixestis a Python implementation of the formidablefixestpackage for fast
high-dimensional fixed effects regression. The package aims to mimicfixestsyntax and functionality as closely as Python allows: if you
knowfixestwell, the goal is that you won't have to read the docs to
get started! In particular, this means that all offixest'sdefaults
are mirrored byPyFixest- currently with onlyone small
exception.
Nevertheless, for a quick introduction, you can take a look at thetutorialor the
regression chapter ofArthur Turrell'sbook onCoding for
Economists.FeaturesOLS and IV RegressionPoisson Regression following thepplmhdfe algorithmMultiple Estimation SyntaxSeveral Robust and Cluster Robust Variance-Covariance TypesWild Cluster Bootstrap Inference (viawildboottest)Difference-in-Difference Estimators:The canonical Two-Way Fixed Effects EstimatorGardner's two-stage
("Did2s")estimatorBasic Versions of the Local Projections estimator followingDube et al (2023)Multiple Hypothesis Corrections following the Procedure byRomano and WolfInstallationYou can install the release version fromPyPiby runningpipinstallpyfixestor the development version from github by runningpipinstallgit+https://github.com/s3alfisc/pyfixest.gitNewsPyFixest0.15.2adds support for Romano-Wolf Corrected p-values via therwolf()function.BenchmarksAll benchmarks follow thefixest
benchmarks.
All non-pyfixest timings are taken from thefixestbenchmarks.Quickstartfrompyfixest.estimationimportfeols,fepoisfrompyfixest.utilsimportget_datafrompyfixest.summarizeimportetabledata=get_data()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.2Multiple EstimationYou can estimate multiple models at once by usingmultiple estimation
syntax:# OLS Estimation: estimate multiple models at oncefit=feols("Y + Y2 ~X1 | csw0(f1, f2)",data=data,vcov={'CRV1':'group_id'})# Print the resultsetable([fit.fetch_model(i)foriinrange(6)])Model:  Y~X1
Model:  Y2~X1
Model:  Y~X1|f1
Model:  Y2~X1|f1
Model:  Y~X1|f1+f2
Model:  Y2~X1|f1+f2
                          est1               est2               est3               est4               est5               est6
------------  ----------------  -----------------  -----------------  -----------------  -----------------  -----------------
depvar                       Y                 Y2                  Y                 Y2                  Y                 Y2
-----------------------------------------------------------------------------------------------------------------------------
Intercept     0.919*** (0.121)   1.064*** (0.232)
X1             -1.0*** (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
-----------------------------------------------------------------------------------------------------------------------------
Significance levels: * p < 0.05, ** p < 0.01, *** p < 0.001
Format of coefficient cell:
Coefficient (Std. Error)Adjust Standard Errors "on-the-fly"Standard Errors can be adjusted after estimation, "on-the-fly":fit1=fit.fetch_model(0)fit1.vcov("hetero").summary()Model:  Y~X1
###

Estimation:  OLS
Dep. var.: Y
Inference:  hetero
Observations:  998

| Coefficient   |   Estimate |   Std. Error |   t value |   Pr(>|t|) |   2.5 % |   97.5 % |
|:--------------|-----------:|-------------:|----------:|-----------:|--------:|---------:|
| Intercept     |      0.919 |        0.112 |     8.223 |      0.000 |   0.699 |    1.138 |
| X1            |     -1.000 |        0.082 |   -12.134 |      0.000 |  -1.162 |   -0.838 |
---
RMSE: 2.158   R2: 0.123Poisson Regression viafepois()You can estimate Poisson Regressions via thefepois()function:poisson_data=get_data(model="Fepois")fepois("Y ~ X1 + X2 | f1 + f2",data=poisson_data).summary()###

Estimation:  Poisson
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.008 |        0.035 |    -0.239 |      0.811 |  -0.076 |    0.060 |
| X2            |     -0.015 |        0.010 |    -1.471 |      0.141 |  -0.035 |    0.005 |
---
Deviance: 1068.836IV Estimation via three-part formulasLast,PyFixestalso supports IV estimation via three part formula
syntax:fit_iv=feols("Y ~ 1 | f1 | X1 ~ Z1",data=data)fit_iv.summary()###

Estimation:  IV
Dep. var.: Y, Fixed effects: f1
Inference:  CRV1
Observations:  997

| Coefficient   |   Estimate |   Std. Error |   t value |   Pr(>|t|) |   2.5 % |   97.5 % |
|:--------------|-----------:|-------------:|----------:|-----------:|--------:|---------:|
| X1            |     -1.025 |        0.115 |    -8.930 |      0.000 |  -1.259 |   -0.790 |
---