4
$\begingroup$

I am running a multiple regression on simulated data in R. The sample size is 100. There is one relevant regressor and 18 irrelevant ones. I am testing the joint significance of the 18 irrelevant regressors using Newey-West covariance matrix.

Puzzle 1: I find the 18 irrelevant regressors to be highly statistically significant.
Puzzle 2: I get a test statistic of 6.8814 under 18 degrees of freedom which seems moderate to me (not far out in the right tail of the F(18, 80) distribution), so how come this yields a very low p-value of 4.5e-10?

I was able to figure out puzzle 1. Apparently, Newey-West is the problem. Using vanilla covariance matrix, the result is much more sensible. However, I am still at a loss w.r.t. puzzle 2, and that is my question.

library(car)
library(sandwich)

m <- 20
n <- 100
set.seed(9999)
x <- rnorm(m * n)
X <- matrix(x, ncol = m)
X[, 2] <- X[, 1] + X[, 2]
# Now the 2nd column is the 1st column + some noise,
# while all the other columns are pure noise.
# Thus, if we try to predict the 1st column, then only the 2nd column should be helpful.
m1 <- lm(X[, 1] ~ X[, -1])
(test <- linearHypothesis(
  model = m1,
  hypothesis.matrix = (diag(m)[-c(1:2), ]),
  rhs = rep(0, m - 2),
  test = "F",
  vcov. = NeweyWest(m1)
))

Result:

Linear hypothesis test

Hypothesis:


Model 1: restricted model
Model 2: X[, 1] ~ X[, -1]

Note: Coefficient covariance matrix supplied.

  Res.Df Df      F    Pr(>F)    
1     98                        
2     80 18 6.8814 4.494e-10 ***

Without the Newey-West:


(test <- linearHypothesis(
  model = m1,
  hypothesis.matrix = (diag(m)[-c(1:2), ]),
  rhs = rep(0, m - 2),
  test = "F"
))

Result:

Linear hypothesis test

Hypothesis:


Model 1: restricted model
Model 2: X[, 1] ~ X[, -1]

  Res.Df    RSS Df Sum of Sq      F Pr(>F)
1     98 38.856                           
2     80 31.982 18    6.8739 0.9552 0.5178

Edit 1: Thank you to Lukas Lohse for a good comment. When evaluating the size of the test statistic informally, I was thinking of the $\chi^2$ approximation to the $F$ distribution but forgot that I have to multiply the $F$ value by the numerator degrees of freedom (here, 18) to get the corresponding $\chi^2$ statistic... OK, so instead of puzzle 2 we now have a new puzzle 3: why does the test with Newey-West use 6.8 as the $F$-statistic and the one with vanilla variance estimator as the sum of squares.

Edit 2: It looks like puzzle 3 was based on a coincidence where the $F$-statistic and the sum of squares just happened to be close. Lukas Lohse has the answer.

$\endgroup$
6
  • 6
    $\begingroup$ An F-statistic of 6.8 is absolutely massive and has a p-value of $4.5\cdot 10^{-5}$ for $F(18, 80)$. The real question is why the test with Newey-West uses 6.8 as the F-statistic and the one without has it as the sum of squares. $\endgroup$ Commented Sep 24 at 21:54
  • $\begingroup$ @LukasLohse, good point, and stupid me. I have edited the post accordingly. $\endgroup$ Commented Sep 25 at 6:48
  • $\begingroup$ Just a shot at this stage, but maybe because the RSS version only works with the conventional variance estimate, cf. end of my answer here: stats.stackexchange.com/questions/258461/… $\endgroup$ Commented Sep 25 at 10:57
  • 1
    $\begingroup$ That both statistics differ fairly little will be because there is neither heteroskedasticity nor serial correlation in your data, so that the Newey-West correction does not have to do much $\endgroup$ Commented Sep 25 at 11:26
  • $\begingroup$ Also, the F-statistic is not "the" sum of squares then, but > (38.856-31.982)/31.982*(100-20)/18=0.9552596, right? $\endgroup$ Commented Sep 26 at 7:15

1 Answer 1

3
$\begingroup$

Ok, so I've looked at it quite a bit. I don't have a final answer but I think I'm calling it here.

I removed the real association from the data generation and added 2 additional robust variance estimators, HC3 and default HAC. What I found is that the F-statistic and the sum of squares being identical appears to have been a large coincidence but the robust variance estimators actually shrink the standard errors (I used lmtest::coeftest) by some degree and by extension inflate the F-statistic.

library(car)
library(sandwich)

m <- 20
n <- 100
set.seed(9999)
x <- rnorm(m * n)
X <- matrix(x, ncol = m)
y <- rnorm(n) 
m1 <- lm(y ~ X)

linearHypothesis(
  model = m1,
  hypothesis.matrix = (diag(m+1)[-1,]),
  rhs = rep(0, m),
  test = "F"
) # F = 1.4 (Sum of Sq = 29.3)

linearHypothesis(
  model = m1,
  hypothesis.matrix = (diag(m+1)[-1,]),
  rhs = rep(0, m),
  test = "F",
  vcov. = hccm(m1, type = "hc3")
)# F = 1.8

