# Doing a Wald Test in R

One way to test whether the coefficients on a group of regressors are all equal to zero is to do a Wald test comparing the fit of the larger model (with all regressors) against the fit of the smaller model (where the regressors with zero coefficients have been omitted).

Let's generate data on the dependent variable:

set.seed(500)
y <- ts(rnorm(500))

And three regressors:

x1 <- ts(rnorm(500))
x2 <- ts(rnorm(500))
x3 <- ts(rnorm(500))

The model is $y_{t} = \beta_{0} + \beta_{1} x_{1t} + \beta_{2} x_{2t} + \beta_{3t} x_{3t} + \varepsilon_{t}$ and the hypothesis of interest is $H_{0}: \beta_{2} = \beta_{3} = 0.$

Estimate the unrestricted and restricted models:

library(tstools)
fit.unrestricted <- tsreg(y, ts.intersect(x1, x2, x3))
fit.restricted <- tsreg(y, x1)

Do the Wald test:

library(lmtest)
waldtest(fit.unrestricted, fit.restricted)

The output is

Wald test

Model 1: lhs ~ rhs
Model 2: lhs ~ rhs
Res.Df Df      F Pr(>F)
1    496
2    498 -2 0.8449 0.4302

As expected (given that we generated the regressors to be independent of $$y$$) the p-value is 0.43, so we don't reject $$H_{0}$$.

If there is a concern about heteroskedasticity or serial correlation, you can set the vcov parameter to be a function to use to extract the covariance matrix, for instance the NeweyWest function in the sandwich package:

library(sandwich)
waldtest(fit.unrestricted, fit.restricted, vcov=NeweyWest)

Because we know there is no issue with heteroskedasticity or serial correlation in the residuals of our regression, we don't expect the correction to have much effect in this example, and it doesn't:

Wald test

Model 1: lhs ~ rhs
Model 2: lhs ~ rhs
Res.Df Df      F Pr(>F)
1    496
2    498 -2 0.8539 0.4264

Index    Home