Chapter Contents |
Previous |
Next |
The GENMOD Procedure |
The following code illustrates the use of programming statements. Even though you usually request the Poisson distribution by specifying DIST=POISSON as a MODEL statement option, you can define the variance and deviance functions for the Poisson distribution by using the VARIANCE and DEVIANCE statements. For example, the following code performs the same analysis as the Poisson regression example in the "Getting Started" section.
The code must be in logical order for computation, just as in a DATA step.
proc genmod ; class car age; a = _MEAN_; y = _RESP_; d = 2 * ( y * log( y / a ) - ( y - a ) ); variance var = a; deviance dev = d; model c = car age / link = log offset = ln; run;
The variables var and dev are dummy variables used internally by the procedure to identify the variance and deviance functions. Any valid SAS variable names can be used.
Similarly, the log link function and its inverse could be defined with the FWDLINK and INVLINK statements.
fwdlink link = log(_MEAN_); invlink ilink = exp(_XBETA_);
This code is for illustration, and it works well for most Poisson regression problems. If, however, in the iterative fitting process, the mean parameter becomes too close to 0, or a 0 response value occurs, an error condition occurs when the procedure attempts to evaluate the log function. You can circumvent this kind of problem by using if-then-else clauses or other conditional statements to check for possible error conditions and appropriately define the functions for these cases.
Data set variables can be referenced in user definitions of the link function and response distributions using programming statements and the FWDLINK, INVLINK, DEVIANCE, and VARIANCE statements.
See the DEVIANCE, VARIANCE, FWDLINK, and INVLINK statements for more information.
Chapter Contents |
Previous |
Next |
Top |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.