Skip to contents

Compute CRV3 covariance matrices via a cluster jackknife as described in MacKinnon, Nielsen & Webb (2022) for objects of type fixest

Usage

# S3 method for fixest
vcov_CR3J(
  obj,
  cluster,
  type = "CRV3",
  return_all = FALSE,
  absorb_cluster_fixef = TRUE,
  ...
)

Arguments

obj

An object of type fixest

cluster

A clustering vector

type

"CRV3" or "CRV3J" following MacKinnon, Nielsen & Webb. CRV3 by default

return_all

Logical scalar, FALSE by default. Should only the vcov be returned (FALSE) or additional results (TRUE)

absorb_cluster_fixef

TRUE by default. Should the cluster fixed effects be projected out? This increases numerical stability.

...

other function arguments passed to 'vcov'

Value

An object of class vcov_CR3J

References

MacKinnon, James G., Morten Ørregaard Nielsen, and Matthew D. Webb. "Leverage, influence, and the jackknife in clustered regression models: Reliable inference using summclust." arXiv preprint arXiv:2205.03288 (2022).

Examples

# \donttest{

if(requireNamespace("summclust")
&& requireNamespace("haven")
&& requireNamespace("fixest")){

library(summclust)
library(haven)
library(fixest)

nlswork <- read_dta("http://www.stata-press.com/data/r9/nlswork.dta")
# drop NAs at the moment
nlswork <- nlswork[, c("ln_wage", "grade", "age", "birth_yr", "union", "race", "msp", "ind_code")]
nlswork <- na.omit(nlswork)

feols_fit <- feols(
  ln_wage ~ union +  race + msp + as.factor(birth_yr) + as.factor(age) + as.factor(grade),
  data = nlswork)

# CRV3 standard errors
vcov <- vcov_CR3J(
   obj = feols_fit,
   cluster = ~ind_code,
   type = "CRV3"
)

# CRV3 standard errors
vcovJN <- vcov_CR3J(
   obj = feols_fit,
   cluster = ~ind_code,
   type = "CRV3J",
)
}
#> Error in feols(fml = ln_wage ~ 1, data = nlswork): Argument 'data' could not be evaluated. Problem: object 'nlswork' not
#> found.
# }