estimation.estimation.fepois

estimation.estimation.fepois(
    fml,
    data,
    vcov=None,
    ssc=None,
    fixef_rm='none',
    fixef_tol=1e-08,
    iwls_tol=1e-08,
    iwls_maxiter=25,
    collin_tol=1e-10,
    separation_check=None,
    solver='np.linalg.solve',
    drop_intercept=False,
    i_ref1=None,
    copy_data=True,
    store_data=True,
    lean=False,
    split=None,
    fsplit=None,
)

Estimate Poisson regression model with fixed effects using the ppmlhdfe algorithm.

Parameters

Name Type Description Default
fml str A two-sided formula string using fixest formula syntax. Syntax: “Y ~ X1 + X2 | FE1 + FE2”. “|” separates left-hand side and fixed effects. Special syntax includes: - Stepwise regressions (sw, sw0) - Cumulative stepwise regression (csw, csw0) - Multiple dependent variables (Y1 + Y2 ~ X) - Interaction of variables (i(X1,X2)) - Interacted fixed effects (fe1^fe2) Compatible with formula parsing via the formulaic module. required
data DataFrameType A pandas or polars dataframe containing the variables in the formula. required
vcov Union[VcovTypeOptions, dict[str, str]] Type of variance-covariance matrix for inference. Options include “iid”, “hetero”, “HC1”, “HC2”, “HC3”, or a dictionary for CRV1/CRV3 inference. None
ssc str A ssc object specifying the small sample correction for inference. None
fixef_rm FixedRmOptions Specifies whether to drop singleton fixed effects. Options: “none” (default), “singleton”. 'none'
fixef_tol float Tolerance for the fixed effects demeaning algorithm. Defaults to 1e-08. 1e-08
iwls_tol Optional[float] Tolerance for IWLS convergence, by default 1e-08. 1e-08
iwls_maxiter Optional[float] Maximum number of iterations for IWLS convergence, by default 25. 25
collin_tol float Tolerance for collinearity check, by default 1e-10. 1e-10
separation_check Optional[list[str]] Methods to identify and drop separated observations. Either “fe” or “ir”. Executes “fe” by default (when None). None
solver SolverOptions, optional. The solver to use for the regression. Can be either “np.linalg.solve” or “np.linalg.lstsq”. Defaults to “np.linalg.solve”. 'np.linalg.solve'
drop_intercept bool Whether to drop the intercept from the model, by default False. False
i_ref1 Deprecated with pyfixest version 0.18.0. Please use i-syntax instead, i.e. fepois(‘Y~ i(f1, ref=1)’, data = data) instead of the former fepois(‘Y~ i(f1)’, data = data, i_ref=1). None
copy_data bool Whether to copy the data before estimation, by default True. If set to False, the data is not copied, which can save memory but may lead to unintended changes in the input data outside of fepois. For example, the input data set is re-index within the function. As far as I know, the only other relevant case is when using interacted fixed effects, in which case you’ll find a column with interacted fixed effects in the data set. True
store_data bool Whether to store the data in the model object, by default True. If set to False, the data is not stored in the model object, which can improve performance and save memory. However, it will no longer be possible to access the data via the data attribute of the model object. This has impact on post-estimation capabilities that rely on the data, e.g. predict() or vcov(). True
lean bool False by default. If True, then all large objects are removed from the returned result: this will save memory but will block the possibility to use many methods. It is recommended to use the argument vcov to obtain the appropriate standard-errors at estimation time, since obtaining different SEs won’t be possible afterwards. False
split Optional[str] A character string, i.e. ‘split = var’. If provided, the sample is split according to the variable and one estimation is performed for each value of that variable. If you also want to include the estimation for the full sample, use the argument fsplit instead. None
fsplit Optional[str] This argument is the same as split but also includes the full sample as the first estimation. None

Returns

Name Type Description
object An instance of the Fepois class or an instance of class FixestMulti for multiple models specified via fml.

Examples

The fepois() function can be used to estimate a simple Poisson regression model with fixed effects. The following example regresses Y on X1 and X2 with fixed effects for f1 and f2: fixed effects are specified after the | symbol.

import pyfixest as pf

data = pf.get_data(model = "Fepois")
fit = pf.fepois("Y ~ X1 + X2 | f1 + f2", data)
fit.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.007 |        0.035 |    -0.190 |      0.850 | -0.075 |   0.062 |
| X2            |     -0.015 |        0.010 |    -1.449 |      0.147 | -0.035 |   0.005 |
---
Deviance: 1068.169 

For more examples, please take a look at the documentation of the feols() function.