An R package for estimating linear panel regression models with interactive fixed effects (IFE) in balanced and unbalanced panels. The package implements the IFE estimator of Bai (2009) and extends it to unbalanced panels under conditionally random attrition following Czarnowske and Stammann (2020). Bias correction procedures are provided to account for asymptotic bias due to heteroscedasticity of the idiosyncratic error term and due to predetermined regressors, as well as routines for estimating the number of factors.
- Bai, J. (2009). Panel data models with interactive fixed effects. Econometrica, 77(4), 1229–1279.
- Czarnowske, D. & Stammann, A. (2020). Inference in unbalanced panel data models with interactive fixed effects. arXiv:2004.03414.
- Moon, H. R., & Weidner, M. (2017). Dynamic linear panel regression models with interactive fixed effects. Econometric Theory, 33(1), 158-195.
The package can be installed from GitHub using the pak package:
# install.packages("pak")
pak::pak("dczarnowske/InteractiveEffects")The following toy example illustrates the main workflow: generating synthetic data, estimating an IFE model, and applying bias correction.
# Load package
library(InteractiveEffects)
# Generate a synthetic panel data set
df <- synthetic_data(125, 25, 4711, psi = 0.2)
# Create a panel data object
pd <- panel_data(df, "id", "time")
# Estimate a linear model with interactive fixed effects (r = 1 factor)
reg <- lm_ie(y ~ y_lag, pd, r = 1)
# Apply bias correction for heteroscedasticity and predetermined regressors
reg_bc <- bias_correction(reg, L = 5, xs_het = TRUE, ts_het = TRUE)
# Inspect the debiased results
summary(reg_bc)