Skip to contents

Recommended when the number of clusters is small (< 50). Uses a base-R Rademacher / Webb wild-cluster-bootstrap implementation. Earlier rmorie versions also delegated to fwildclusterboot::boottest when installed; that branch was dropped in 0.9.5.12 because fwildclusterboot is GitHub-only and transitively requires summclust, also GitHub-only, which made the CI dependency resolver unreliable. Callers who want fwildclusterboot should call it directly on a feols / lm fit.

Usage

morie_did_wild_cluster_bootstrap(
  data,
  outcome,
  treatment,
  post,
  cluster,
  covariates = NULL,
  n_bootstrap = 999L,
  weight_type = "rademacher",
  seed = 42L,
  alpha = 0.05
)

Arguments

data

A data frame containing the outcome, treatment, post and any covariate columns.

outcome

Name of the outcome column.

treatment

Name of the binary (0/1) treatment-group column.

post

Name of the binary (0/1) post-period column.

cluster

Optional cluster ID column for CR1 standard errors.

covariates

Optional character vector of covariate column names.

n_bootstrap

Number of bootstrap replications.

weight_type

"rademacher" (default) or "webb".

seed

RNG seed.

alpha

Significance level for confidence intervals (default 0.05).

Value

A result list; see morie_did_2x2. p_value is the bootstrap p-value.

Examples

set.seed(1)
n <- 300
d <- rbinom(n, 1, 0.5); p <- rbinom(n, 1, 0.5)
y <- 1 + 0.3 * d + 0.4 * p + 0.5 * d * p + rnorm(n, sd = 0.5)
df <- data.frame(y = y, d = d, post = p,
                 clust = sample.int(20, n, replace = TRUE))
res <- morie_did_wild_cluster_bootstrap(df, "y", "d", "post",
                                        cluster = "clust",
                                        n_bootstrap = 99L, seed = 7)
c(res$estimate, res$p_value)
#> [1] 0.584631 0.000000