statable Statistics for study and research

The same units over time? (Panel data, fixed and random effects)

In brief

With panel data the same unit is measured several times: a firm every year, a person in several surveys, a country over decades. That has an advantage and a problem. The advantage: you can compare each unit with itself and so take out everything that stays the same for it and was never measured (company culture, location). The problem: measurements of the same unit are not independent, ordinary standard errors are then too small.

The models at a glance

An example with real data

Grunfeld data: ten large US firms, 1935 to 1954 (200 observations). The investment (inv) is explained by the market value of the firm (value) and its capital stock (capital).

An example with real data
Modelb for valueb for capitalStandard error value (classical / cluster-robust)
Fixed effects0.11010.31010.0119 / 0.0152
Random effects0.10980.3081-
Pooled0.11560.23070.0058 / 0.0159
Between0.13460.0320-

When do I use it?

When the same units were measured several times and you want to know how changes in a feature go with changes in the outcome without unchanging differences between units getting in the way. Whoever only wants to describe the change of one unit over time uses repeated measures or the growth curve model; whoever compares people in groups (classes, schools) at one time point uses the multilevel model.

Requirements

How it works in Statable

  1. Open a file in which every row is one unit at one time point (for example firm and year in one column each) and run a question "Can something be predicted? (regression)".
  2. Under the result, at "Calculate differently", open "The same units over time? (panel data, fixed and random effects)". Ctrl+K: "panel data".
  3. Choose the column that identifies the unit (group identifier), the number to be explained and the features that change within a unit; then "Calculate panel".
  4. With "As R script with data (.zip)" you take the calculation with you; it needs only base R, no package.

For each feature the table shows all models one below the other, with classical and cluster-robust standard errors. The cluster-robust variance follows the formula of Stata and the R package sandwich (CR1: G/(G−1) · (N−1)/(N−k)); the R package plm uses only N/(N−k) for fixed effects and gets somewhat smaller standard errors. The p values of the cluster-robust errors use the t distribution with G − 1 degrees of freedom (G = number of units).

Reading and reporting the result

A panel regression of the investment of ten firms over 20 years (N = 200) with fixed effects gave b = 0.110 (cluster-robust SE = 0.015) for market value and b = 0.310 (cluster-robust SE = 0.053) for capital stock. The F test for firm effects was clear, F(9, 188) = 49.18, p < .001; the Hausman test showed no clear difference from random effects, χ²(2) = 2.33, p = .312.

Limits

What is often misunderstood

Sources

Croissant, Y. & Millo, G. (2008). Panel Data Econometrics in R: the plm Package. Journal of Statistical Software, 27(2) (open access). Cameron, A. C. & Miller, D. L. (2015). A Practitioner's Guide to Cluster-Robust Inference. Journal of Human Resources, 50(2), 317-372. Cunningham, S. Causal Inference: The Mixtape (mixtape.scunning.com, open access). Data: Grunfeld, Y. (1958), prepared in the R packages plm and AER (GPL).

Take away

  • Fixed effects compare each unit with itself; random effects also use the comparison between units but need an assumption that the Hausman test checks only roughly.
  • Measurements of the same unit are not independent: cluster-robust standard errors are part of it, and fewer than about 30 units make even them unreliable.
  • A feature that never changes within a unit cannot be estimated with fixed effects.
  • The panel also describes relationships; causes need a design (experiment, instrument, difference-in-differences) and good reasons.

Related

Open in Statable