| name | pyfixest-reference |
| description | Dense, machine-readable API reference for PyFixest โ high-dimensional fixed-effects OLS/WLS/IV and Poisson (feols, fepois, feglm), clustered/robust standard errors, R-style formula syntax, and post-estimation. Use when writing or debugging Python fixed-effects regressions with the pyfixest package. |
| allowed-tools | ["Read","Write","Edit","Bash"] |
PyFixest LLM Skill Reference
Dense, machine-readable reference for LLMs. No prose padding.
Version: matches latest PyFixest release.
Package Import
import pyfixest as pf
Core Estimation Functions
pf.feols() โ OLS / WLS / IV with Fixed Effects
pf.feols(
fml: str,
data: pd.DataFrame,
vcov: str | dict = None,
weights: str = None,
ssc: dict = None,
fixef_rm: str = "singleton",
drop_intercept: bool = False,
split: str = None,
fsplit: str = None,
weights_type: str = "aweights",
solver: str = "scipy.linalg.solve",
lean: bool = False,
) -> Feols | FixestMulti
Returns Feols for single model, FixestMulti for multiple estimation syntax.
pf.fepois() โ Poisson Regression with Fixed Effects
pf.fepois(
fml: str,
data: pd.DataFrame,
vcov: str | dict = None,
ssc: dict = None,
fixef_rm: str = "singleton",
iwls_tol: float = 1e-08,
iwls_maxiter: int = 25,
separation_check: list[str] = None,
split: str = None,
fsplit: str = None,
) -> Fepois | FixestMulti
pf.feglm() โ GLM (without FE demeaning, WIP)
pf.feglm(
fml: str,
data: pd.DataFrame,
family: str,
vcov: str | dict = None,
separation_check: list[str] = None,
split: str = None,
fsplit: str = None,
) -> Feglm | FixestMulti
pf.quantreg() โ Quantile Regression
pf.quantreg(
fml: str,
data: pd.DataFrame,
vcov: str | dict = "nid",
quantile: float | list[float] = 0.5,
method: str = "fn",
split: str = None,
fsplit: str = None,
) -> Feols | FixestMulti
Formula Syntax
Basic
"Y ~ X1 + X2" # OLS
"Y ~ X1 + X2 | fe1" # OLS + one FE
"Y ~ X1 + X2 | fe1 + fe2" # OLS + two-way FE
"Y ~ X1 + C(categorical)" # Categorical variable as dummies
"Y ~ X1 + i(factor, ref=0)" # Factor variable for event studies
"Y ~ X1 + i(f1, X2)" # Interaction: factor ร continuous
"Y ~ 1 | fe1 | X1 ~ Z1" # IV: depvar ~ exog | fe | endog ~ inst
"Y ~ 1 | X1 ~ Z1 + Z2" # IV without FE
"Y ~ X1:X2" # Interaction only
"Y ~ X1*X2" # X1 + X2 + X1:X2
"Y ~ X1 + I(X1**2)" # Polynomial term
Multiple Estimation Operators
"Y ~ X1 + sw(X2, X3)" # Stepwise: two models, X2 then X3
"Y ~ X1 + sw0(X2, X3)" # Stepwise with empty: three models
"Y ~ X1 + csw(X2, X3)" # Cumulative stepwise: X2, then X2+X3
"Y ~ X1 + csw0(X2, X3)" # Cumulative with empty: three models
"Y + Y2 ~ X1" # Multiple dependent variables
"Y ~ X1 | csw0(fe1, fe2)" # Stepwise fixed effects
Split Sample
pf.feols("Y ~ X1 | fe1", data=data, split="group_var")
pf.feols("Y ~ X1 | fe1", data=data, fsplit="group_var")
Post-Estimation Methods (Feols object)
Extracting Results
fit.summary()
fit.tidy(alpha=0.05)
fit.coef()
fit.se()
fit.tstat()
fit.pvalue()
fit.confint(alpha=0.05)
fit.confint(joint=True)
Changing Inference
fit.vcov("iid")
fit.vcov("HC1")
fit.vcov({"CRV1": "cluster_var"})
fit.vcov({"CRV3": "cluster_var"})
fit.vcov({"CRV1": "c1 + c2"})
Returns self โ chainable: fit.vcov("HC1").summary().
Visualization
fit.coefplot()
pf.coefplot([fit1, fit2], keep="X1")
pf.iplot([fit1, fit2], coord_flip=False)
pf.qplot(fit_qr)
Prediction
fit.predict()
fit.predict(newdata=df_new)
fit.predict(type="response")
fit.predict(type="link")
Inference Methods
fit.wildboottest(param="X1", reps=999, cluster="clust_var")
fit.ritest(resampvar="X1=0", reps=1000, cluster="group_id")
fit.ccv(treatment="treat_var", pk=0.05, n_splits=2, seed=42)
fit.wald_test(R=np.eye(k))
fit.wald_test(R=R_matrix, q=q_vector)
IV Diagnostics (Feiv objects)
fit_iv._model_1st_stage
fit_iv._f_stat_1st_stage
fit_iv.IV_Diag()
fit_iv._eff_F
Online Learning
fit.update(X_new, y_new)
Reporting Functions
pf.etable() โ Regression Tables
pf.etable(
models,
type: str = "gt",
signif_code: list = None,
coef_fmt: str = "b \n (se)",
keep: str | list = None,
drop: str | list = None,
labels: dict = None,
felabels: dict = None,
show_fe: bool = True,
show_se_type: bool = True,
notes: str = "",
model_heads: list = None,
caption: str = None,
file_name: str = None,
)
pf.summary() โ Print Results
pf.summary(models, digits=3)
pf.dtable() โ Descriptive Statistics
pf.dtable(
df: pd.DataFrame,
vars: list,
stats: list = None,
bycol: list[str] = None,
byrow: str = None,
type: str = "gt",
labels: dict = None,
digits: int = 2,
)
Multiple Testing Corrections
pf.bonferroni(models, param="X1")
pf.rwolf(models, param="X1", reps=9999, seed=42)
pf.wyoung(models, param="X1", reps=9999, seed=42)
Difference-in-Differences
pf.event_study() โ Unified Event Study API
pf.event_study(
data: pd.DataFrame,
yname: str,
idname: str,
tname: str,
gname: str,
xfml: str = None,
cluster: str = None,
estimator: str = "twfe",
att: bool = True,
)
pf.did2s() โ Gardner's Two-Stage DID
pf.did2s(
data: pd.DataFrame,
yname: str,
first_stage: str,
second_stage: str,
treatment: str,
cluster: str,
weights: str = None,
)
pf.lpdid() โ Local Projections DID
pf.lpdid(
data: pd.DataFrame,
yname: str,
idname: str,
tname: str,
gname: str,
vcov: str | dict = None,
pre_window: int = None,
post_window: int = None,
never_treated: int = 0,
att: bool = True,
xfml: str = None,
)
pf.panelview() โ Treatment Visualization
pf.panelview(data, unit="unit_col", time="time_col", treat="treat_col")
Small Sample Correction
pf.ssc(
k_adj: bool = True,
k_fixef: str = "nonnested",
G_adj: bool = True,
G_df: str = "min",
)
pf.feols("Y ~ X1 | fe1", data=data, ssc=pf.ssc(k_adj=True))
Data Generators
pf.get_data(N=1000, seed=1234, model="Feols")
pf.get_twin_data(N_pairs=500, seed=42)
pf.get_worker_panel(N_workers=500, N_firms=50, N_years=11, seed=42)
Variance-Covariance Options
| vcov | Description |
|---|
"iid" | Spherical errors (homoskedastic, uncorrelated) |
"HC1" | Heteroskedasticity-robust (White) |
"HC2" | HC2 robust |
"HC3" | HC3 robust (jackknife-like) |
{"CRV1": "var"} | One-way cluster-robust |
{"CRV3": "var"} | CRV3 cluster-robust |
{"CRV1": "v1 + v2"} | Two-way clustering |
Default: CRV1 clustered by first FE variable (if FE present), else "iid".
Common Patterns
fit = pf.feols("Y ~ X1 + X2 | fe1 + fe2", data=df, vcov={"CRV1": "fe1"})
fit_iv = pf.feols("Y ~ exog | fe1 | endog ~ instrument", data=df)
fits = pf.feols("Y ~ X1 | csw0(fe1, fe2, fe3)", data=df)
fits.etable()
fit_pois = pf.fepois("count ~ X1 + X2 | fe1", data=df)
fit_es = pf.feols("Y ~ i(rel_time, ref=-1) | unit + time", data=df)
pf.iplot(fit_es)
pf.etable([fit1, fit2, fit3], type="tex", file_name="table1.tex",
labels={"X1": "Treatment"}, felabels={"fe1": "Unit FE"})
fit.vcov({"CRV1": "cluster"}).summary()
FixestMulti Methods
When multiple estimation syntax is used, returns FixestMulti:
multi = pf.feols("Y + Y2 ~ X1 | csw0(fe1, fe2)", data=df)
multi.etable()
multi.summary()
multi.coefplot()
multi.vcov("HC1")
multi.fetch_model(0)
multi.all_fitted_models["Y~X1"]