knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

CRV3J

R-CMD-check Codecov test coverage

CRV3J implements the CRV3 Jackknife algorithm proposed in MacKinnon, Nielsen and Webb.

Installation

To install the package, run

devtools::install_github("s3alfisc/CRV3J")

Example

library(CRV3J)
library(fwildclusterboot)
library(fixest)

set.seed(98765)
# few large clusters (around 10000 obs)
N <- 100000
N_G1 <-100
data <- fwildclusterboot:::create_data(
    N = N,
    N_G1 = N_G1,
    icc1 = 0.8,
    N_G2 = 10,
    icc2 = 0.8,
    numb_fe1 = 10,
    numb_fe2 = 10,
    seed = 12
  )

feols_fit <- feols(
  proposition_vote ~ treatment  + log_income |Q1_immigration + Q2_defense, 
  cluster = ~group_id1 , 
  data = data
)

You can estimate CVR3 Variance-Covariance Matrix via the Jackknive with the vcov_CR3J function:

system.time(
  vcov <- CRV3J::vcov_CR3J(
    obj = feols_fit, 
    cluster = data$group_id1
  )
)

Note that the algorithm proposed by NMW is very fast!

You can now compute common test statistics via the coeftest package:

library(sandwich)
library(lmtest)

coeftest(feols_fit, vcov)


s3alfisc/clusterjack documentation built on June 13, 2022, 10:20 p.m.