Bayesian Fixed Effects Model

Econometrics
Introduced by
Chib (2008); Lancaster (2000)
Year
2000–2008
Type
Bayesian panel regression
Family
Econometrics / time series

What does it do?

The Bayesian fixed effects model applies Bayesian inference to a panel regression with unit-specific intercepts that absorb time-invariant unobserved differences between units.

Priors are placed on the slopes, the error precision and the intercepts, so the output is a posterior distribution over all parameters rather than point estimates with asymptotic standard errors. As specified in the mechanics, the unit intercepts carry a hierarchical normal prior and are shrunk toward a common mean. The specification is therefore a hierarchical intercept model, not one with unrestricted fixed intercepts, and the intercept prior must be read as part of the model.

The intuition behind the method

In a classical fixed effects model, each unit (a firm, country or person) receives its own intercept, which absorbs everything about that unit that does not change over time. The Bayesian version keeps this structure but adds prior beliefs about the slopes, the error variance and the intercepts, and updates them with the data using Bayes' theorem. The result is a posterior distribution for each coefficient, from which credible intervals and direct probability statements can be read. Because the joint posterior rarely has a closed form when there are many unit intercepts, it is usually explored with MCMC samplers.

History

The classical fixed effects estimator is part of the older panel econometrics literature. Lancaster (2000) reviews the incidental parameter problem, which arises when the number of unit intercepts grows with the number of units, across the period named in its title, which begins in 1948. Chib (2008) provides a Bayesian primer for panel data models that covers fixed and random effects specifications.

When to use it

Choose this model for panel data with repeated observations on the same units when you suspect time-invariant unobserved differences that would bias a pooled estimator, and you want the full posterior distribution of the coefficients. It is useful when you have genuine prior information about the slopes, or when the sample is small enough that asymptotic inference is unreliable. The shrinkage on the intercepts matters most in short panels, where the classical within estimator is less efficient. Do not use it when your main question concerns time-invariant covariates, because the data alone cannot identify their effects in this specification. It is also a poor default when the panel has very many units and MCMC over all intercepts is too slow; in that case a Bayesian random effects model, or an approach that integrates out the intercepts analytically, may be more practical. The identifying assumption is strict exogeneity: conditional on the unit effects, the regressors are uncorrelated with the errors in every period. The model does not handle lagged outcomes or endogenous regressors without further extension.

Limitations and considerations

  • Each unit intercept is a parameter that must be sampled or integrated out, so computation grows with the number of units and MCMC over a large panel can be slow.
  • In very short panels the data carry little information about each intercept, so results depend heavily on the intercept prior and on the hyperparameter tau squared, which has no prior of its own in the given specification.
  • Time-invariant covariates cannot be estimated from within-unit variation. In this specification their coefficients would be informed mainly by the form of the intercept prior rather than by the data, so such estimates should be treated with caution.
  • Model comparison relies on DIC or Bayes factors rather than the F-tests of classical panel analysis, which applied researchers may find less familiar.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Gives a full posterior distribution for each slope, so credible intervals and direct probability statements do not depend on asymptotic approximations.
  • The hierarchical normal prior on the unit intercepts shrinks them toward a common mean, which can stabilise intercept estimates in short panels where maximum likelihood with one parameter per unit is fragile.
  • Prior information from earlier studies can be entered through the prior on the slopes and the error precision.
  • Parameter uncertainty carries into posterior predictive distributions, so predictive intervals reflect estimation uncertainty and not only the error term.
  • The likelihood is written over the observed unit-period pairs, so unbalanced panels can be handled without changing the model structure.

Applications

  • Estimating wage equations with individual fixed effects while allowing full uncertainty quantification over returns to education or experience.
  • Analysing firm-level panel data on investment, productivity, or leverage when time-invariant firm characteristics must be controlled.
  • Macroeconomic country-panel studies (e.g., growth regressions) where short T makes classical fixed effects fragile and priors can incorporate cross-country knowledge.
  • Health economics panels tracking individual patients across periods where unobserved heterogeneity is large and small-sample credible intervals are needed.
  • Policy evaluation in short administrative panels where prior information from programme literature can be incorporated formally.

How it works

How it works

1

The outcome for unit i at time t is a unit intercept alpha_i plus the linear predictor x_it times beta, plus a normally distributed error with variance sigma squared. Because each unit has its own intercept, the slopes are informed mainly by variation within units over time, while differences between units are absorbed by the intercepts.

Formula
y_{it} = \alpha_i + x_{it}^{\top}\beta + \varepsilon_{it}, \quad \varepsilon_{it} \sim N(0,\sigma^2)
2

