Create a simplified formula from a formula, a Formula, or a list of formulas. The result retains the variables and transformations needed to build a model.frame while separating out special model terms. This is mainly used internally when gamlss2 prepares formulas for fitting.
Character, vector of names of special functions in the formula, see terms.formula.
nospecials
Logical, should variables of special model terms be part of the "fake formula"?
onlyspecials
Logical, should only the special model terms be returned?
Details
The function is primarily an internal helper for formula preprocessing in gamlss2, but it can also be useful for inspecting how complex formulas are decomposed before fitting.
Special model terms such as s(), te(), ti(), re(), or package-specific specials are identified and handled separately from ordinary variables. Depending on the control arguments:
if nospecials = FALSE, variables used inside registered special terms are reintroduced into the returned formula so they remain available in the model frame;
if nospecials = TRUE, the returned formula excludes the special terms and their variables;
if onlyspecials = TRUE, the function returns the names of the detected special terms instead of a formula object.
For multi-part or multi-parameter formulas, the output preserves the overall formula structure.
Value
Depending on the input, the function returns a formula or Formula. If onlyspecials = TRUE, a character vector or list of special model term names is returned.