algorithms.statistics.models.family.family

Module: algorithms.statistics.models.family.family

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

digraph inheritanceb9496eda9a { rankdir=LR; size="8.0, 12.0"; "family.family.Binomial" [URL="#nipy.algorithms.statistics.models.family.family.Binomial",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="Binomial exponential family."]; "family.family.Family" -> "family.family.Binomial" [arrowsize=0.5,style="setlinewidth(0.5)"]; "family.family.Family" [URL="#nipy.algorithms.statistics.models.family.family.Family",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="A class to model one-parameter exponential"]; "family.family.Gamma" [URL="#nipy.algorithms.statistics.models.family.family.Gamma",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="Gamma exponential family."]; "family.family.Family" -> "family.family.Gamma" [arrowsize=0.5,style="setlinewidth(0.5)"]; "family.family.Gaussian" [URL="#nipy.algorithms.statistics.models.family.family.Gaussian",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="Gaussian exponential family."]; "family.family.Family" -> "family.family.Gaussian" [arrowsize=0.5,style="setlinewidth(0.5)"]; "family.family.InverseGaussian" [URL="#nipy.algorithms.statistics.models.family.family.InverseGaussian",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="InverseGaussian exponential family."]; "family.family.Family" -> "family.family.InverseGaussian" [arrowsize=0.5,style="setlinewidth(0.5)"]; "family.family.Poisson" [URL="#nipy.algorithms.statistics.models.family.family.Poisson",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="Poisson exponential family."]; "family.family.Family" -> "family.family.Poisson" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

Classes

Binomial

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

Bases: nipy.algorithms.statistics.models.family.family.Family

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)[source]

Initialize self. See help(type(self)) for accurate signature.

variance = <nipy.algorithms.statistics.models.family.varfuncs.Binomial object>
devresid(Y, mu)[source]

Binomial deviance residual

INPUTS:

Y – response variable mu – mean parameter

OUTPUTS: resid

resid – deviance residuals

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

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

Family

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

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)[source]

Initialize self. See help(type(self)) for accurate signature.

valid = [-inf, inf]
tol = 1e-05
weights(mu)[source]

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

deviance(Y, mu, scale=1.0)[source]

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)[source]

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)[source]

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)[source]

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

Gamma

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

Bases: nipy.algorithms.statistics.models.family.family.Family

Gamma exponential family.

INPUTS:

link – a Link instance

BUGS:

no deviance residuals?

__init__(link=<nipy.algorithms.statistics.models.family.links.Power object>)[source]

Initialize self. See help(type(self)) for accurate signature.

variance = <nipy.algorithms.statistics.models.family.varfuncs.Power object>
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

Gaussian

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

Bases: nipy.algorithms.statistics.models.family.family.Family

Gaussian exponential family.

INPUTS:

link – a Link instance

__init__(link=<nipy.algorithms.statistics.models.family.links.Power object>)[source]

Initialize self. See help(type(self)) for accurate signature.

variance = <nipy.algorithms.statistics.models.family.varfuncs.VarianceFunction object>
devresid(Y, mu, scale=1.0)[source]

Gaussian deviance residual

INPUTS:

Y – response variable mu – mean parameter scale – optional scale in denominator (after taking sqrt)

OUTPUTS: resid

resid – deviance residuals

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

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

InverseGaussian

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

Bases: nipy.algorithms.statistics.models.family.family.Family

InverseGaussian exponential family.

INPUTS:

link – a Link instance n – number of trials for Binomial

__init__(link=<nipy.algorithms.statistics.models.family.links.Power object>)[source]

Initialize self. See help(type(self)) for accurate signature.

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

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>)[source]

Bases: nipy.algorithms.statistics.models.family.family.Family

Poisson exponential family.

INPUTS:

link – a Link instance

__init__(link=<nipy.algorithms.statistics.models.family.links.Log object>)[source]

Initialize self. See help(type(self)) for accurate signature.

valid = [0, inf]
variance = <nipy.algorithms.statistics.models.family.varfuncs.Power object>
devresid(Y, mu)[source]

Poisson deviance residual

INPUTS:

Y – response variable mu – mean parameter

OUTPUTS: resid

resid – deviance residuals

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

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
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