alpaca_vcovCL: Cluster-robust variance-covariance matrix for alpaca feglm

View source: R/alpaca_vcov.R

alpaca_vcovCLR Documentation

Cluster-robust variance-covariance matrix for alpaca feglm

Description

Wraps summary(mod, type = "clustered", cluster = cluster) and returns a diagonal variance-covariance matrix that stargazer recognises and labels with the appropriate "clustered by ..." description.

Usage

alpaca_vcovCL(mod, cluster)

Arguments

mod

A fitted feglm object from the alpaca package.

cluster

A one-sided formula identifying the clustering variable(s). Use ~X for one-way, ~X + Y for two-way additive, or ~X^Y for two-way interaction clustering.

Value

A square diagonal matrix of class "vcovAlpacaCL" with a "cluster" attribute containing the cluster formula.

Examples


if (requireNamespace("alpaca", quietly = TRUE)) {
  d <- data.frame(
    y   = rbinom(200, 1, 0.5),
    x1  = rnorm(200),
    grp = factor(rep(1:10, 20))
  )
  mod <- alpaca::feglm(y ~ x1 | grp, d, binomial("logit"))
  V   <- alpaca_vcovCL(mod, cluster = ~grp)
  stargazer(mod, vcov = list(V), type = "text")
}


stargazer2 documentation built on July 17, 2026, 5:08 p.m.