# algorithms.statistics.models.family.family¶

## Module: algorithms.statistics.models.family.family¶

Inheritance diagram for nipy.algorithms.statistics.models.family.family:

## Classes¶

### Binomial¶

class nipy.algorithms.statistics.models.family.family.Binomial(link=<nipy.algorithms.statistics.models.family.links.Logit object>, n=1)

Binomial exponential family.

INPUTS:
link – a Link instance n – number of trials for Binomial
__init__(link=<nipy.algorithms.statistics.models.family.links.Logit object>, n=1)
devresid(Y, mu)

Binomial deviance residual

INPUTS:
Y – response variable mu – mean parameter
OUTPUTS: resid
resid – deviance residuals
variance = <nipy.algorithms.statistics.models.family.varfuncs.Binomial object>

### Family¶

class nipy.algorithms.statistics.models.family.family.Family(link, variance)

Bases: object

A class to model one-parameter exponential families.

INPUTS:

link – a Link instance variance – a variance function (models means as a function

of mean)
__init__(link, variance)
deviance(Y, mu, scale=1.0)

Deviance of (Y,mu) pair. Deviance is usually defined as the difference

DEV = (SUM_i -2 log Likelihood(Y_i,mu_i) + 2 log Likelihood(mu_i,mu_i)) / scale

INPUTS:
Y – response variable mu – mean parameter scale – optional scale in denominator of deviance
OUTPUTS: dev
dev – DEV, as described aboce
devresid(Y, mu)

The deviance residuals, defined as the residuals in the deviance.

Without knowing the link, they default to Pearson residuals

resid_P = (Y - mu) * sqrt(weight(mu))

INPUTS:
Y – response variable mu – mean parameter
OUTPUTS: resid
resid – deviance residuals
fitted(eta)

Fitted values based on linear predictors eta.

INPUTS:
eta – values of linear predictors, say,
X beta in a generalized linear model.
OUTPUTS: mu
mu – link.inverse(eta), mean parameter based on eta
predict(mu)

Linear predictors based on given mu values.

INPUTS:
mu – mean parameter of one-parameter exponential family
OUTPUTS: eta
eta – link(mu), linear predictors, based on
mean parameters mu
tol = 1e-05
valid = [-inf, inf]
weights(mu)

Weights for IRLS step.

w = 1 / (link’(mu)**2 * variance(mu))

INPUTS:
mu – mean parameter in exponential family
OUTPUTS:
w – weights used in WLS step of GLM/GAM fit

### Gamma¶

class nipy.algorithms.statistics.models.family.family.Gamma(link=<nipy.algorithms.statistics.models.family.links.Power object>)

Gamma exponential family.

INPUTS:
BUGS:
no deviance residuals?
__init__(link=<nipy.algorithms.statistics.models.family.links.Power object>)
variance = <nipy.algorithms.statistics.models.family.varfuncs.Power object>

### Gaussian¶

class nipy.algorithms.statistics.models.family.family.Gaussian(link=<nipy.algorithms.statistics.models.family.links.Power object>)

Gaussian exponential family.

INPUTS:
__init__(link=<nipy.algorithms.statistics.models.family.links.Power object>)
devresid(Y, mu, scale=1.0)

Gaussian deviance residual

INPUTS:
Y – response variable mu – mean parameter scale – optional scale in denominator (after taking sqrt)
OUTPUTS: resid
resid – deviance residuals
variance = <nipy.algorithms.statistics.models.family.varfuncs.VarianceFunction object>

### InverseGaussian¶

class nipy.algorithms.statistics.models.family.family.InverseGaussian(link=<nipy.algorithms.statistics.models.family.links.Power object>)

InverseGaussian exponential family.

INPUTS:
link – a Link instance n – number of trials for Binomial
__init__(link=<nipy.algorithms.statistics.models.family.links.Power object>)
variance = <nipy.algorithms.statistics.models.family.varfuncs.Power object>

### Poisson¶

class nipy.algorithms.statistics.models.family.family.Poisson(link=<nipy.algorithms.statistics.models.family.links.Log object>)

Poisson exponential family.

INPUTS:
__init__(link=<nipy.algorithms.statistics.models.family.links.Log object>)
devresid(Y, mu)
valid = [0, inf]
variance = <nipy.algorithms.statistics.models.family.varfuncs.Power object>