Description
Create a simplified or "fake" version of a model formula for internal use in gamlss2. Many model formulas in gamlss2 may contain complex terms such as smoothing functions, tensor-product interactions, distributional components, or multiple right-hand sides. These extended formulas cannot be passed directly to model.frame, which expects a traditional formula as used in lm or glm.
fake_formula() therefore "fakes" a standard formula by rewriting the original model specification into a form that is acceptable to model.frame, while preserving all variable transformations (e.g., log(), exp(), arithmetic expressions) and extracting any special model terms. These special terms can then be handled separately during model setup and fitting.
In summary, the function separates the parsing of model terms from the creation of the data frame: it provides a clean, simplified formula that ensures correct extraction and evaluation of variables.
Note
In some versions of the RStudio IDE, printing or inspecting a fake_formula() object may trigger a message of the form
‘length = 2’ in coercion to ‘logical(1)’.
This is due to the way RStudio internally inspects objects of class Formula, whose length() method returns a two-element vector (reflecting the number of left- and right-hand side components). The message does not indicate a problem with fake_formula(), and the returned object is valid and works correctly with model.frame() and subsequent processing. The message does not appear in a standard R session outside RStudio.