PyFixest Function Reference

Estimation

User-facing estimation functions. Everything in this reference is available under the pf. namespace after import pyfixest as pf.

feols Estimate a linear regression model with fixed effects using fixest formula syntax.
fepois Estimate Poisson regression model with fixed effects using the ppmlhdfe algorithm.
feglm Estimate GLM regression models with fixed effects.
quantreg Fit a quantile regression model using the interior point algorithm from Portnoy and Koenker (1997).

Difference-in-Differences

Difference-in-differences and event-study estimators, plus panel treatment visualization.

event_study Estimate Event Study Model.
did2s Estimate a Difference-in-Differences model using Gardner’s two-step DID2S estimator.
lpdid Local projections approach to estimation.
SaturatedEventStudy Saturated event study with cohort-specific effect curves.
panelview Generate a panel view of the treatment variable over time for each unit.

Multiple Hypothesis Testing

Family-wise error-rate corrections for multiple hypothesis testing.

bonferroni Compute Bonferroni adjusted p-values for multiple hypothesis testing.
rwolf Compute Romano-Wolf adjusted p-values for multiple hypothesis testing.
wyoung Compute the Westfall-Young adjusted p-values for multiple hypothesis testing.

Estimation Classes

Fitted-model classes returned by the estimation functions. Users do not construct these directly; they are the objects feols(), fepois(), feglm(), and quantreg() return.

Feols Non user-facing class to estimate a linear regression via OLS.
Fepois Estimate a Poisson regression model.
Feiv Non user-facing class to estimate an IV model using a 2SLS estimator.
Feglm Base class for the estimation of a fixed-effects GLM model.
FixestMulti Results container holding every model fitted by one public-API call.
Quantreg Quantile regression model.

Post-Estimation Methods

Methods available on a fitted model object, e.g. the result of a call to feols(). Defined on Feols and shared by Fepois, Feglm, Feiv, and Quantreg through inheritance.

Feols.tidy Tidy model outputs.
Feols.coef Estimated coefficients as a pandas Series.
Feols.se Coefficient standard errors as a pandas Series.
Feols.tstat Coefficient t-statistics as a pandas Series.
Feols.pvalue Coefficient p-values as a pandas Series.
Feols.confint Fitted model confidence intervals.
Feols.resid Fitted model residuals.
Feols.vcov Compute covariance matrices for an estimated regression model.
Feols.predict Predict values of the model on new data.
Feols.fixef Compute the coefficients of (swept out) fixed effects for a regression model.
Feols.get_performance Get Goodness-of-Fit measures.
Feols.wald_test Conduct Wald test.
Feols.wildboottest Run a wild cluster bootstrap based on an object of type “Feols”.
Feols.ritest Conduct Randomization Inference (RI) test against a null hypothesis of
Feols.ccv Compute the Causal Cluster Variance following Abadie et al (QJE 2023).
Feols.decompose Implement the Gelbach (2016) decomposition method for mediation analysis.
Feols.update Update coefficients for new observations using Sherman-Morrison formula.
Feols.evalue Compute coefficient-wise SAVI e-values.
Feols.pvalue_savi Compute coefficient-wise SAVI sequential p-values.

Summarize and Visualize

Summary tables and coefficient plots for fitted models.

summary Print a summary of estimation results for each estimated model.
etable Generate a table summarizing the results of multiple regression models.
coefplot Plot model coefficients with confidence intervals.
iplot Plot model coefficients for variables interacted via “i()” syntax, with
qplot Plot regression quantiles.

Data Sets

Synthetic data generators used throughout the documentation and tests.

get_data Create a random example data set.
get_ivf_data Synthetic data for the motherhood penalty IV application (IVF instrument).
get_bartik_data Synthetic data for a Bartik (shift-share) IV application on immigration and wages.
get_encouragement_data Synthetic data for an A/B encouragement design IV application.
get_twin_data Generate twin study data for returns to education.
get_worker_panel Generate a worker-firm panel dataset with two-way fixed effects.
get_motherhood_event_study_data Generate a fertility-timing panel for motherhood-penalty event studies.

Formula Parsing & Model Matrix

Internal APIs for formula parsing and model matrix construction.

Formula A formulaic-compliant formula.
ModelMatrix A wrapper around formulaic.ModelMatrix for the specification of PyFixest models.
factor_interaction Fixest-style i() operator for categorical encoding with interactions.

Demeaning

Fixed-effects demeaning: the demean() workhorse and the configurable backends. See the Choosing a Demeaner Backend guide for how to pick one.

demean Demean an array.
BaseDemeaner Base configuration shared by all fixed-effects demeaners.
MapDemeaner Method of Alternating Projections (MAP) demeaner.
LsmrDemeaner Sparse LSMR demeaner.
Preconditioner

Misc / Utilities

Other PyFixest internals and utilities.

detect_singletons Detect singleton fixed effects in a dataset.
ssc Set the small sample correction factor applied in get_ssc().
get_ssc Compute small sample adjustment factors.
optimal_mixture_precision Compute the mixture precision that minimizes SAVI sequence width
model_matrix_fixest Create model matrices for fixed effects estimation.