next up previous
Next: Fitting a Bradley-Terry Up: Structure of the Previous: Error Structures

Link Structures

The link function g for a generalized linear model relates the linear predictor to the mean response by

Links are implemented as objects. Table 1 lists the pre-defined link functions, along with the expressions used to return link objects.

  
Table 1: Link Functions and Expression for Obtaining Link Objects

With one exception, the pre-defined links require no parameters. These link objects can therefore be shared among models. The exception is the power link. Links for binomial models are defined for n = 1 trials and assume .

Link objects inherit from the glim-link-proto prototype. The log-link object, for example, is constructed by

(defproto log-link () () glim-link-proto)
Since this prototype can be used directly in model objects, the convention of having prototype names end in -proto is not used. The glim-link-proto prototype provides a :print method that should work for most link functions. The log-link object prints as
> log-link
#<Glim Link Object: LOG-LINK>

The glim-proto computing methods assume that a link object responds to three messages: (send link :eta mu)
(send link :means eta)
(send link :derivs mu)

The :eta method returns a sequence of linear predictor values for a particular mean sequence. The :means method is the inverse of :eta: it returns mean values for specified values of the linear predictor. The :derivs method returns the values of

at the specified mean values. As an example, for the log-link object these three methods are defined as

(defmeth log-link :eta (mu) (log mu))
(defmeth log-link :means (eta) (exp eta))
(defmeth log-link :derivs (mu) (/ mu))

Alternative link structures can be constructed by setting up a new prototype and defining appropriate :eta, :means, and :derivs methods. Parametric link families can be implemented by providing one or more slots for holding the parameters. The power link is an example of a parametric link family. The power link prototype is defined as

(defproto power-link-proto '(power) () glim-link-proto)
The slot power holds the power exponent. An accessor method is defined by
(defmeth power-link-proto :power () (slot-value 'power))
and the :isnew initialization method is defined to require a power argument:
(defmeth power-link-proto :isnew (power) (setf (slot-value 'power) power))
Thus a power link for a particular exponent, say the exponent 2, can be constructed using the expression
(send power-link-proto :new 2)

To complete the power link prototype, we need to define the three required methods. They are defined as

(defmeth power-link-proto :eta (mu) (^ mu (send self :power)))
(defmeth power-link-proto :means (eta) (^ eta (/ (slot-value 'power))))
and
(defmeth power-link-proto :derivs (mu)
  (let ((p (slot-value 'power)))
    (* p (^ mu (- p 1)))))
The definition of the :means method could be improved to allow negative arguments when the power is an odd integer. Finally, the :print method is redefined to reflect the value of the exponent:
(defmeth power-link-proto :print (&optional (stream t))
  (format stream ``#<Glim Link Object: Power Link (~s)>'' (send self :power)))
Thus a square link prints as
> (send power-link-proto :new 2)
#<Glim Link Object: Power Link (2)>



next up previous
Next: Fitting a Bradley-Terry Up: Structure of the Previous: Error Structures



Luke Tierney
Tue Jan 21 14:42:18 CST 1997