Nonlin {gnm} | R Documentation |
A symbolic wrapper, for use in the formula argument to
gnm
, to indicate a nonlinear term that requires special
handling.
Nonlin(functionCall)
functionCall |
a call to a plug-in function that provides the objects required to fit the special nonlinear term. |
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:
gnm
will prefix the call to the
plug-in function).coef
(a vector of parameter estimates) and
predictor
(the result of the predictor function), and
returns the local design matrix. If the plug-in function does
not return a 'start' component, this function must also take the
argument ind
, the index of a column to be returned
rather than the full matrix.and optionally one further component
NA
may be used to indicate parameters which
may be treated as linear for the purpose of finding starting
values, given the non-NA
values.
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
.
An object of class "Nonlin"
which is a list of deparsed expressions
representing the variables in the nonlinear term, with the call to
the plug-in function as an attribute.
Heather Turner
Goodman, L. A. (1979) Simple Models for the Analysis of Association in Cross-Classifications having Ordered Categories. J. Am. Stat. Assoc., 74(367), 537-552.
gnm
, getModelFrame
,
MultHomog
, Dref
, Mult
set.seed(1) data(occupationalStatus) ## Fit an association model with homogeneous row-column effects RChomog <- gnm(Freq ~ origin + destination + Diag(origin, destination) + Nonlin(MultHomog(origin, destination)), family = poisson, data = occupationalStatus)