SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.regression.linear.glm.distribution
Class Gamma

java.lang.Object
  extended by com.numericalmethod.suanshu.stats.regression.linear.glm.distribution.Family
      extended by com.numericalmethod.suanshu.stats.regression.linear.glm.distribution.Gamma
All Implemented Interfaces:
ExponentialDistribution
Direct Known Subclasses:
Gamma

public class Gamma
extends Family

The Gamma distribution for the error distribution in a GLM model.

The R equivalent function is Gamma.


Constructor Summary
Gamma()
          Construct an instance of Gamma.
Gamma(LinkFunction link)
          Construct an instance of Gamma with an overriding link function.
 
Method Summary
 double AIC(Vector y, Vector mu, Vector weight, double prelogLike, double deviance, int nFactors)
          AIC = 2 * #param - 2 * log-likelihood
 double cumulant(double theta)
          The cumulant function of the exponential distribution.
 double deviance(double y, double mu)
          Deviance D(y;μ^) measures the goodness-of-fit of a model, which is defined as the difference between the maximum log likelihood achievable and that achieved by the model.
 double dispersion(Vector y, Vector mu, int nFactors)
          Different distribution models have different ways to compute dispersion, φ.
 double overdispersion(Vector y, Vector mu, int nFactors)
          Overdispersion is the presence of greater variability (statistical dispersion) in a data set than would be expected based on the nominal variance of a given simple statistical model.
 double theta(double mu)
          The canonical parameter of the distribution in terms of the mean μ.
 double variance(double mu)
          The variance function of the distribution in terms of the mean μ.
 
Methods inherited from class com.numericalmethod.suanshu.stats.regression.linear.glm.distribution.Family
link
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Gamma

public Gamma()
Construct an instance of Gamma. The canonical link is Inverse.

See Also:
"pp.32. Section 2.2.4. Measuring the goodness-of-fit. Generalized Linear Models. 2nd ed. P. J. MacCullagh and J. A. Nelder."

Gamma

public Gamma(LinkFunction link)
Construct an instance of Gamma with an overriding link function.

Parameters:
link - the overriding link function
Method Detail

variance

public double variance(double mu)
Description copied from interface: ExponentialDistribution
The variance function of the distribution in terms of the mean μ.

Parameters:
mu - the distribution mean, μ
Returns:
the value of variance function at μ
See Also:
"P. J. MacCullagh and J. A. Nelder, Generalized Linear Models, 2nd ed. Chapter 2. Table 2.1. pp.30"

theta

public double theta(double mu)
Description copied from interface: ExponentialDistribution
The canonical parameter of the distribution in terms of the mean μ.

Parameters:
mu - the distribution mean, μ
Returns:
the value of canonical parameter θ at μ
See Also:
"P. J. MacCullagh and J. A. Nelder, Generalized Linear Models, 2nd ed. Chapter 2. Table 2.1. pp.30."

cumulant

public double cumulant(double theta)
Description copied from interface: ExponentialDistribution
The cumulant function of the exponential distribution.

Parameters:
theta - the input argument of the cumulant function
Returns:
the value of the cumulant function at (@code θ}
See Also:
"P. J. MacCullagh and J. A. Nelder, Generalized Linear Models, 2nd ed. Chapter 2. Table 2.1. pp.30."

deviance

public double deviance(double y,
                       double mu)
Description copied from class: Family
Deviance D(y;μ^) measures the goodness-of-fit of a model, which is defined as the difference between the maximum log likelihood achievable and that achieved by the model.
D(y;μ^) = 2 * [l(y;y) - l(μ^;y)]
where l is the log-likelihood.

For an exponential family distribution, this is equivalent to

2 * [(y * θ(y) - b(θ(y))) - (y * θ(μ^) - b(θ(μ^)]
where b() is the cumulant function of the distribution.

The definition above is the default implementation of this function, a subclass of ExponentialDistribution may override this function to implement a simplified expression for efficiency or handle special values.

Specified by:
deviance in interface ExponentialDistribution
Overrides:
deviance in class Family
Parameters:
y - the observed value
mu - the estimated mean, μ^
Returns:
the deviance
See Also:
  • P. J. MacCullagh and J. A. Nelder, "Measuring the goodness-of-fit," Generalized Linear Models, 2nd ed. Section 2.3. pp.34.
  • Wikipedia: Deviance

overdispersion

public double overdispersion(Vector y,
                             Vector mu,
                             int nFactors)
Description copied from interface: ExponentialDistribution
Overdispersion is the presence of greater variability (statistical dispersion) in a data set than would be expected based on the nominal variance of a given simple statistical model. σ^2 = X^2/(n-p), 4.23 X^2 = sum{(y-μ)^2}/V(μ), p.34 = sum{(y-μ)^2}/b''(θ), p.29 X^2 estimates a(φ) = φ, the dispersion parameter (assuming w = 1).

For, Gamma, Gaussian, InverseGaussian, over-dispersion is the same as dispersion.

mu - μ
Returns:
the dispersion
See Also:
"P. J. MacCullagh and J. A. Nelder, Generalized Linear Models, 2nd ed. Section 4.5. Equation 4.23."

dispersion

public double dispersion(Vector y,
                         Vector mu,
                         int nFactors)
Description copied from interface: ExponentialDistribution
Different distribution models have different ways to compute dispersion, φ.

Note that in R's output, this is called "over-dispersion".

mu - μ
Returns:
the dispersion
See Also:
"P. J. MacCullagh and J. A. Nelder, Generalized Linear Models, 2nd ed. Section 2.2.2. Table 2.1."

AIC

public double AIC(Vector y,
                  Vector mu,
                  Vector weight,
                  double prelogLike,
                  double deviance,
                  int nFactors)
Description copied from interface: ExponentialDistribution
AIC = 2 * #param - 2 * log-likelihood

mu - μ
prelogLike - sum of y * θi - b(θi)
Returns:
the AIC

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.