next up previous
Next: Link Structures Up: Structure of the Previous: Model Prototypes

Error Structures

The error structure of a generalized linear model affects four methods and two slots The methods are called as (send m :initial-means)
(send m :fit-variances mu )
(send m :fit-deviances mu )
(send m :fit-scale)

The ="2D :initial-means=-1 method should return an initial estimate of the means for the iterative search. The default method simply returns the dependent variable, but for some models this may need to be adjusted to move the initial estimate away from a boundary. For example, the method for the Poisson regression model can be defined as

(defmeth poissonreg-proto :initial-means () (pmax (send self :yvar) 0.5))

which insures that initial mean estimates are at least 0.5.

The ="2D :fit-variances=-1 ="2D :fit-deviances=-1 methods return the values on the variance and deviance functions for a specified vector of means. For the Poisson regression model, these methods can be defined as

(defmeth poissonreg-proto :fit-variances (mu) mu)

and
(defmeth poissonreg-proto :fit-deviances (mu)
  (flet ((log+ (x) (log (if-else (< 0 x) x 1))))
    (let* ((y (send self :yvar))
           (raw-dev (* 2 (- (* y (log+ (/ y mu))) (- y mu))))
           (pw (send self :pweights)))
      (if pw (* pw raw-dev) raw-dev))))

The local function ="2D log+=-1 is used to avoid taking the logarithm of zero.

The final message, ="2D :fit-scale=-1 , is only used by the ="2D :display=-1 method. The default method returns the mean deviance.

The two slots related to the error structure are ="2D estimate-scale=-1 and ="2D link=-1 . If the ="2D estimate-scale=-1 slot is not ="2D nil=-1 , then a scale estimate is computed and printed by the ="2D :dislay=-1 method. The ="2D link=-1 slot holds the link object used by the model. The Poisson model does not have a scale parameter, and the canonical link is the logit link. These defaults can be set by the expressions

(send poissonreg-proto :estimate-scale nil)
(send poissonreg-proto :link log-link)

The ="2D glim-proto=-1 prototype itself uses normal errors and an identity link. Other error structures can be implemented by constructing a new prototype and defining appropriate methods and default slot values.



next up previous
Next: Link Structures Up: Structure of the Previous: Model Prototypes



Anthony Rossini
Fri Oct 20 08:28:51 EDT 1995