-</code></pre><p>Internally, this is accomplished in three steps:</p><ol><li>The expression passed to <code>@formula</code> is lowered to term constructors combined by <code>~</code>, <code>+</code>, and <code>&</code>, which evaluate to create terms for the whole formula and any interaction terms.</li><li>A schema is extracted from the data, which determines whether each variable is continuous or categorical and extracts the summary statistics of each variable (mean/variance/min/max or unique levels respectively). This schema is then <em>applied</em> to the formula with <code>apply_schema(term, schema, ::Type{Model})</code>, which returns a new formula with each placeholder <code>Term</code> replaced with a concrete <code>ContinuousTerm</code> or <code>CategoricalTerm</code> as appropriate. This is also the stage where any custom syntax is applied (see <a href="../internals/#Internals-and-extending-the-formula-DSL">the section on extending the <code>@formula</code> language</a> for more details).</li><li>Numeric arrays are generated for the response and predictors from the full table using <code>modelcols(term, data)</code>.</li></ol><p>The <code>ModelFrame</code> and <code>ModelMatrix</code> types can still be used to do this transformation, but this is only to preserve some backwards compatibility. Package authors who would like to include support for fitting models from a <code>@formula</code> are <strong>strongly</strong> encouraged to directly use <code>schema</code>, <code>apply_schema</code>, and <code>modelcols</code> to handle the table-to-matrix transformations they need.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../">« Introduction</a><a class="docs-footer-nextpage" href="../internals/">Internals and extending the <code>@formula</code> »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 0.27.25 on <span class="colophon-date" title="Friday 19 September 2025 07:08">Friday 19 September 2025</span>. Using Julia version 1.8.5.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
0 commit comments