Skip to content

FE - Fixed Effects

Overview

The Fixed Effects (FE) estimator handles panel data models with entity-specific unobserved heterogeneity. It uses within-transformation (demeaning) to eliminate time-invariant fixed effects and provides consistent estimates when individual effects are correlated with regressors.

Mathematical Foundation

Panel Data Model

\[y_{it} = \alpha_i + \mathbf{x}_{it}'\mathbf{\beta} + \epsilon_{it}\]

where \(\alpha_i\) are entity-specific fixed effects and \(i = 1, \ldots, N\), \(t = 1, \ldots, T\).

Within Transformation

Eliminate fixed effects by demeaning: \(\(\tilde{y}_{it} = y_{it} - \bar{y}_i, \quad \tilde{\mathbf{x}}_{it} = \mathbf{x}_{it} - \bar{\mathbf{x}}_i\)\)

where \(\bar{y}_i = \frac{1}{T_i}\sum_{t=1}^{T_i} y_{it}\) and \(\bar{\mathbf{x}}_i = \frac{1}{T_i}\sum_{t=1}^{T_i} \mathbf{x}_{it}\).

FE Estimator

Apply OLS to demeaned data: \(\(\hat{\mathbf{\beta}}_{FE} = (\tilde{\mathbf{X}}'\tilde{\mathbf{X}})^{-1}\tilde{\mathbf{X}}'\tilde{\mathbf{y}}\)\)

Fixed Effects Recovery

\[\hat{\alpha}_i = \bar{y}_i - \bar{\mathbf{x}}_i'\hat{\mathbf{\beta}}_{FE}\]

API Reference

Constructor

FE(robust=False)

Parameters: - robust (bool): Whether to use cluster-robust standard errors

Methods

fit()

fit(X, y, entity_id) -> None
Fit the Fixed Effects model using within transformation.

Parameters: - X (np.ndarray): Training data matrix - y (np.ndarray): Target values - entity_id (np.ndarray): Entity identifiers for grouping

Requirements: - At least 2 observations per entity for within variation - n_samples > n_features + n_entities

predict()

predict(X, entity_id) -> np.ndarray
Generate predictions including entity fixed effects.

Statistical Methods

  • standard_errors() → Standard errors (clustered if robust=True)
  • t_statistics() → T-statistics for significance tests
  • p_values() → P-values for coefficient tests
  • confidence_intervals(alpha=0.05) → Confidence intervals
  • summary() → Comprehensive regression summary

Properties

Core Results: - coefficients: Fixed Effects regression coefficients - fixed_effects: Entity-specific fixed effects (α̂ᵢ) - robust: Whether clustered standard errors are used

Statistical Measures: - r_squared: Overall R-squared - within_r_squared: Within R-squared - r_squared_adj: Adjusted R-squared - mse: Mean squared error - residuals: Regression residuals

Model Information: - n_samples: Number of observations - n_features: Number of features - n_entities: Number of entities

Implementation Details

Within Transformation

  • Efficient entity mapping for demeaning
  • Vectorized computation of entity means
  • Memory-optimized transformation

Standard Errors

  • Classical: Assumes independence across entities
  • Clustered: Accounts for within-entity correlation

Usage Guidelines

Use FE when: - Panel data structure present - Entity-specific unobserved heterogeneity - Fixed effects may correlate with regressors - Focus on within-entity variation

Key Assumptions: - Strict exogeneity: \(E[\epsilon_{it}|\mathbf{x}_{i1}, \ldots, \mathbf{x}_{iT}, \alpha_i] = 0\) - Time-varying regressors available - Sufficient within-entity variation

Limitations: - Cannot estimate effects of time-invariant variables - Requires balanced or unbalanced panel structure - Need sufficient time periods per entity

Consider alternatives when: - Time-invariant regressors of interest → Random Effects - Cross-sectional data → OLS - Endogenous regressors → IV or TSLS

See Also

  • OLS - For cross-sectional data
  • GLS - For correlated error structures
  • IV - For endogenous regressors