Takes a parsed formula and data frame, and constructs:
The fixed-effects design matrix X
An offset vector (or NULL) extracted from
offset(...)termsRE group index vectors
RE slope matrices (if applicable)
Value
A list with:
y: response vector (or NULL). Acbind(successes, failures)response is resolved to the successes column.n_trials: binomial denominators when the response was written ascbind(successes, failures), otherwise NULLX: fixed-effects design matrixoffset: numeric vector or NULLre_terms: list of RE data structures (group indices, slope matrices)
Details
Missing values pass through (na.action = na.pass), because a prior
predictive may have no response; the fitting doors refuse them. Unused
levels of a grouping factor are dropped, so n_groups counts the groups
that have data.
Examples
d <- data.frame(y = rnorm(6), x = 1:6, g = rep(1:2, 3))
parsed <- tulpa_parse_formula(y ~ x + (1 | g))
md <- tulpa_build_model_data(parsed, d)
dim(md$X)
md$n_re_terms