Add support for handling functions in formulas with LINPRED
#35
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds general capability to handle functions in R formulas with
LINPRED. For exampleoffset()orscale().During formula processing, these types of "function terms" are identified as functions and the corresponding formula component object is tagged as class
formulaComponentFunction.Since every function will be different, we have to handle them individually.
In order to process a
formulaComponentFunctionobject further, we need a matching processing function. This function must have a particular name and a particular class. For example to handleoffset, the environment must contain a function calledoffsetFormulaFunctionwhich has classformulaFunction. This processing function then takes the input formula component and creates the linear predictor terms and priors as needed.If there is no such matching processing function, an error is returned instead.
The upside of this approach is that we can add support for a given function in formulas in a modular way, without modifying
LINPRED, as can users. In this PR I've addedoffsetFormulaFunctionto the package exports as an example of this (and also because we definitely need offset support).There is no requirement that the function to be supported in formulas already exists as an R function. So this feature will also allow for arbitrary new function support, such as for
ICAR()for a spatial random effect.Fixes #32