Releases: py-econometrics/pyfixest
PyFixest 0.21.0
Highlights
- We have a new and improved quickstart section, thanks to work by @juanitorduz 🎉
- We add a
ritest
module for randomization inference:
import numpy as np
import pyfixest as pf
rng = np.random.default_rng(2332)
data = pf.get_data(N = 100_000, seed = 1432)
fit = pf.feols("Y ~ f3 + X1 | f1", data=data)
fit.ritest(resampvar = "f3", reps = 1000)
Full Changelog
- Fix small bugs with weights by @s3alfisc in #437
- [pre-commit.ci] pre-commit autoupdate by @pre-commit-ci in #438
- Fix weights r2 bug by @s3alfisc in #439
- Bump requests from 2.31.0 to 2.32.2 by @dependabot in #440
- Add more intro material quick start by @juanitorduz in #436
- Set default fig size per plot backend by @juanitorduz in #442
- Fix typos in quickstart by @s3alfisc in #443
- Add support for randomization inference by @s3alfisc in #431
- Ritest tweaks & bug fixes by @s3alfisc in #445
- bump version to 0.21.0 / release version 0.21.0 by @s3alfisc in #449
Full Changelog: v0.20.0...v0.21.0
v0.20.0
Summary
This version introduces MyPy
type checks to the entire pyfixest
codebase. Thanks to @juanitorduz for nudging me to get started with this =). It also fixes a handful of smaller bugs.
New Contributors
- @juanitorduz made their first contribution in #373
- @allcontributors made their first contribution in #389
- @pre-commit-ci made their first contribution in #417
What's Changed
- update readme by @s3alfisc in #368
- update readme by @s3alfisc in #372
- improve pre-commit by @juanitorduz in #373
- Add ruff checks on notebooks via nbqa by @juanitorduz in #374
- Add colors to tests and cov report by @juanitorduz in #376
- PNG -> SVG Badge by @juanitorduz in #377
- Add pre-commit-ci by @juanitorduz in #375
- Rename readme by @s3alfisc in #385
- Rename readme to README in pyproject.toml by @s3alfisc in #388
- docs: add NKeleher as a contributor for code, and infra by @allcontributors in #389
- docs: add styfenschaer as a contributor for code by @allcontributors in #386
- docs: add Wenzhi-Ding as a contributor for code by @allcontributors in #390
- docs: add apoorvalal as a contributor for code by @allcontributors in #391
- Fix contributors by @s3alfisc in #392
- docs: add juanitorduz as a contributor for infra, and code by @allcontributors in #393
- Fix readme by @s3alfisc in #394
- docs: add s3alfisc as a contributor for code, and infra by @allcontributors in #396
- Remove pre-commit from GitHub action by @juanitorduz in #397
matplotlib
(viaseaborn
) support forcoefplot
andiplot
by @juanitorduz in #395- Readme call contributions by @s3alfisc in #399
- Add codecov config yml by @juanitorduz in #401
- docs: add apoorvalal as a contributor for bug by @allcontributors in #406
- Fix iplot bug by @s3alfisc in #405
- docs: add aeturrell as a contributor for tutorial, doc, and promotion by @allcontributors in #408
- Pass
MyPy
Checks by @s3alfisc in #402 - Mypy estimation by @s3alfisc in #412
- Mypy ccv by @s3alfisc in #413
- Mypy fepois by @s3alfisc in #414
- Mypy feols by @s3alfisc in #415
- Mypy fixest multi by @s3alfisc in #416
- [pre-commit.ci] pre-commit autoupdate by @pre-commit-ci in #417
- Pass MyPy checks for model_matrix and formula parser by @s3alfisc in #419
- Version info + documentation updates by @s3alfisc in #420
- Update docs by @s3alfisc in #421
- Fix several small issues by @s3alfisc in #423
- Pass MyPy Checks for the DiD module by @s3alfisc in #424
- Fix bug with negative fixef #425 by @s3alfisc in #426
- [pre-commit.ci] pre-commit autoupdate by @pre-commit-ci in #432
- Bump jinja2 from 3.1.3 to 3.1.4 by @dependabot in #433
- PyFixest
0.20.0
by @s3alfisc in #434
Full Changelog: v0.19.0...v0.20.0
PyFixest 0.19.0
PyFixest 0.19.0
- Fixes multiple smaller and larger performance regressions. The NYC-Taxi example regression now takes approximately 22 seconds to run (... if my laptop is connected to a power charger)!
%load_ext autoreload
%autoreload 2
import duckdb
import time
import numpy as np
import pyfixest as pf
# %%
nyc = duckdb.sql(
'''
FROM 'C:/Users/alexa/Documents/nyc-taxi/**/*.parquet'
SELECT
tip_amount, trip_distance, passenger_count,
vendor_id, payment_type, dropoff_at,
dayofweek(dropoff_at) AS dofw
WHERE year = 2012 AND month <= 3
'''
).df()
# convert dowf, vendor_id, payment_type to categorical
tic = time.time()
nyc["dofw"] = nyc["dofw"].astype(int)
nyc["vendor_id"] = nyc["vendor_id"].astype("category")
nyc["payment_type"] = nyc["payment_type"].astype("category")
print(f"""
I am convering columns of type 'objects' to 'categories' and 'int'data types outside
of the regression, hence I am cheating a bit. This saves {np.round(time.time() - tic)} seconds.
"""
)
# I am convering columns of type 'objects' to 'categories' and 'int'data types outside
# of the regression, hence I am cheating a bit. This saves 7.0 seconds.
run = True
if run:
# mock regression for JIT compilation
fit = pf.feols(
fml = "tip_amount ~ trip_distance + passenger_count | vendor_id + payment_type + dofw",
data = nyc.iloc[1:10_000],
copy_data = False,
store_data = False
)
import time
tic = time.time()
fit = pf.feols(
fml = "tip_amount ~ trip_distance + passenger_count | vendor_id + payment_type + dofw",
data = nyc,
copy_data = False, # saves a few seconds
store_data = False # saves a few second
)
passed = time.time() - tic
print(f"Passed time is {np.round(passed)}.")
# Passed time is 22.
- Three new function arguments for
feols()
andfepois()
:copy_data
,store_data
, andfixef_tol
. - Support for frequency weights via the
weights_type
function argument.
import pyfixest as pf
data = pf.get_data(N = 10000, model = "Fepois")
df_weighted = data[["Y", "X1", "f1"]].groupby(["Y", "X1", "f1"]).size().reset_index().rename(columns={0: "count"})
df_weighted["id"] = list(range(df_weighted.shape[0]))
print("Dimension of the aggregated df:", df_weighted.shape)
print(df_weighted.head())
fit = pf.feols(
"Y ~ X1 | f1",
data = data
)
fit_weighted = pf.feols(
"Y ~ X1 | f1",
data = df_weighted,
weights = "count",
weights_type = "fweights"
)
pf.etable([fit, fit_weighted], coef_fmt = "b(se) \n (t) \n (p)")
- Bugfix: Wild Cluster Bootstrap Inference with Weights would compute unweighted standard errors. Sorry about that! WLS is not supported for the WCB.
- Adds support for CRV3 inference with weights.
What's Changed
- Performance Improvements by @s3alfisc in #359
- Fweights by @s3alfisc in #365
- release version 0.19.0 by @s3alfisc in #366
Full Changelog: v0.18.0...v0.19.0
PyFixest 0.18.0
PyFixest 0.18.0
- Large(ish) Refactoring of Interal Processing of Model Formulas, in particular
FixestFormulaParser
andmodel_matrix_fixest
. As a results, the code should be cleaner and more robust. - The
fml
argument ofmodel_matrix_fixest
is deprecated. Instead,model_matrix_fixest
now asks for aFixestFormula
, which is essentially a dictionary with information on model specifications like a first stage formula (if applicable), dependent variables, fixed effects, etc. - Additionally,
model_matrix_fixest
now returns a dictionary instead of a tuple. - Fixed effects reference setting via
i(var1, var2, ref)
syntax is back. Thei_ref1
,i_ref2
function arguments are deprecated. It is again possible to run
import pyfixest as pf
data = pf.get_data()
fit1 = pf.feols("Y ~ i(f1, X2)", data=data)
fit2 = pf.feols("Y ~ i(f1, X2, ref = 1)", data=data)
fit1.coef()
# Coefficient
# Intercept -0.164200
# C(f1)[T.0.0]:X2 -0.254219
# C(f1)[T.1.0]:X2 -0.118796
# C(f1)[T.2.0]:X2 -0.193556
# level '1' set as reference
fit2.coef()
# Coefficient
# Intercept -0.164029
# C(f1, contr.treatment(base=1))[T.0.0]:X2 -0.254219
# C(f1, contr.treatment(base=1))[T.2.0]:X2 -0.193556
# C(f1, contr.treatment(base=1))[T.3.0]:X2 -0.173535
What's Changed
- Delete warning message when loading the did module by @s3alfisc in #340
- Add
keep
/drop
tocoefplot
and refactor code to improve maintainability by @Wenzhi-Ding in #341 - Rework
fixest_model_matrix
by @s3alfisc in #343 - Fix cluster interaction bug by @s3alfisc in #345
- fix: number of observations format by @Wenzhi-Ding in #347
- Fix summary weights bug by @s3alfisc in #351
FixestFormulaParser
cleanup / refactoring by @s3alfisc in #352- Formula parser cleanup2 by @s3alfisc in #354
- Fix bug with
keep
anddrop
forcoefplot
by @s3alfisc in #356 - Pyfixest 018 by @s3alfisc in #358
Full Changelog: v0.17.0...v0.18.0
PyFixest 0.17.0
Highlights of Version 0.17.0
PyFixest 0.17.0
...
-
... restructures the codebase and reorganizes how users can interact with the
pyfixest
API. It is now recommended to usepyfixest
in the following way:import pyfixest as pf import numpy as np data = pf.get_data() data["D"] = data["X1"] > 0 fit = pf.feols("Y ~ D + f1", data = data) fit.tidy()
Loading
import pyfixest as pf
will expose the most common functions:feols
,fepois
,etable
,summary
,coefplot
,iplot
, etc. The update does not introduce any breaking changes. Thanks to @Wenzhi-Ding for the PR! -
... adds support for simultaneous confidence intervals via a multiplier bootstrap. Thanks to @apoorvalal for the contribution!
fit.confint(joint = True)
-
... adds support for the causal cluster variance estimator by Abadie et al. (QJE, 2023)
for OLS via the.ccv()
method.fit.ccv(treatment = "D", cluster = "group_id")
Details
- dev: add exact_match to _select_order_coefs and etable by @Wenzhi-Ding in #325
- added implementation of simultaneous confidence intervals by @apoorvalal in #286
- Fix
coefplot()
bug after deleting whitespace before % for CIs intidy()
by @s3alfisc in #327 - Implement the Causal Cluster Variance Estimator following Abadie et al by @s3alfisc in #314
- Restructure API and support backward compatibility by @Wenzhi-Ding in #332
- Fix ci error with Python 3.10 by @s3alfisc in #334
- Pyfixest017 by @s3alfisc in #338
New Contributors
- @apoorvalal made their first contribution in #286 🎉
Full Changelog: v0.16.0...v0.17.0
PyFixest 0.16.0
What's Changed
Version 0.16.0
comes with multiple quality of life improvements for development. All of this is thanks to @NKeleher: for example, he has added contribution guidelines to the docs, updated the github workflows to build the documentation, and undertaken a large code-refactoring to pass linting checks that he implemented as well. @Wenzhi-Ding has implemented multiple new features for the etable()
function - for example, it is now possible to pass custom statistics, or to keep and drop variables from the estimation tables. Thanks for all your work! 🎉 @s3alfisc has implemented the Romano-Wolf procedure for multiple hypothesis correction via the rwolf()
function. Last, the documentation has been ported to quartodoc
, which required dropping support for Python 3.8
.
Details
- Update docs by @s3alfisc in #275
- add information on contributing by @NKeleher in #289
- Build Documentation locally by @s3alfisc in #290
- move content from _site to docs by @s3alfisc in #292
- Github Action to copy docs from
docs/_site
todocs
by @s3alfisc in #294 - update poetry dependencies by @NKeleher in #288
- dev: Customize significance notation and coefficient reporting format. by @Wenzhi-Ding in #297
- Migrate docs build to github workflow by @NKeleher in #299
- take out etable example that likely causes build error for quartodoc by @s3alfisc in #301
- publish docs on refs/heads/master by @NKeleher in #302
- rename docs/readme.md by @NKeleher in #303
- Implement the Romano Wolf Multiple Testing Correction #277 by @s3alfisc in #278
- Add ruff linting formatting and basic ruff autofixes by @s3alfisc in #305
- update readme by @s3alfisc in #308
- add bonferroni correction #309 by @s3alfisc in #310
- Refactor codebase to apply selected ruff linting and formatting rules… by @s3alfisc in #312
- Docstyle formatting by @NKeleher in #315
- delete unused functions by @s3alfisc in #317
- dev: Support custom statistics in
etable()
output (#306) by @Wenzhi-Ding in #318 - Bump cryptography from 42.0.2 to 42.0.4 by @dependabot in #319
- dev: Support keep/drop coefs; Improve number formatting. by @Wenzhi-Ding in #320
- release version 0.16.0 by @s3alfisc in #321
New Contributors
- @NKeleher and @Wenzhi-Ding made their first contributions! Thank you so much for all your efforts! 🎉
Full Changelog: v0.15.0...v0.16.0
PyFixest 0.15.0
What's Changed
- Fix
codecov
: generate coverage reports by @s3alfisc in #270 - Add support for
WLS
forfeols()
by @s3alfisc in #273
Full Changelog: v0.14.0...v0.15.0
PyFixest 0.14.0
PyFixest 0.14.0
- Moves the documentation to quartodoc.
- Changes all docstrings to
numpy
format. - Difference-in-differences estimation functions now need to be imported via the
pyfixest.did.estimation
module:
from pyfixest.did.estimation import did2s, lpdid, event_study
What's Changed
Full Changelog: v0.13.5...v0.14.0
PyFixest 0.13.5
PyFixest 0.13.5
- Fixes a bug that lead to incorrect results when the dependent variable and all covariates (excluding the fixed effects) where integers. See #265 for details.
PyFixest 0.13.4
- Fixes a bug in
etable()
with IV's that occurred becausefeols()
does not report R2 statistics for IVs.
PyFixest 0.13.2
- Fixes a bug in
etable()
and a warning infixest_model_matrix
that arose with higherpandas
versions. Thanks to @aeturrell for reporting!
PyFixest 0.13.0
New Features
- Introduces a new pyfixest.did module which contains routines for Difference-in-Differences estimation.
- Introduces support for basic versions of the local projections DiD estimator following Dube et al (2023).
- Adds a new vignette for Difference-in-Differences estimation.
- Reports R2 values in
etable()
.