Panel Regression

Analyze → Regression → Panel Regression. For panel (longitudinal) data — the same entities (firms, patients, countries, stores) observed repeatedly over time. Repeated observations are an opportunity, not just a nuisance: each entity can serve as its own control, so effects can be estimated from within-entity variation alone, sweeping out everything about an entity that never changes — measured or not.

That identification strategy is what distinguishes this procedure from adding entity dummies to an ordinary regression by hand, and from the Linear Mixed Model, which overlaps statistically but frames its output around variance components rather than the fixed-/random-effects choice econometrics expects.

The data layout

Panel data is entered in long format — one row per entity-period, with the identifiers as ordinary columns:

firm year invest value capital
GM 1935 317.6 3078.5 2.8
GM 1936 391.8 4661.7 52.6
US Steel 1935 209.9 1362.4 53.8
  • Entity — which unit the row belongs to. Numeric or string; every row needs one.
  • Time (optional) — the period. When given, a duplicate entity-time pair stops the analysis with a message (it almost always means a data problem). Without it, rows are taken in dataset order within each entity.
  • Dependent and Regressors — ordinary numeric variables.

Unbalanced panels (entities with different numbers of periods) are supported; the output's entity and period counts show what was actually estimated — dropped rows change the counts, never silently shrink the estimate.

Choosing an estimator

  • Fixed effects (within) — the default. Each variable is demeaned by its entity mean and OLS runs on the deviations, which is equivalent to giving every entity its own intercept. Anything constant within an entity — industry, sex, an unmeasured "management quality" — is swept out, so FE is robust to time-invariant confounding, but it also cannot estimate the effect of a time-invariant regressor (the procedure stops with a message naming it).
  • Random effects (GLS) — treats the entity effect as a random draw uncorrelated with the regressors. More efficient than FE when that assumption holds, and it can estimate time-invariant regressors — but if the entity effect is correlated with a regressor, RE is biased. The reported θ shows how far toward FE the GLS transformation sat (θ = 0 is pooled OLS, θ → 1 is FE).
  • Pooled OLS — ignores the panel structure entirely; the baseline the other two are compared against.

Standard errors: Conventional, or Clustered by entity — robust to arbitrary within-entity correlation over time, the usual default in applied panel work whenever T is more than a couple of periods.

The Hausman test — what it does and does not tell you

Whenever both FE and RE can be fitted, a Hausman Test table compares their slope estimates. Under the null hypothesis the entity effect is uncorrelated with the regressors, so FE and RE both estimate the same thing and RE is the efficient choice; a small p-value says their estimates differ by more than sampling noise — evidence the RE assumption fails, so use fixed effects.

What it does not tell you: a large p-value does not prove RE is valid (it may simply lack power), and the test says nothing about time-varying confounding, which neither estimator fixes. In finite samples the statistic can come out negative — a failure of the test's conditions, reported as computed with a note rather than hidden — and a negative H does not reject random effects.

Reading the output

  • Fixed Effects / Random Effects / Pooled OLS Coefficients — the chosen estimator's slopes with SEs, t, p and confidence intervals. The table note names the SE type and the degrees of freedom.
  • Model Summary — the econometrics vocabulary: N (observations), n (entities), T min / mean / max, and the three R²s. For RE it adds σ_u (entity-effect SD), σ_e (idiosyncratic SD), ρ (the share of variance due to entities) and θ.
  • Estimator Comparison — all three estimators side by side with conventional SEs, so a coefficient's sensitivity to the choice is visible at a glance. An estimator that could not be fitted is named in the note.
  • Hausman Test — see above.

Within, between and overall R²

The most common misreading of panel output is treating the three R²s as one number:

  • R² within — how well the model explains variation inside entities over time (on the demeaned data). This is the number FE actually maximizes, and the one to quote for a within identification strategy.
  • R² between — how well it explains differences across entity means.
  • R² overall — on the raw data, mixing the two.

A model can have a high within R² and a near-zero between R² (or vice versa); which one matters depends on which variation answers your question.

The conventions behind the numbers

Panel estimators differ across packages in ways that change every standard error, so the choices are stated here (and pinned against the reference package in the validation suite):

  • RE variance components: Swamy–Arora, the common default (xtreg, re, plm, linearmodels), with the harmonic mean T̄ on unbalanced panels.
  • FE degrees of freedom: the n − 1 absorbed entity effects are charged against the residual df (df = N − n − K), matching Stata's xtreg, fe. The intercept is the grand-mean constant, Stata-style.
  • Cluster-robust small-sample factor: xtreg's G/(G−1) · (N−1)/(N−K), which does not charge the absorbed entity effects — Stata's areg does, and reports larger SEs for the same model.
  • Hausman: the classic form on conventional covariances, slopes only.
  • Inference is t on the residual df for all three estimators, and the R²s are the 1 − SSR/TSS family (Stata defines between/overall R² as squared correlations, which differ).

If your numbers disagree with another package, check its conventions on these points before suspecting the data.

Weighting. Computed unweighted by design: a frequency weight replicates cases, and no reference package defines the within/GLS transformations under that reading — an active Weight Cases variable only selects cases, and the output says so. Select Cases and Split File are honored.

Scope (v1). One-way (entity) effects, balanced or unbalanced panels. No two-way effects, no dynamic panels (Arellano–Bond), no Driscoll–Kraay or two-way clustered SEs, no between estimator or first differences.