compile_model() parses the formula, runs the upstream semantic-IR /
design-audit pipeline against the supplied data, and returns an
mm_spec object — the audit-first analogue of the design-only step in
base lm()'s model.frame() / model.matrix() chain. Nothing is
optimized; nothing is fitted. audit(), explain_model(),
random_options(), and (in Phase 1.E) lmm() all consume the same
artifact.
Value
An object inheriting from mm_spec and containing:
callthe matched call
formulathe input formula
varscharacter vector of variables read from
datamodel_framethe data columns used to compile the artifact, retained so prefit audit views can evaluate nearby formula spellings
artifactparsed JSON artifact (the
mixedmodels.compiled_model_artifactv1 schema)
The raw artifact JSON is attached as attr(spec$artifact, "raw_json")
so the post-compile FFI calls (e.g., the internal
mm_audit_report_text primitive) can round-trip without re-encoding.
Details
The compiled artifact is the structured truth: every print, summary, and audit verb in mixeff reads back from it rather than re-deriving meaning from formula text. R formats; Rust authors wording (PRD §9.6).
Phase 1 compile scope: returns a populated mm_spec with the JSON
artifact attached. explain_model(), random_options(), and
compare_covariance() render random-effects guidance from upstream
random-term cards; the fit driver (lmm()) lands in 1.E.
Errors
Raises typed conditions (all inheriting from mm_condition):
mm_formula_error— formula is not a two-sided R formula or fails parsing.mm_data_error—datais not a data.frame, refers to unknown variables, contains NAs in design columns, or has an unsupported column type.mm_schema_error— the artifact JSON returned by Rust does not match the wrapper's known schema set.
See also
audit() for the printed audit report.