Skip to content

DPredict · Guide test 002

Wald test

Tests parameter restrictions using estimated coefficients and their covariance; includes many familiar z, t, and chi square tests.

Runs in CodeSplashPython example validatedR example validated

Do it in CodeSplash

In the app, set it up in Analyze with one of these methods:

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 · Wald test

40
0.25
0.000

Adds curve × (x − 5)².

0.00

Error SD grows like exp(h · (x − 5)/5).

0.00

Errors in collection order carry φ × the previous error.

0.00
0.050

Your data

Simulated with a known ρ

If H₀ were true

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

The formula

W=(β^1se^ML)2=n(RSS0−RSS1)RSS1∼χ12W = \left(\dfrac{\hat\beta_1}{\widehat{\mathrm{se}}_{\mathrm{ML}}}\right)^{2} = \dfrac{n(\mathrm{RSS}_0-\mathrm{RSS}_1)}{\mathrm{RSS}_1} \sim \chi^2_1

With your numbers

W=40 (64.12−44.28)44.28=17.92W = \dfrac{40\,(64.12-44.28)}{44.28} = 17.92
β^1\hat\beta_1
estimated slope
se^ML\widehat{\mathrm{se}}_{\mathrm{ML}}
standard error with the maximum likelihood variance
RSS\mathrm{RSS}
residual sum of squares

The verdict

W(1) = 17.92, p < .001

p ≤ α = .050: reject H₀

The Wald test only needs the fitted (unrestricted) model. It is the largest of the three classical statistics, so it rejects most readily in small samples.

Statistic
17.922
p-value
0.0000
Wald test on 40 (x, y) pairs: W(1) = 17.92, p < .001. The p-value is below α = .050, so the data are hard to reconcile with H0.

Wald test on 40 (x, y) pairs: W(1) = 17.92, p < .001. The p-value is below α = .050, so the data are hard to reconcile with H₀.

Question and hypotheses

H0: g(θ)=0 for q restrictions; H1: at least one restriction fails.

Assumptions

An approximately normal parameter estimator and a consistent covariance estimate are required. Restrictions must be differentiable and locally independent. Robust covariance estimates need the corresponding sample or cluster asymptotics.

Formula

W=g(θ^)T[GV^GT]−1g(θ^)≈χq2,G=∂g∂θT∣θ^W=g(\widehat\theta)^T[G\widehat V G^T]^{-1}g(\widehat\theta)\approx\chi^2_q,\qquad G=\left.\frac{\partial g}{\partial\theta^T}\right|_{\widehat\theta}

Parameters and notation

V̂ estimates Var(θ̂), including its sample size scaling; G is the restriction Jacobian. For linear restrictions, g(θ)=Rθ−r.

Structure of the method

Fit the unrestricted model, evaluate the restriction vector, and form its covariance with the restriction Jacobian. Solve the corresponding quadratic form using numerically stable linear algebra. Independent restriction rank determines the chi-square degrees of freedom; an exact linear-model F version uses a different finite-sample reference.

Estimated and nuisance parameters

Estimated quantities are the unrestricted parameter vector and its covariance, including nuisance scale and any covariance-estimation corrections. The Jacobian is evaluated at the fit. The contrast matrix and target values define the scientific hypothesis and are fixed design inputs, not fitted coefficients.

Settings and design choices

Prespecify contrasts, sidedness for a single signed contrast, covariance type, clustering unit if relevant, and multiplicity family. Choosing HC, HAC, or cluster covariance changes the asymptotic justification; bandwidths and small-cluster corrections are inferential choices requiring documented sensitivity, not universal defaults.

Fitting and adaptation

Refit after modifying the mean model or data transformation and recompute the full restriction covariance. Warm starts affect optimization only. If contrasts were chosen after variable selection, ordinary Wald calibration does not account for that selection; use an independently justified post-selection procedure or independent confirmation.

Sensitivity and robustness

Near-boundary estimates and nonlinear reparameterizations can produce unstable small-sample results. Singular restriction covariance signals redundant or unidentified restrictions rather than permission to invert arbitrarily. Few clusters can make cluster-robust chi-square inference unreliable even with many rows; report effects and intervals as well as the joint test.

How to use and calibrate

Fit the unrestricted model. Evaluate restrictions and their covariance. Use the upper χ²q tail, or the model justified finite sample F/t reference. Report the estimated contrasts and confidence intervals.

Example application

In a regression, jointly test two slopes equal zero using the two coefficient estimates and their 2×2 covariance submatrix.

Interpretation and pitfalls

Watch out

Wald statistics can depend strongly on parameterization in small samples and behave poorly near boundaries or separation. Counting every application as a different test would count the same framework repeatedly.

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

Tests the added coefficient; the usual covariance assumes homoskedastic independent errors.

Python · native

Validated — Executed successfully in the validation environment · needs numpy, scipy, statsmodels

import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
import statsmodels.api as sm
n=100
x=rng.normal(size=n); z=rng.normal(size=n); y=1+.5*x+.3*z+rng.normal(size=n)
X=sm.add_constant(np.column_stack([x,z])); fit=sm.OLS(y,X).fit(); reduced=sm.OLS(y,X[:,:2]).fit()
print(fit.wald_test("x2 = 0",use_f=False,scalar=True))
Output
<Wald test (chi2): statistic=5.342011272107058, p-value=0.020817441357637197, df_denom=1>
R

Validated — Executed successfully in the validation environment · needs lmtest

set.seed(2026)
n <- 100; x <- rnorm(n); z <- rnorm(n); y <- 1+.5*x+.3*z+rnorm(n)
d <- data.frame(y,x,z); fit <- lm(y~x+z,data=d); reduced <- lm(y~x,data=d)
print(lmtest::waldtest(fit,reduced,test="Chisq"))
Output
Wald test

Model 1: y ~ x + z
Model 2: y ~ x
  Res.Df Df  Chisq Pr(>Chisq)    
1     97                         
2     98 -1 14.218  0.0001628 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Sources

Statistics guide v4 (historical):
Python: Executed successfully in the validation environment · R: Executed successfully in the validation environment
Reference's record:
Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Unavailable local dependencies: statsmodels. Python: Not run in the reference's review: Unavailable local dependencies: statsmodels. No installation attempted. R: Reviewed but not run: R wasn't available to the reference's authors.

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