Nonlinear terms that cannot be specified by Mult
require special
handling by gnm
. Nonlin
provides a way of specifying
such terms in a gnm
formula. To fit the special terms, gnm
requires certain objects and
functions, which must be produced by a plug-in function. The
functionCall
argument of Nonlin
specifies the call to this function that is
necessary to fit the desired term.
The gnm package includes plug-in functions for multiplicative
interactions with homogeneous effects (MultHomog
) and diagonal
reference terms (Dref
).
Users may also define their own plug-in functions which should
return a list with at least the following three components:
[object Object],[object Object],[object Object]
and optionally one further component
[object Object]
Nonlin
identifies variables in the term from the call to the
plug-in function and returns deparsed expressions representing these
variables, so that they can be added to the model frame. By default,
expressions passed to unspecified arguments of the plug-in function
are deparsed.
If the default action of Nonlin
will not capture the required
variables, a companion function must exist in the environment of the
plug-in function, which takes a call to the plug-in function and
returns the necessary deparsed expressions. The name of this
function must be the name of the plug-in function suffixed with
Variables
, e.g. PlugInFunctionVariables
would be the
companion function for PlugInFunction
.
The call to the plug-in function is evaluated in the environment of
the model frame and in the enclosing environment of the parent frame
of the call to gnm
. To access the model frame directly from
within a plug-in function (e.g. for use with model.matrix
),
use getModelFrame
.