nb2: A negative binomial family

View source: R/auxilaryfunctions.R

nb2R Documentation

A negative binomial family

Description

Since the negative binomial is not a family in base R, an nb2() family has been created which establishes the negative binomial as a family for use in the main rpql function. Only the log link is available at the moment, with the variance parameterized as V = \mu + \phi\mu^2 where \phi is the overdispersion parameter.

Usage

 
nb2()
  

Details

Used in the form rpql(y, ..., family = nb2(), ...).

Value

An object of class "family"

Author(s)

Francis K.C. Hui [aut, cre]

Maintainer: Francis K.C. Hui <fhui28@gmail.com>

Examples

## Not run: 
## The function is currently defined as follows
nb2 <- function () {
    link <- "log"
    linkfun <- function(mu) log(mu)
    linkinv <- function(eta) pmax(exp(eta), .Machine$double.eps)
    mu.eta <- function(eta) pmax(exp(eta), .Machine$double.eps)
    variance <- function(mu, phi) mu + phi * mu^2
    valideta <- function(eta) TRUE
    validmu <- function(mu) all(mu > 0)
    structure(list(family = "negative.binomial", link = "log", 
        linkfun = linkfun, linkinv = linkinv, mu.eta = mu.eta, 
        variance = variance, valideta = valideta, validmu = validmu, 
        name = link), class = "family")
  }

## End(Not run)  

rpql documentation built on Dec. 18, 2025, 1:07 a.m.