Learn R Programming

gnm (version 0.8-1)

MultHomog: gnm Plug-in Function to Fit Multiplicative Interactions with Homogeneous Effects

Description

A function to provide the objects and functions required to fit multiplicative interactions with homogeneous effects in a generalized nonlinear model using gnm.

Usage

MultHomog(...)

Arguments

...
a comma-separated list of two or more factors.

Value

  • A list with the components required of a gnm plug-in function:
  • labelsa character vector of labels for the parameters in the interaction.
  • predictora function that takes estimates of the parameters in the interaction and returns the fitted values.
  • localDesignFunctiona function that takes a vector of estimates of the parameters in the interaction and returns the local design matrix.

Details

Designed to work as a plug-in function for gnm, MultHomog produces the objects required to fit a multiplicative interaction with one component in which the constituent multipliers are the effects of two or more factors and the effects of these factors are constrained to be equal when the factor levels are equal. Thus the interaction effect would be $$\gamma_i\gamma_j...$$ for an observation with level $i$ of the first factor, level $j$ of the second factor and so on, where $\gamma_l$ is the effect for level $l$ of the homogeneous multiplicative factor. To specify a homogeneous multiplicative interaction in the formula argument to gnm, the symbolic wrapper Nonlin must be used, with a call to MultHomog as the first argument.

If the factors passed to MultHomog do not have exactly the same levels, the set of levels is taken to be the union of the factor levels, sorted into increasing order.

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 and Nonlin for usage. Dref for another gnm plug-in function. Mult for specifying multiplicative interactions in gnm formulae.

Examples

Run this code
set.seed(1)
data(friend)

##  Fit an association model with homogeneous row-column effects
rc1 <- gnm(Freq ~ r + c + Diag(r,c) + Nonlin(MultHomog(r, c)),
           family = poisson, data = friend)
rc1

##  Extend to two-component interaction (using workaround)
original <- as.data.frame(friend)
r2 <- original$r
c2 <- original$c
rc2 <- update(rc1, . ~ . + Nonlin(MultHomog(r2, c2)))
rc2

Run the code above in your browser using DataLab