generate_CSU_site: One-shot site summaries for COLA-GLMM

View source: R/COLA.R

generate_CSU_siteR Documentation

One-shot site summaries for COLA-GLMM

Description

Produces the **lossless**, pattern-level sufficient statistics for a single site: pattern counts 'Ck', outcome sums 'Sk = \sum y', squared sums 'S2k = \sum y^2', and the corresponding pattern matrix 'X0'. Works for both binomial and Poisson outcomes (for Bernoulli, 'S2k == Sk').

Usage

generate_CSU_site(df_site, x_names, intercept = TRUE)

Arguments

df_site

Data frame for one site. Must include outcome column named 'y' and the fixed-effect covariates in 'x_names'. If 'intercept = TRUE', the function will add an 'Intercept' column when missing.

x_names

Character vector of fixed-effect names (binary covariates; may include '"Intercept"' if 'intercept = TRUE').

intercept

Logical; include a fixed intercept in the pattern matrix.

Value

A list with elements:

  • 'Ck' (integer vector) pattern counts

  • 'Sk' (numeric vector) sums of y per pattern

  • 'S2k' (numeric vector) sums of y^2 per pattern

  • 'X0' (matrix) pattern design matrix aligned to 'Ck/Sk/S2k'

Examples

# df_site$y must exist; x_names are binary
# out <- generate_CSU_site(df_site, c("Intercept","age","sex"), intercept = TRUE)

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

Related to generate_CSU_site in pda...