Ordinary least squares, two-stage least squares, Poisson and logit regressions with any number of high-dimensional fixed effects, interactions of fixed effects, varying slopes, weights and iid, heteroskedasticity-robust (HC1, HC2, HC3), multiway-clustered, CRV3, Newey-West, Driscoll-Kraay or Conley standard errors. The formula syntax, arguments, results and methods follow the 'fixest' package and reproduce its estimates. The computations run in a parallel 'Rust' library that eliminates the largest fixed effect exactly and solves for the others by preconditioned conjugate gradient.
Fast high-dimensional fixed-effects regressions with the fixest interface.
feols(), fepois() and feglm() take fixest 0.14.2's formulas, arguments and defaults and
return objects with fixest's methods, so estimates, standard errors and statistics match
fixest's. The estimation runs in a parallel Rust library that eliminates the largest fixed
effect exactly and solves the others by preconditioned conjugate gradient: at 10 million
observations and 16 threads it is 2.6–200× faster than fixest on the fixest benchmark designs.
library(fereg)
m <- feols(y ~ x1 + x2 | firm + year, df, cluster = ~firm)
iv <- feols(y ~ x1 | firm + year | x2 ~ z, df)
p <- fepois(count ~ x1 | firm + year, df, vcov = "hetero")
lg <- feglm(default ~ x1 | firm, df, family = "logit")
summary(m)
etable(m, iv, p)
fixef(m)
Supported: OLS, IV/2SLS (several endogenous regressors), Poisson, logit; any number of fixed
effects, fe1^fe2 interactions and varying slopes (fe[x], fe[[x]]); weights and offsets;
i(), factor(), multiple estimation (c(y1, y2), sw(), csw(), split, fsplit);
predict (with newdata), resid, fitted, fixef, fitstat, etable, tidy/glance.
Variances, at estimation and post hoc (summary(), vcov(), confint(), etable()), with
fixest's syntax, labels and ssc(): iid, heteroskedasticity-robust (HC1) and HC2/HC3 (exact
leverage, fixed effects included; not for IV), one- to four-way clustering, Newey–West
(NW ~ id + period, NW(2) ~ id + period, NW ~ period for a time series, or "NW" with
panel.id = ~id + period), Driscoll–Kraay (DK(2) ~ period), Conley (conley(100) ~ lat + lon,
conley("60mi"), pixel and spherical distance, fixest's deduced cutoff), and fixest's request
objects (NW(), DK(), conley(), vcov_NW(), vcov_DK(), vcov_conley(), vcov_hetero(),
vcov_cluster()). CRV3 (vcov = crv3 ~ g, vcov_crv3()) is a fereg extension (fixest has no
CRV3): the leave-one-cluster-out jackknife with fixest's cluster small-sample correction;
after estimation it re-estimates the model.
Not implemented: fixef.rm = "infinite_coef", the panel operators l()/f()/d(),
mvsw(), the .[]/..ctrl formula macros, and variances given as functions or matrices.
Installing from source needs Rust (cargo, rustc >= 1.85); the source tarball on the GitHub release page bundles every Rust dependency, so the build needs no network.
The same core powers the Stata commands fereg/feppml/felogit and the Python package
fereg: see https://github.com/leoliu0/fereg.