Arti Patel
Arti Patel

Reputation: 11

Why does stargazer give me a table of output for my lm regression output but not for when I use lm_robust()?

When I used

est <- lm_robust(x~y, data=df) stargazer(est, est, type="text")

R says "% Error: Unrecognized object type." but prints my output properly when I don't try to use robust standard errors.

I'm just looking to find a way to organize my lm regression output into a simple table to include in my paper. Is there another way I can do this if not with the stargazer package?

Upvotes: 1

Views: 1636

Answers (1)

Marco
Marco

Reputation: 2807

You can use a workaround for robust standard errors and stargazer, as follows:

library("sandwich")
library("plm")
library("stargazer")

data("Produc", package = "plm")

# Regression    
model <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp,
             data = Produc, 
             index = c("state","year"),
             method="pooling")

# Adjust standard errors
cov1         <- vcovHC(model, type = "HC1")
robust_se    <- sqrt(diag(cov1))

# Stargazer output (with and without RSE)
stargazer(model, model, type = "text",
          se = list(NULL, robust_se))

Upvotes: 1

Related Questions