Skip to content

DPredict · Guide test 225

Wooldridge test for panel serial correlation

Tests serial correlation of idiosyncratic errors in suitable panel regression models.

Runs in CodeSplashPython (calls R) example not runR example validated

Do it in CodeSplash

In the app, set it up in Analyze with this method:

Do it in CodeSplash Run this test on your own data, in Python or R.

Bench

Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.

Bench · Wooldridge test for panel serial correlation

15
6
0.50
1.0
0.00

Not 0: random effects are inconsistent, fixed effects are not.

0.00

A shock shared by every unit each period: cross-sectional dependence.

0.40

Errors carry φ × last period's error.

0.050

Your data

Simulated with known truth

15 units over 6 periods. Lines offset from each other are unit effects (SD of the unit means 1.01); lines that rise and fall together share a common shock; smooth runs within a line are serial correlation.

If H₀ were true

F = 2.84
  1. The reference: how F varies across samples when H₀ is true (cluster-robust F).
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .096).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

e^it=α+ρ e^i,t−1+vit,H0:ρ=−1T−1,F=(ρ^−ρ0SE⁡cl(ρ^))2\hat e_{it} = \alpha + \rho\,\hat e_{i,t-1} + v_{it},\qquad H_0: \rho = -\tfrac{1}{T-1},\qquad F = \Bigl(\dfrac{\hat\rho - \rho_0}{\operatorname{SE}_{cl}(\hat\rho)}\Bigr)^2

With your numbers

ρ^=(−0.0082),ρ0=(−0.20),F=2.84\hat\rho = (-0.0082),\quad \rho_0 = (-0.20),\quad F = 2.84
e^it\hat e_{it}
within (fixed-effects) residuals
−1T−1-\tfrac{1}{T-1}
their correlation under no serial correlation: demeaning induces it
SE⁡cl\operatorname{SE}_{cl}
unit-clustered standard error

The verdict

F(1, 73) = 2.84, p = .096

p > α = .050: compatible with H₀

Serial correlation leaves the FE estimate unbiased but its usual SEs too small; cluster by unit.

Statistic
2.843
p-value
0.0961
Wooldridge test for panel serial correlation on a balanced panel of 15 units × 6 periods: F(1, 73) = 2.84, p = .096. The p-value is above α = .050, so the data are compatible with H0.

Wooldridge test for panel serial correlation on a balanced panel of 15 units × 6 periods: F(1, 73) = 2.84, p = .096. The p-value is above α = .050, so the data are compatible with H₀.

Question and hypotheses

H0: no serial correlation in the idiosyncratic panel errors.

Assumptions

Independent clusters with enough clusters for cluster-robust inference; correctly specified panel mean and exogeneity assumptions.

Formula

Δu^it=δ Δu^i,t−1+vitH0:δ=−1/2\begin{gathered}\Delta\widehat u_{it}=\delta\,\Delta\widehat u_{i,t-1}+v_{it}\\[5pt] H_0:\delta=-1/2\end{gathered}

Parameters and notation

The displayed Wooldridge first-difference version exploits Corr(Δuit,Δui,t−1)=−1/2 under serially uncorrelated homoskedastic level errors. A within-residual version instead tests coefficient −1/(T−1) in a balanced panel.

Structure of the method

Fit the stated panel model, form the appropriate transformed residuals, regress residuals on their lags, and test the transformation-specific null coefficient with cluster-robust inference. First-difference and within-residual versions share a motivation but use different null restrictions and input model types.

Estimated and nuisance parameters

Estimate the panel mean coefficients, residuals, auxiliary autoregressive coefficient, and cluster-robust covariance. The within transformation induces correlation even when level errors are serially uncorrelated; its null coefficient is therefore not zero. In balanced first-difference reasoning, the familiar adjacent-error correlation is minus one half under the required variance conditions.

Settings and design choices

Choose first-difference versus within version, level-error versus differenced-error null, panel/time indexes, and robust covariance settings. The supplied pwartest code is the within-residual version; pwfdtest with h0="fe" targets no serial correlation in levels through the minus-one-half restriction.

Fitting and adaptation

Refit the mean model and regenerate residuals after changes in regressors or sample. Maintain panel lag alignment rather than treating rows as a single continuous series. There is no neural adaptation; the relevant adaptation is selecting a valid auxiliary regression and covariance for the panel design and cluster count.

Sensitivity and robustness

Inspect missing periods, unequal time lengths, few clusters, time-varying variance, exogeneity violations, and common cross-sectional shocks. Robust standard errors do not fix a wrongly specified auxiliary null. Report the implementation/version and restriction so readers can distinguish the within and first-difference calculations.

How to use and calibrate

Use the version’s cluster-robust Wald/F test; specify first-difference versus within-residual construction.

Example application

Check residual serial correlation in a fixed-effects panel model.

Interpretation and pitfalls

Watch out

Testing the transformed residual coefficient against zero is wrong for these procedures. Unequal T and heteroskedasticity require the appropriate version.

What changed in edition 2

  • New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.

Python and R

Wooldridge test using fixed-effects residuals. This is the pwartest variant; pwfdtest is a distinct first-difference formulation.

Python · invokes R

Not run — Executed end to end through Rscript · needs Python standard library + Rscript; R packages: plm

# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
    raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
set.seed(2026)
N<-20;TT<-25;d<-expand.grid(time=1:TT,id=1:N);d$x<-rnorm(nrow(d));a<-rnorm(N);d$y<-.5*d$x+a[d$id]+rnorm(nrow(d));pd<-plm::pdata.frame(d,index=c("id","time"))
fit<-plm::plm(y~x,pd,model="within");print(plm::pwartest(fit))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
                        text=True, capture_output=True)
print(result.stdout)
if result.stderr:
    print(result.stderr)
result.check_returncode()
R

Validated — Executed successfully in the validation environment · needs plm

set.seed(2026)
N<-20;TT<-25;d<-expand.grid(time=1:TT,id=1:N);d$x<-rnorm(nrow(d));a<-rnorm(N);d$y<-.5*d$x+a[d$id]+rnorm(nrow(d));pd<-plm::pdata.frame(d,index=c("id","time"))
fit<-plm::plm(y~x,pd,model="within");print(plm::pwartest(fit))
Output
	Wooldridge's test for serial correlation in FE panels

data:  fit
F = 0.12516, df1 = 1, df2 = 478, p-value = 0.7237
alternative hypothesis: serial correlation

Sources

Statistics guide v4 (historical):
Python: Executed end to end through Rscript · R: Executed successfully in the validation environment
Reference's record:
Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.

From the CodeSplash statistics guide (v4), entry 225, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT225.