The slopes receive a normal prior centred at b_0 with covariance B_0, the error precision receives a gamma prior with parameters a_0 and s_0, and each unit intercept receives a normal prior centred at zero with variance tau squared. Because this intercept prior is hierarchical in form, it shrinks the unit intercepts toward zero and shares information across units. The hyperparameter tau squared has no prior of its own in the given specification, so it is treated as fixed.

Formula
\beta \sim N(b_0, B_0),\; \sigma^{-2} \sim \text{Gamma}(a_0/2, a_0 s_0/2),\; \alpha_i \sim N(0, \tau^2)
3

The joint posterior of the slopes, intercepts and error variance is proportional to the likelihood multiplied by the priors. Bayes' theorem combines the prior beliefs with the observations from all units and periods.

Formula
p(\beta, \{\alpha_i\}, \sigma^2 \mid y) \propto p(y \mid \beta, \{\alpha_i\}, \sigma^2)\, p(\beta)\, p(\sigma^2)\, \prod_i p(\alpha_i)
4

The joint posterior is generally not available in closed form when there are many unit intercepts, so Markov chain Monte Carlo methods such as Gibbs sampling or Hamiltonian Monte Carlo are used to draw samples from it. Each draw is one plausible set of slopes, intercepts and error variance, and the draws together approximate the posterior.

5

Posterior means, medians and credible intervals replace classical point estimates and confidence intervals. Model comparison can use the Deviance Information Criterion (DIC) or Bayes factors, subject to the caveats given in the FAQ, and posterior predictive checks assess fit.

Common pitfalls

  • Using diffuse priors on the unit intercepts in short panels can leave the posterior nearly non-identified for those intercepts; weakly informative or hierarchical priors are more stable.
  • Accepting MCMC output without checking convergence. Inspect trace plots, confirm Gelman-Rubin R-hat values close to 1 for all parameters, check effective sample size for the slopes and for the intercepts separately, confirm zero divergent transitions when Hamiltonian Monte Carlo is used, and test whether results hold under alternative values of the intercept prior scale tau.
  • Describing the intercepts as unrestricted fixed effects while the specification gives them a hierarchical normal prior that shrinks them toward a common mean. The prior and the interpretation of the intercepts must match, and the reported model should state which structure is used.
  • Integrating out the unit intercepts analytically (a marginal likelihood approach) reduces the dimension of the sampler and can make inference on the slopes simpler and faster, but it changes what is being sampled, so the reported summaries must match the chosen approach.

Frequently asked questions

What is the incidental parameter problem and how does the Bayesian approach address it?

Each unit adds an intercept, so the number of parameters grows with the number of units. The problem mainly affects estimation of the error variance and nonlinear or dynamic models, and in the linear static case the slope estimates are less affected. A hierarchical prior on the intercepts shrinks them toward a common mean and can stabilise them in short panels. Because the shrinkage changes the estimator, the prior on the intercepts can move the slope estimates in short panels, so its specification should be checked with a sensitivity analysis.

Can I identify time-invariant covariates in a Bayesian fixed effects model?

Not from the data alone. A time-invariant covariate is collinear with the unit intercepts within each unit, so its coefficient is informed only by the structure of the intercept prior. If you need to estimate effects of time-invariant regressors, consider a Bayesian random effects model or a Mundlak-type correlated random effects specification, and state clearly which assumptions drive the estimate.

How do I choose between Bayesian fixed effects and Bayesian random effects?

If unit effects are plausibly correlated with the regressors, a fixed effects specification is the safer choice, because a random effects specification assumes they are not. You can compare the two models on the same data using DIC or Bayes factors, but both criteria depend on the prior and on how latent intercepts are counted, and neither confirms the identifying assumption. In the classical framework, a Hausman-type or Mundlak test can assess whether unit effects correlate with the regressors.

How many MCMC iterations are needed, and how do I know the chains have converged?

The required chain length depends on the number of units, the number of slopes and how strongly the parameters are correlated. Run several chains from dispersed starting values, discard an initial burn-in, and check convergence with trace plots, Gelman-Rubin R-hat values close to 1 for all parameters, and effective sample size for the slopes and the intercepts separately. For Hamiltonian Monte Carlo, confirm there are no divergent transitions. Panels with many units usually need longer chains.

What software can estimate a Bayesian fixed effects panel model?

In R, Stan (through rstan or cmdstanr) and JAGS (through rjags) can specify the full model. The bayesm and rstanarm packages offer more automated interfaces, and PyMC supports hierarchical panel specifications in Python.

Related methods

Sources

  1. Lancaster, T. (2000). The incidental parameter problem since 1948. Journal of Econometrics, 95(2), 391–413.

    Open DOI reference
  2. Chib, S. (2008). Panel data modeling and inference: A Bayesian primer. In L. Mátyás & P. Sevestre (Eds.), The Econometrics of Panel Data (3rd ed., pp. 479–515). Springer.

    Open DOI reference