the slope is identified by variation left after projecting out unit and time effects. Explicitly constructing thousands of indicator columns is usually unnecessary. Trex uses weighted alternating projections to residualize all design columns and the outcome together, then solves a least-squares problem.
For strictly positive analytic weights W=\operatorname{diag}(w_i), write \widetilde X and \widetilde y for weighted within-transformations. The estimate solves
Alternating demeaning converges to the joint weighted projection; one subtraction of unit means and time means need not suffice in an unbalanced or unequally weighted panel. A failure to converge raises an error.
A weighted two-way panel
The simulation correlates a regressor with unit effects and makes noise variance depend on that regressor. Inverse-variance weights are known here because this is a controlled example. In real data, weights require their own justification.
The comparison illustrates omitted heterogeneity, not a rule that FE always improves an estimate. FE does not solve time-varying confounding, reverse causality or measurement error.
What the uncertainty calculation uses
Set A=W^{1/2}\widetilde X and r=\widetilde y-\widetilde X\hat\beta. The supported covariances are
with \widehat V_{\rm HC1}=n\widehat V_{\rm HC0}/(n-k). Here k counts retained slope columns and the rank of absorbed effects. In a connected two-way panel, absorbed rank is N+T-1; disconnected support changes that count. For large three-or-more-way designs, supply df_absorbed when the exact-rank calculation exceeds the implementation’s level-space bound.
predict(X) returns onlyX\hat\beta. fitted_values_ includes the estimated effects on the training rows. There is no new-level FE prediction interface in this class.
An intercept absorbed by FE retains a zero coefficient slot; zero does not mean the population intercept was estimated as zero.
weights are positive WLS/analytic weights, not replicated-observation frequency counts. Filter zero-weight rows explicitly.
Current choices are None, classical, HC0, and HC1. Repeated panel rows often need clustered inference, which is not implemented here.
A regressor with no within variation cannot identify a slope. Trex drops absorbed columns and rejects remaining rank deficiency.