Learn R Programming

fixest: Fast and user-friendly fixed-effects estimation

The fixest package offers a family of functions to perform estimations with multiple fixed-effects in both an OLS and a GLM context. Please refer to the introduction for a walk-through.

At the time of writing of this page (February 2020), fixest is the fastest existing method to perform fixed-effects estimations, often by orders of magnitude. See below for a benchmarking with the fastest alternative software.

# To install from CRAN:
install.packages("fixest")

# To install the latest stable development release:
install.packages("fixest", 
                 repos = c(ropensci = 'https://fastverse.r-universe.dev',
                           CRAN = 'https://cloud.r-project.org'))

Benchmarking

Here is a comparison of the performance of fixest functions to other state of the art methods to perform estimations with multiple fixed-effects. The results are reported in the five figures below. Package fixest (black lines) is consistently faster in all situations.

Setup

The benchmarking was performed as follows: In the OLS context, we estimate the following equation:

The same functional form (one variable, three fixed-effects) is estimated for the Poisson, the Negative Binomial and the Logit cases (with ad hoc modifications to fit each model). See Berge (2018) for more details on the setup.

For the "difficult" benchmark (OLS only), the data is generated in a way that makes the convergence of the fixed-effects slow. The phenomenon of slow convergence is frequent for real micro-level data sets involving employee and firm fixed-effects for instance.

Each estimation is replicated 10 times and the average computing time is reported in the figures.

The alternative methods used for comparison are:

  • OLS: felm (R: package lfe), reghdfe (Stata) and FixedEffectModels (Julia)
  • Poisson: glmmboot (R: package glmmML), feglm (R: package alpaca) and ppmlhdfe (Stata)
  • Negative Binomial: glm.nb (R: package MASS) and nbreg (Stata)
  • Logit: glmmboot (R: package glmmML), feglm (R: package alpaca) and logit (Stata)

All the aforementioned packages were updated at the benchmarking date: February 2020.

The code and data for the benchmarking can be found in this folder.

Acknowledgements

Of course the development of fixest has been inspired and pushed forward by (almost all) these (great) packages used in the benchmarking and I am deeply indebted to their authors. Although fixest contains many features, some are still uncovered and you should definitely have a look at these packages.

Copy Link

Version

Install

install.packages('fixest')

Monthly Downloads

12,836

Version

0.12.1

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

June 13th, 2024

Functions in fixest (0.12.1)

confint.fixest

Confidence interval for parameters estimated with fixest
coeftable.default

Extracts the coefficients table from an estimation
coeftable

Extracts the coefficients table from an estimation
collinearity

Collinearity diagnostics for fixest objects
coef.fixest

Extracts the coefficients from a fixest estimation
coefplot

Plots confidence intervals and point estimates
confint.fixest_multi

Confidence intervals for fixest_multi objects
coeftable.fixest_multi

Extracts the coefficients tables from fixest_multi estimations
coeftable.fixest

Obtain various statistics from an estimation
coef.fixest_multi

Extracts the coefficients of fixest_multi objects
est_env

Estimates a fixest estimation from a fixest environment
emmeans_support

Support for emmeans package
df.residual.fixest

Residual degrees-of-freedom for fixest objects
demeaning_algo

Controls the parameters of the demeaning procedure
degrees_freedom

Gets the degrees of freedom of a fixest estimation
dsb

Simple and powerful string manipulation with the dot square bracket operator
did_means

Treated and control sample descriptives
deviance.fixest

Extracts the deviance of a fixest estimation
demean

Centers a set of variables around a set of factors
estfun.fixest

Extracts the scores from a fixest estimation
AIC.fixest

Aikake's an information criterion
BIC.fixest

Bayesian information criterion
as.dict

Transforms a character string into a dictionary
aggregate.fixest

Aggregates the values of DiD coefficients a la Sun and Abraham
bread.fixest

Extracts the bread matrix from fixest objects
as.list.fixest_multi

Transforms a fixest_multi object into a list
check_conv_feols

Check the fixed-effects convergence of a feols estimation
base_stagg

Sample data for staggered difference in difference
base_did

Sample data for difference in difference
bin

Bins the values of a variable (typically a factor)