0

https://1drv.ms/u/s!ArUNQ8J4vgGqhe8IAVP0ulapoEv4uQ?e=wRMEWN

I have provided my data frame above and my R code below.

I am trying to cluster standard errors on firm level.

firm id = gvkey

I have tried the miceadds package but I was not capable of executing it properly.

In the end I want to create an linear regression output including clusterd standard errors on firm level.

the output should look similar to this one:

OUTPUT

Thank you so much!!!

Update

m1_1 <- lm_robust(ROA ~ fam_ownership + lag_investment + dual_class + age + crisis, clusters = gvkey
           , 
           data) 

m1_2 <- lm_robust(ROA ~ fam_ownership + fam_ownership_squared + lag_investment + dual_class + age+crisis, 
                  clusters = gvkey,
           data)

m1_3 <- lm_robust(ROA ~ fam_ownership + fam_ownership_squared + lag_investment + dual_class + age +crisis
           + as.factor(industry) + +as.factor(year), clusters = gvkey,
           data)

m1_4 <- lm_robust(ROA ~ fam_ownership + famfirm50 + lag_investment + dual_class + age+crisis
           + as.factor(industry)+as.factor(year), clusters = gvkey,
           data) 


stargazer(m1_1,m1_2,m1_3,m1_4, type="html", dep.var.labels=c("ROA"), intercept.bottom = FALSE,
          out="OLS1")

When I am using lm_robust and stargazer I receive the following error:

% Error: Unrecognized object type.
% Error: Unrecognized object type.
% Error: Unrecognized object type.
% Error: Unrecognized object type.
Yaron Nolan
  • 153
  • 1
  • 1
  • 8
  • The link fail because of my company policy, could you upload a smaller sample in the form of a dput result? – Bruno Dec 27 '19 at 15:07

1 Answers1

1

There are many ways to calculate clustered standard errors. The easiest is probably to use the estimatr package: instead of using lm(), use the lm_robust() function with the clusters argument.

But lm_robust() produces objects of class lm_robust, and stargazer won't work with objects of that class. To get clustered SEs in stargazer, see Cluster-Robust Standard Errors in Stargazer.

user697473
  • 2,165
  • 1
  • 20
  • 47
  • Thank you! I have updated my initial post. Do you have any idea why I cannot create an output with stargazer when using lm_robust? – Yaron Nolan Dec 27 '19 at 16:45
  • @YaronNolan - yes, see my edited post for an explanation. – user697473 Dec 27 '19 at 17:41
  • Thanks! Flavian Barton posted a good answer in the link you have posted. But which code should I use if I want to create one output with 4 regression models. Each model should have clustered standard errors. How would you set up the code? This is how it looks like for the model without clustered standard errors: stargazer(m1,m2,m3,m4, type="html", dep.var.labels=c("ROA"), intercept.bottom = FALSE, out="OLS1") – Yaron Nolan Dec 27 '19 at 17:45
  • @YaronNolan, I'm afraid that I can't help you on that point - I don't use stargazer. You might try to leave a question in a comment on that other post, or to post a new question. – user697473 Dec 27 '19 at 18:43