Skip to main content
1 of 13
Christoph Hanck
  • 34.8k
  • 3
  • 78
  • 137

Preliminary/partial answer:

In linear models, when using the chi-square version of the Wald test, it is nearly the case for large $n$. For the F-test version it is not true but requires (which is precisely what the chi-square version does) multiplication with a correction for the number of hypotheses tested.

I conjecture that remaining differences stem from different ways of estimating the error variances as e.g. discussed in the links. (So to return to your purpose of validating code, "close" is maybe too vague to be helpful.)

library(lmtest)
library(sandwich)

n <- 3000
X1 <- rnorm(n)
X2 <- rnorm(n)
y <- rnorm(n)

M0 <- lm(y~1)
M1 <- lm(y~X1)
M2 <- lm(y~X1+X2)

Wald.M1M0 <- waldtest(M1,M0)$F[2]
Wald.M2M1 <- waldtest(M2,M1)$F[2]
Wald.M2M0 <- waldtest(M2,M0)$F[2]

Wald.M2M0
Wald.M1M0 + Wald.M2M1 # only close if we multiply the previous line by 2

LR.M1M0 <- lrtest(M1,M0)$Chisq[2]
LR.M2M1 <- lrtest(M2,M1)$Chisq[2]
LR.M2M0 <- lrtest(M2,M0)$Chisq[2]

LR.M2M0
LR.M1M0 + LR.M2M1 # the same

Wald.M1M0 <- waldtest(M1,M0, test="Chisq")$Chisq[2]
Wald.M2M1 <- waldtest(M2,M1, test="Chisq")$Chisq[2]
Wald.M2M0 <- waldtest(M2,M0, test="Chisq")$Chisq[2]

Wald.M2M0
Wald.M1M0 + Wald.M2M1 # close
Christoph Hanck
  • 34.8k
  • 3
  • 78
  • 137