| generate_CSU_site | R Documentation |
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').
generate_CSU_site(df_site, x_names, intercept = TRUE)
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. |
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'
# df_site$y must exist; x_names are binary
# out <- generate_CSU_site(df_site, c("Intercept","age","sex"), intercept = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.