prepare_stan_data.Rd
Prepares species-level binomial data for a hierarchical Bayesian model in Stan. Converts a dataset with species and complex identifiers and counts into a list formatted for Stan input. The model infers complex-level effects from species-level observations.
prepare_stan_data(data.req, varname)
A data frame with species-level observations. Must include `speciesNb`, `complexNb`, and count columns `<varname>.num` (successes) and `<varname>.den` (trials).
Character. Name of the target variable (e.g., `"HBI"`, `"endophagy"`). Used to identify numerator and denominator columns.
A named list with components:
Number of species-level observations (rows).
Number of unique species.
Number of unique complexes.
Vector of observed counts of successes per observation.
Vector of total counts (trials) per observation.
Integer vector mapping each observation to a species ID.
Integer vector mapping each species to a complex ID.