When using modelsummary and clustered SEs via the vcov argument with a glm model, I get the following error:
The `lmtest::coeftest` function does not seem to produce complete results when
applied to a model of class glm. Only the standard errors have been adjusted. p
values and confidence intervals may not be correct.
And as the error says, in the resulting table only the SEs have been corrected. The significance stars (*, **, etc), which I presume are calculated from the p-values, are not.
MWE:
library(modelsummary)
df = data.frame(
outcome = rbinom(1000, 1, 0.2),
cov1 = rnorm(1000),
cov2 = rnorm(1000),
cat = rep(c("A", "B", "C", "D", "E"), each = 200))
modellist = list(
glm(outcome ~ cov1 + factor(cat), data = df, family = "binomial"),
glm(outcome ~ cov1 + cov2 + factor(cat), data = df, family = "binomial"))
modelsummary(models = modellist, estimate = "{estimate}{stars}", vcov = ~cat)
modelsummary(models = modellist, estimate = "{estimate}{stars}")
Is there any workaround to present the correct stars using the adjusted SEs in this case?
EDIT (solution):
It turns out that, at least when uploading to R 4.x.x, the lmtest package needs to be installed independently of modelsummary. Once that it's done, the issue disappears.