Metadata-Version: 2.4
Name: fereg
Version: 0.4.0
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Dist: numpy>=1.25
Requires-Dist: pandas>=1.5
Requires-Dist: formulaic>=1.1 ; extra == 'formulaic'
Provides-Extra: formulaic
Summary: Fast high-dimensional fixed-effects regressions (OLS, IV, Poisson, logit) with pyfixest-compatible results
Author-email: Leo Liu <auleo.liu@gmail.com>
License-Expression: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Repository, https://github.com/leoliu0/fereg

# fereg (Python)

Fast high-dimensional fixed-effects regressions with pyfixest-compatible syntax and results.

`fereg.feols`, `fereg.fepois` and `fereg.feglm` take pyfixest 0.60.0's formulas, arguments and
defaults and return results with pyfixest's classes, names and methods, so estimates, standard
errors and statistics match pyfixest's. The estimation runs in a parallel Rust core that
eliminates the largest fixed effect exactly and solves the others by preconditioned conjugate
gradient: at 10 million observations and 16 threads it is 5–100× faster than pyfixest and
2–200× faster than R's fixest on the fixest benchmark designs.

```python
import fereg

m = fereg.feols("y ~ x1 + x2 | firm + year", data=df, vcov={"CRV1": "firm"})
iv = fereg.feols("y ~ x1 | firm + year | x2 ~ z", data=df)
p = fereg.fepois("count ~ x1 | firm + year", data=df, vcov="hetero")
lg = fereg.feglm("default ~ x1 | firm", data=df, family="logit")
m.summary()
fereg.etable([m, iv, p], type="md")
m.fixef()
```

Supported: OLS, IV/2SLS (several endogenous regressors), Poisson, logit; any number of fixed
effects, `fe1^fe2` interactions and varying slopes `fe[x]`; weights; `i()`, `C()`, multiple
estimation (`sw`, `csw`, several left-hand sides, `split`/`fsplit`); `predict`, `resid`,
`fixef`, `tidy`, `etable`. Data can be pandas or polars.

Variances (`vcov=` at estimation, or post hoc with `m.vcov(...)`), as in pyfixest with `ssc()`:
`"iid"`, `"hetero"`/`"HC1"`, `"HC2"`, `"HC3"`; `{"CRV1": "a+b"}` and `{"CRV3": "a+b"}` (up to
four-way); Newey–West `"NW"` and Driscoll–Kraay `"DK"` with
`vcov_kwargs={"time_id": "year", "panel_id": "firm", "lag": 2}`. fereg extensions (pyfixest
raises): HC2/HC3 with fixed effects, CRV3 for IV and logit (logit refits), Newey–West /
Driscoll–Kraay for IV and Driscoll–Kraay without `panel_id`, and fixest's Conley spatial HAC:
`vcov="conley", vcov_kwargs={"lat": "lat", "lon": "lon", "cutoff": "100km"}` (`cutoff` in km
or `"60mi"`, default deduced as fixest; `pixel`, `distance="triangular"|"spherical"`).

Not implemented: probit; `nid` variances (raise `NotImplementedError`); wild bootstrap,
`ccv`, `decompose`, `ritest`, plotting and DiD helpers.

`nthreads` (default: all cores) sets the number of threads. Results do not depend on it.

The same core powers the Stata commands `fereg`/`feppml`/`felogit` and the R package `fereg`:
see <https://github.com/leoliu0/fereg>.

