causalfe: Causal Forests with Fixed Effects in Python
Harry Aytug
TL;DR
The paper addresses estimating heterogeneous treatment effects in panel data with unit and time fixed effects, where standard causal forests can misattribute variation due to fixed effects. It introduces Causal Forests with Fixed Effects (CFFE) implemented in Python, which performs node-level residualization within each tree node, uses $\tau$-heterogeneity splitting, honest estimation, and cluster-aware subsampling to obtain valid, nonparametric estimates of $\tau(x)$. The results from simulations and an empirical example on minimum wage show that CFFE recovers true CATE patterns and provides more reliable inference than standard causal forests, particularly when fixed effects are correlated with covariates. While CI coverage is approximate and computational costs are nontrivial for large panels, the approach offers a practical, accessible tool for policy evaluation and heterogeneity analysis in panel settings, with potential for future improvements in variance estimation and scalability.
Abstract
The causalfe package provides a Python implementation of Causal Forests with Fixed Effects (CFFE) for estimating heterogeneous treatment effects in panel data settings. Standard causal forest methods struggle with panel data because unit and time fixed effects induce spurious heterogeneity in treatment effect estimates. The CFFE approach addresses this by performing node-level residualization during tree construction, removing fixed effects within each candidate split rather than globally. This paper describes the methodology, documents the software interface, and demonstrates the package through simulation studies that validate the estimator's performance under various data generating processes.
