From 7850a85cd1940d12056b02166dbf1b2156a18cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Cruz?= Date: Fri, 5 Dec 2025 15:07:23 -0600 Subject: [PATCH 1/2] Update standard_errors.Rmd with `vcov = "cluster"` --- vignettes/standard_errors.Rmd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vignettes/standard_errors.Rmd b/vignettes/standard_errors.Rmd index 61406dfe..9994d4dd 100644 --- a/vignettes/standard_errors.Rmd +++ b/vignettes/standard_errors.Rmd @@ -215,11 +215,11 @@ Now let's see how to replicate the standard-errors from `lm` and `plm`: ```{r} # How to get the lm version -se_feols_firm_lm = se(est_feols, ssc = ssc(K.fixef = "full")) +se_feols_firm_lm = se(est_feols, vcov = "cluster", ssc = ssc(K.fixef = "full")) rbind(se_lm_firm, se_feols_firm_lm) # How to get the plm version -se_feols_firm_plm = se(est_feols, ssc = ssc(K.fixef = "none", G.adj = FALSE)) +se_feols_firm_plm = se(est_feols, vcov = "cluster", ssc = ssc(K.fixef = "none", G.adj = FALSE)) rbind(se_plm_firm, se_feols_firm_plm) ``` @@ -296,13 +296,13 @@ se_lfe_firm = se(est_lfe) rbind(se_lfe_firm, se_feols_firm) # You have to provide a custom VCOV to replicate lfe's VCOV -my_vcov = vcov(est_feols, ssc = ssc(K.adj = FALSE)) +my_vcov = vcov(est_feols, vcov = "cluster", ssc = ssc(K.adj = FALSE)) se(est_feols, vcov = my_vcov * 199/198) # Note that there are 200 observations # Differently from feols, the SEs in lfe are different if year is not a FE: # => now SEs are identical. rbind(se(felm(inv ~ capital + factor(year) | firm | 0 | firm, Grunfeld))["capital"], - se(feols(inv ~ capital + factor(year) | firm, Grunfeld))["capital"]) + se(feols(inv ~ capital + factor(year) | firm, Grunfeld), vcov = "cluster")["capital"]) # Now with two-way clustered standard-errors est_lfe_2way = felm(inv ~ capital | firm + year | 0 | firm + year, Grunfeld) From 3712f03375694883beadff1d00527bd9bf3f5a34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Cruz?= Date: Sat, 6 Dec 2025 16:00:19 -0600 Subject: [PATCH 2/2] Update standard_errors.Rmd with `vcov = ~firm` --- vignettes/standard_errors.Rmd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vignettes/standard_errors.Rmd b/vignettes/standard_errors.Rmd index 9994d4dd..cd4fbbf5 100644 --- a/vignettes/standard_errors.Rmd +++ b/vignettes/standard_errors.Rmd @@ -204,7 +204,7 @@ Now for clustered SEs: se_lm_firm = se(vcovCL(est_lm, cluster = ~firm, type = "HC1"))["capital"] se_plm_firm = se(vcovHC(est_plm, cluster = "group"))["capital"] se_stata_firm = 0.06328129 # vce(cluster firm) -se_feols_firm = se(est_feols, vcov = "cluster") +se_feols_firm = se(est_feols, vcov = ~firm) rbind(se_lm_firm, se_plm_firm, se_stata_firm, se_feols_firm) ``` @@ -215,11 +215,11 @@ Now let's see how to replicate the standard-errors from `lm` and `plm`: ```{r} # How to get the lm version -se_feols_firm_lm = se(est_feols, vcov = "cluster", ssc = ssc(K.fixef = "full")) +se_feols_firm_lm = se(est_feols, vcov = ~firm, ssc = ssc(K.fixef = "full")) rbind(se_lm_firm, se_feols_firm_lm) # How to get the plm version -se_feols_firm_plm = se(est_feols, vcov = "cluster", ssc = ssc(K.fixef = "none", G.adj = FALSE)) +se_feols_firm_plm = se(est_feols, vcov = ~firm, ssc = ssc(K.fixef = "none", G.adj = FALSE)) rbind(se_plm_firm, se_feols_firm_plm) ``` @@ -296,13 +296,13 @@ se_lfe_firm = se(est_lfe) rbind(se_lfe_firm, se_feols_firm) # You have to provide a custom VCOV to replicate lfe's VCOV -my_vcov = vcov(est_feols, vcov = "cluster", ssc = ssc(K.adj = FALSE)) +my_vcov = vcov(est_feols, vcov = ~firm, ssc = ssc(K.adj = FALSE)) se(est_feols, vcov = my_vcov * 199/198) # Note that there are 200 observations # Differently from feols, the SEs in lfe are different if year is not a FE: # => now SEs are identical. rbind(se(felm(inv ~ capital + factor(year) | firm | 0 | firm, Grunfeld))["capital"], - se(feols(inv ~ capital + factor(year) | firm, Grunfeld), vcov = "cluster")["capital"]) + se(feols(inv ~ capital + factor(year) | firm, Grunfeld), vcov = ~firm)["capital"]) # Now with two-way clustered standard-errors est_lfe_2way = felm(inv ~ capital | firm + year | 0 | firm + year, Grunfeld)