Negative Binomial Generalized Linear Model (Regression)

Negative Binomial Generalized Linear Model (Regression)

book

Article ID: KB0080749

calendar_today

Updated On:

Products Versions
Spotfire S+ All supported versions

Description

How to calculate a Negative Binomial generalized linear model including a theta parameter.

 

Issue/Introduction

Negative Binomial Generalized Linear Model (Regression)

Environment

Product: TIBCO Spotfire S+ Version: All supported versions OS: All supported operating systems --------------------

Resolution

The MASS library (written by Dr. Venables and Professor Ripley) contains the function 'glm.nb', which is a modification of the system function glm() to include estimation of the additional parameter, theta, for a Negative Binomial generalized linear model.  To load the MASS library in your S-PLUS session, type:

> library(MASS)
[1] "This library is not supported by Insightful, Corp."

Once you have the library loaded, you can view the help file for glm.nb by typing the following at the command line:

> ?glm.nb

Here is an example that uses this function:

> glm.nb(Days ~ Sex/(Age + Eth*Lrn), data = quine)
Call:
glm.nb(formula = Days ~ Sex/(Age + Eth * Lrn), data = quine, init.theta = 1.59799070541236, link
     = log)

Coefficients:
(Intercept)           Sex      SexFAge1     SexMAge1     SexFAge2     SexMAge2      SexFAge3
  2.73812532 0.03985518112 -0.3544368764 -0.361867744 -0.086809163 0.3300958791 0.02472477617

     SexMAge3      SexFEth      SexMEth     SexFLrn      SexMLrn    SexFEthLrn   SexMEthLrn
0.2956537178 -0.376184919 -0.149139421 0.132165446 0.3098088934 -0.3396226701 0.1903539916

Degrees of Freedom: 146 Total; 132 Residual
Residual Deviance: 167.5558222

Unfortunately, the MASS library functions are not supported by S+ Technical Support, but you can view the website to the MASS (Modern Applied Statistics with S) book and software at:

http://www.stats.ox.ac.uk/pub/MASS4/index.html

"Modern Applied Statistics with S" contains a discussion on the Negative Binomial Family on pages 206-208.