Learn R Programming

gnm (version 0.8-1)

Nonlin: Specify a Special Nonlinear Term in a Model Formula

Description

A symbolic wrapper, for use in the formula argument to gnm, to indicate a nonlinear term that requires special handling.

Usage

Nonlin(functionCall)

Arguments

functionCall
a call to a plug-in function that provides the objects required to fit the special nonlinear term.

Value

  • 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.

Details

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.

References

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.

See Also

gnm, getModelFrame, MultHomog, Dref, Mult

Examples

Run this code
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)

Run the code above in your browser using DataLab