How to Perform a Wald Test in R

A Wald test can be used to test if one or more parameters in a model are equal to certain values.

This test is often used to determine if one or more predictor variables in a regression model are equal to zero.

We use the following null and alternative hypotheses for this test:

  • H0: Some set of predictor variables are all equal to zero.
  • HA: Not all predictor variables in the set are equal to zero.

If we fail to reject the null hypothesis, then we can drop the specified set of predictor variables from the model because they don’t offer a statistically significant improvement in the fit of the model.

The following example shows how to perform a Wald test in R.

Example: Wald Test in R

For this example, we’ll use the built-in mtcars dataset in R to fit the following multiple linear regression model:

mpg  = β0 + β1disp + β2carb + β3hp + β4cyl

The following code shows how to fit this regression model and view the model summary:

#fit regression model
model <- lm(mpg ~ disp + carb + hp + cyl, data = mtcars)

#view model summary

lm(formula = mpg ~ disp + carb + hp + cyl, data = mtcars)

    Min      1Q  Median      3Q     Max 
-5.0761 -1.5752 -0.2051  1.0745  6.3047 

             Estimate Std. Error t value Pr(>|t|)    
(Intercept) 34.021595   2.523397  13.482 1.65e-13 ***
disp        -0.026906   0.011309  -2.379   0.0247 *  
carb        -0.926863   0.578882  -1.601   0.1210    
hp           0.009349   0.020701   0.452   0.6551    
cyl         -1.048523   0.783910  -1.338   0.1922    
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 2.973 on 27 degrees of freedom
Multiple R-squared:  0.788,	Adjusted R-squared:  0.7566 
F-statistic: 25.09 on 4 and 27 DF,  p-value: 9.354e-09

Next, we can use the wald.test() function from the aod package to test if the regression coefficients for the predictor variables “hp” and “cyl” are both equal to zero.

This function uses the following basic syntax:

wald.test(Sigma, b, Terms)


  • Sigma: The variance-covariance matrix of the regression model
  • b: A vector of regression coefficients from the model
  • Terms: A vector that specifies which coefficients to test

The following code shows how to use this function in practice:


#perform Wald Test to determine if 3rd and 4th predictor variables are both zero
wald.test(Sigma = vcov(model), b = coef(model), Terms = 3:4)

Wald test:

Chi-squared test:
X2 = 3.6, df = 2, P(> X2) = 0.16

From the output we can see that the p-value of the test is 0.16.

Since this p-value is not less than .05, we fail to reject the null hypothesis of the Wald test.

This means we can assume the regression coefficients for the predictor variables “hp” and “cyl” are both equal to zero.

We can drop these terms from the model since they don’t statistically significantly improve the overall fit of the model.

Additional Resources

The following tutorials explain how to perform other common operations in R:

How to Perform Simple Linear Regression in R
How to Perform Multiple Linear Regression in R
How to Interpret Regression Output in R
How to Calculate Variance Inflation Factor (VIF) in R

3 Replies to “How to Perform a Wald Test in R”

  1. I think wald.test uses the intercept as the first term. In that case, the terms should be specified as “Terms = 4:5” and not “Terms = 3:4”.

  2. Hey Zach,

    Thanks for the write-up. I noticed that you say that you want to test if “hp” and “cyl” are both equal to zero, but the code example uses Terms = 3:4 which would be “carb” and “hp” from the lm output.

Leave a Reply

Your email address will not be published. Required fields are marked *