fewclust

Regression for a binary outcome measured repeatedly within a small number of groups (clusters): 10 to about 150 groups, short series. With few groups the usual analyses give tests that reject too often; fewclust fits the methods that stayed calibrated in a simulation study of these designs, with defaults you do not need to change.

Installation

install.packages("fewclust")

# development version
# install.packages("remotes")
remotes::install_github("lucavd/fewclust")

Usage

library(fewclust)

fit <- fit_fewclust(fc_trial, y ~ time * arm, id = id, time = time)
fit
tidy(fit, conf.int = TRUE)

fit_fewclust() takes the data first, so it works in a pipe, and the columns as bare names:

fc_trial |>
  fit_fewclust(y ~ time * arm + x, id = id, time = time) |>
  tidy()

By default it fits the marginalized multilevel model (Heagerty 1999) with a convergence check, with tests on a t distribution with N - p degrees of freedom (N groups, p coefficients). If that model gives no usable estimate, it fits GEE with an AR(1) working correlation and the Fay-Graubard small-sample correction instead, and tells you. method = "gee" asks for GEE directly; corstr and correction choose its variant.

The coefficients are marginal (population-averaged) log odds ratios.

What the messages mean

All conditions have a class ("fewclust_error", "fewclust_warning", "fewclust_message"), so they can be caught or silenced selectively.

Functions

See vignette("fewclust") to get started and vignette("simulation-study") for what the study found.