Skip to content

Releases: py-econometrics/pyfixest

PyFixest 0.21.0

27 May 20:37
54dd77e
Compare
Choose a tag to compare

Highlights

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

Full Changelog: v0.20.0...v0.21.0

v0.20.0

12 May 08:48
f2a8ca9
Compare
Choose a tag to compare

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

What's Changed

Full Changelog: v0.19.0...v0.20.0

PyFixest 0.19.0

12 Apr 11:33
3249eda
Compare
Choose a tag to compare

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() and fepois(): copy_data, store_data, and fixef_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

Full Changelog: v0.18.0...v0.19.0

PyFixest 0.18.0

24 Mar 09:21
2833674
Compare
Choose a tag to compare

PyFixest 0.18.0

  • Large(ish) Refactoring of Interal Processing of Model Formulas, in particular FixestFormulaParser and model_matrix_fixest. As a results, the code should be cleaner and more robust.
  • The fml argument of model_matrix_fixest is deprecated. Instead, model_matrix_fixest now asks for a FixestFormula, 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. The i_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

Full Changelog: v0.17.0...v0.18.0

PyFixest 0.17.0

03 Mar 16:39
b019672
Compare
Choose a tag to compare

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 use pyfixest 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 in tidy() 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

Full Changelog: v0.16.0...v0.17.0

PyFixest 0.16.0

22 Feb 21:22
5a19b15
Compare
Choose a tag to compare

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

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

31 Jan 21:42
8576859
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.14.0...v0.15.0

PyFixest 0.14.0

12 Jan 21:58
6eefe25
Compare
Choose a tag to compare

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

  • PyFixest 0.14.0: Move documentation to quartodoc by @s3alfisc in #264

Full Changelog: v0.13.5...v0.14.0

PyFixest 0.13.5

09 Jan 22:18
Compare
Choose a tag to compare

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 because feols() does not report R2 statistics for IVs.

PyFixest 0.13.2

  • Fixes a bug in etable() and a warning in fixest_model_matrix that arose with higher pandas versions. Thanks to @aeturrell for reporting!

PyFixest 0.13.0

01 Jan 13:52
e1c251e
Compare
Choose a tag to compare

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().