I'm trying to 1. get stargazer output to show the correct standard errors and show the right significance (stars); 2. to add robust F-statistics (from linearHypothesis).
Problem 1:
The significance stars are not right. If you compare r_mod1
with the output from stargazer, you will notice that r_mod1
has only 1 star for the marriedyes-variable, but the stargazer output shows two stars.
Problem 2: I don't know how to get the robust F-statistics. Iv'e read that you have to do it manually somewhere, because stargazer doesn't have the functionality to do this. Is this true? It seems like a kinda basic limitation for such a well developed package as stargazer.
Any help would be much appreciated!
My code:
# Libraries
library(tidyverse)
library(Ecdat)
library(lmtest)
library(sandwich)
library(stargazer)
library(car)
# Get data from Ecdat
data(Wages)
wages <- Wages
rm(Wages)
# A sample model
mod1 <- lm(lwage ~ ed + exp + I(exp^2) + wks + bluecol + ind +
south + smsa + married + sex + union + black,
data = wages)
# Robust standard errors
r_mod1 <- coeftest(mod1,vcov=(vcovHC(mod1,"HC1")))
# Robust F-stats
lh1 <- linearHypothesis(mod1,names(coef(mod1))[-1], white.adjust = T)
# Extract robust values
se1 <- r_mod1[, 2]
p1 <- r_mod1[, 4]
t1 <- r_mod1[, 3]
# STARGAZER
stargazer(mod1,
type = "text",
column.labels=c("Model one (All)"),
title = "Regression results",
style = "qje",
single.row = TRUE,
t.auto = T, # Necessary?
p.auto = T, # Necessary?
se = list(se1),
p = list(p1),
t = list(t1))