linearHypothesis(
  model = m1,
  hypothesis.matrix = (diag(m+1)[-1,]),
  rhs = rep(0, m),
  test = "F",
  vcov. = vcovHAC(m1)
)# F = 2.5

linearHypothesis(
  model = m1,
  hypothesis.matrix = (diag(m+1)[-1,]),
  rhs = rep(0, m),
  test = "F",
  vcov. = NeweyWest(m1),
  verbose = F
)# F = 5.5


library(lmtest)
coeftest(m1)
coeftest(m1, vcov.=NeweyWest(m1))
se_lm <- coeftest(m1)[, 2]
se_hc <- coeftest(m1, vcov.=vcovHAC(m1))[, 2]
se_nw <- coeftest(m1, vcov.=NeweyWest(m1))[, 2]
plot(se_lm, se_nw, ylim = c(0.05, 0.2))
points(se_lm, se_hc, col = 2)
abline(0,1)

hist(se_nw/se_lm)

Histogram of standard error ratios. centered at about 0.85

I also ran 500 simulations and produced this plot of the F-statistics with the 4 methods. We can clearly see that Newey West is by far the worst offender, but they all inflate. The picture is much more extreme if we set m = 30.

enter image description here

What's going on?

The only thing I could find is this: https://stats.stackexchange.com/a/590851/341520

Apparently for small samples (our example has about 5 observations per coefficient) robust standard errors can substantially underestimate. Sadly I don't really understand the paper linked in the other answer.

Code for 2nd image

m <- 20
n <- 100
# ~ 1 minute run time
dat <- t(replicate(500, {
  x <- rnorm(m * n)
  X <- matrix(x, ncol = m)
  y <- rnorm(n) 
  m1 <- lm(y ~ X)
  f0_ols <- linearHypothesis(
    model = m1,
    hypothesis.matrix = (diag(m+1)[-1,]),
    rhs = rep(0, m),
    test = "F"
  )$F[2]
  
  f1_hc3 <- linearHypothesis(
    model = m1,
    hypothesis.matrix = (diag(m+1)[-1,]),
    rhs = rep(0, m),
    test = "F",
    vcov. = hccm(m1, type = "hc3")
  )$F[2]
  
  f2_hac <- linearHypothesis(
    model = m1,
    hypothesis.matrix = (diag(m+1)[-1,]),
    rhs = rep(0, m),
    test = "F",
    vcov. = vcovHAC(m1)
  )$F[2]
  
  f3_nw <- linearHypothesis(
    model = m1,
    hypothesis.matrix = (diag(m+1)[-1,]),
    rhs = rep(0, m),
    test = "F",
    vcov. = NeweyWest(m1),
    verbose = F
  )$F[2]
  c(f0_ols = f0_ols, f1_hc3 = f1_hc3, f2_hac = f2_hac, f3_nw = f3_nw)
}))

#dat 
library(tidyverse)
dat %>% 
  data.frame() %>% 
  rowid_to_column() %>% 
  pivot_longer(cols = -1) %>% 
  ggplot(aes(x = name, y = value)) +
  geom_path(aes(group = rowid), alpha = 0.5) +
  geom_boxplot(alpha = 0.75) +
  geom_hline(yintercept = qf(0.95, 20, 79), col = 2) +
  scale_y_log10()
$\endgroup$
7
  • $\begingroup$ +1. To investigate whether the small sample bias of the robust standard errors are the culprit, you could redo the simulations using the dfadjust package, which promises to adjust for the bias. $\endgroup$ Commented Sep 25 at 21:04
  • $\begingroup$ Let me see if I got you right. The only problem here is that Newey-West severely underestimates the standard errors (by about $\sqrt{18}$ fold in my example)? And that the sum of squares (under vanilla variance estimator) approximately equaling the $F$ statistic under Newey-West is a coincidence (and an example of how severe the underestimation can be, here $18$ fold)? $\endgroup$ Commented Sep 26 at 5:47
  • $\begingroup$ @RichardHardy where are you getting 18 from? Individual standard errors are about 0.85 of the OLS estimate and this, somehow and also including the covariances, combines over 20 estimators to an 5-fold increase in F-statistic, although this has a lot of spread on the log-scale. To see that 6.8 was a coincidence rerun your code with seed 9998. $\endgroup$ Commented Sep 26 at 6:55
  • $\begingroup$ I am asking about my particular example just to have concrete numbers to work with. Since the sum of squares is about equal the F-stat in my case, and since there are 18 degrees of freedom, does that not mean an 18-fold ratio of vanilla vs. NeweyWest variances? $\endgroup$ Commented Sep 26 at 6:59
  • $\begingroup$ At least (unlike in the present DGP) when there actually is heteroskedasticity, conventional wisdom has it that the robust s.e.s typically (although not necessarily, see e.g. stats.stackexchange.com/questions/627057/…) are larger to correct upward size distortions of conventional s.e. estimators. E.g., sciencedirect.com/science/article/abs/pii/0304407685901587 should have discussion. $\endgroup$ Commented Sep 26 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.