DPredict · Guide test 002
Wald test
Tests parameter restrictions using estimated coefficients and their covariance; includes many familiar z, t, and chi square tests.
Do it in CodeSplash
In the app, set it up in Analyze with one of these methods:
- Generalized linear mixed model (logistic / Poisson) — How do predictors change a binary outcome or a count when rows are grouped (repeated measures, clusters)?
- Compare nested models (LR, Wald, score, partial F) — Do the added predictors improve the model significantly?
- Generalized estimating equations (GEE) — What is the population-average effect of predictors when rows are correlated within clusters?
- Logistic regression (binary outcome) — How do predictors change the odds of a yes/no outcome?
- Cox proportional hazards regression — Which factors are associated with the hazard of the event?
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
Adds curve × (x − 5)².
Error SD grows like exp(h · (x − 5)/5).
Errors in collection order carry φ × the previous error.
Your data
Simulated with a known ρIf H₀ were true
- The reference: how W varies across samples when H₀ is true.
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = < .001).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- estimated slope
- standard error with the maximum likelihood variance
- 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 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
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.
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>
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
- lmtest — lmtest · waldtestAuthor documentation/source reviewed: lmtest 0.9-40.search.r-project.org
- waldtestsearch.r-project.org
- 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.