cola_glmm: COLA-GLMM

View source: R/COLA.R

cola_glmmR Documentation

COLA-GLMM

Description

Fits a generalized linear mixed model with site-level random intercepts using only one-shot per-site summaries (Ck, Sk, S2k, X0). Each of the iterations constructs weighted LMM summary statistics which are then solved by lmm.fit (from DLMM), yielding updated fixed effects and random intercepts until convergence.

Usage

cola_glmm(
  summary_by_site,
  family = "poisson",
  intercept = TRUE,
  beta_init = NULL,
  u_init = NULL,
  max_iter = 50,
  tol = 1e-06,
  verbose = TRUE
)

Arguments

summary_by_site

Named list of site summaries. Each element must contain Ck, Sk, S2k, and X0 as returned by generate_CSU_site. The list names should be site IDs.

family

Character; one of "poisson" or "binomial" (canonical links).

intercept

Logical; whether the fixed-effect design includes an intercept (affects how X0 was constructed). Default TRUE.

beta_init

Optional named numeric vector of initial fixed effects. Defaults to zeros.

u_init

Optional named numeric vector of initial site random effects (one per site). Defaults to zeros.

max_iter

Integer maximum number of IRLS iterations. Default 50.

tol

Convergence tolerance on relative squared parameter change. Default 1e-6.

verbose

Logical; print iteration progress. Default TRUE.

Details

Uses canonical links: log for Poisson and logit for binomial. The fixed-effect covariates in X0 are assumed binary (plus optional Intercept). For numerically extreme logits, a small weight floor is used internally. Requires lmm.fit from dlmm.R to be on the search path.

Value

A list with elements:

  • beta: named fixed-effect estimates

  • u: named site random-intercept BLUPs

  • V: variance component matrix for the random intercept

  • s2: residual scale from the working LMM

  • iter: number of iterations performed

  • SiXYZ_last: last iteration's sufficient statistics (by site)

Examples

# fit <- cola_glmm(summary_by_site, family = "poisson")

pda documentation built on Nov. 18, 2025, 1:07 a.m.

Related to cola_glmm in pda...