enrichwith (version 0.3.1)

enrich.family: Enrich objects of class family

Description

Enrich objects of class family with family-specific mathematical functions

Usage

# S3 method for family
enrich(object, with = "all", ...)

Arguments

object

an object of class family

with

a character vector with enrichment options for object

...

extra arguments to be passed to the compute_* functions

Value

The object object of class family with extra components. get_enrichment_options.family() returns the components and their descriptions.

Details

family objects specify characteristics of the models used by functions such as glm. The families implemented in the stats package include binomial, gaussian, Gamma, inverse.gaussian, and poisson, which are all special cases of the exponential family of distributions that have probability mass or density function of the form $$f(y; \theta, \phi) = \exp\left\{\frac{y\theta - b(\theta) - c_1(y)}{\phi/m} - \frac{1}{2}a\left(-\frac{m}{\phi}\right) + c_2(y)\right\} \quad y \in Y \subset \Re\,, \theta \in \Theta \subset \Re\, , \phi > 0$$ where \(m > 0\) is an observation weight, and \(a(.)\), \(b(.)\), \(c_1(.)\) and \(c_2(.)\) are sufficiently smooth, real-valued functions.

The current implementation of family objects includes the variance function (variance), the deviance residuals (dev.resids), and the Akaike information criterion (aic). See, also family.

The enrich method can further enrich exponential family distributions with \(\theta\) in terms of \(\mu\) (theta), the functions \(b(\theta)\) (bfun), \(c_1(y)\) (c1fun), \(c_2(y)\) (c2fun), \(a(\zeta)\) (fun), the first two derivatives of \(V(\mu)\) (d1variance and d2variance, respectively), and the first four derivatives of \(a(\zeta)\) (d1afun, d2afun, d3afun, d4afun, respectively).

Corresponding enrichment options are also avaialble for quasibinomial, quasipoisson and wedderburn families.

The quasi families are enriched with d1variance and d2variance.

See enrich.link-glm for the enrichment of link-glm objects.

See Also

enrich.link-glm, make.link

Examples

Run this code
# NOT RUN {
## An example from ?glm to illustrate that things still work with
## enriched families
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
print(d.AD <- data.frame(treatment, outcome, counts))
glm.D93 <- glm(counts ~ outcome + treatment, family = enrich(poisson()))
anova(glm.D93)
summary(glm.D93)
# }

Run the code above in your browser using DataLab