Link Functions¶
Standard link functions.
Link functions map the mean μ to the linear predictor η = Xβ.
Standard links: - IdentityLink: g(μ) = μ (Gaussian) - LogLink: g(μ) = log(μ) (Poisson, Gamma, Negative Binomial) - LogitLink: g(μ) = log(μ/(1-μ)) (Binomial) - InverseLink: g(μ) = 1/μ (Gamma canonical) - CLogLogLink: g(μ) = log(-log(1-μ)) (Binomial alternative) - ProbitLink: g(μ) = Φ^{-1}(μ) (Binomial/Beta alternative)
Additional links (Phase 5.5): - SqrtLink: g(μ) = √μ (count data alternative) - PowerLink: g(μ) = μ^p (general power family) - InverseSquareLink: g(μ) = 1/μ² (Inverse Gaussian canonical)
- class aurora.distributions.links.IdentityLink[source]¶
Bases:
LinkFunctionIdentity link function: g(mu) = mu.
The simplest link where the linear predictor equals the response directly. This is the canonical link for the Gaussian family.
Examples
>>> import numpy as np >>> from aurora.distributions.links import IdentityLink >>> link = IdentityLink() >>> mu = np.array([1.0, 2.0, 3.0]) >>> eta = link.link(mu) >>> np.allclose(eta, mu) True >>> mu_back = link.inverse(eta) >>> np.allclose(mu_back, mu) True
See also
LogLinkLog link for positive data.
GaussianFamilyDefault family for identity link.
- link(mu)[source]¶
Apply the link function g(mu) to map mean to linear predictor.
- Parameters:
mu (array) – Mean parameter values.
- Returns:
Linear predictor eta = g(mu).
- Return type:
array
- class aurora.distributions.links.LogLink[source]¶
Bases:
LinkFunctionLog link function: g(mu) = log(mu).
Ensures mu > 0. This is the canonical link for the Poisson family and is commonly used for any strictly positive response.
Notes
The inverse is g^{-1}(eta) = exp(eta). The linear predictor eta is clamped to [-700, 700] to prevent numerical overflow.
Examples
>>> import numpy as np >>> from aurora.distributions.links import LogLink >>> link = LogLink() >>> mu = np.array([1.0, 2.0, 3.0]) >>> eta = link.link(mu) >>> np.allclose(eta, np.log(mu)) True >>> mu_back = link.inverse(eta) >>> np.allclose(mu_back, mu) True
See also
IdentityLinkIdentity link.
PoissonFamilyDefault family for log link.
GammaFamilyOften used with log link.
- link(mu)[source]¶
Apply the link function g(mu) to map mean to linear predictor.
- Parameters:
mu (array) – Mean parameter values.
- Returns:
Linear predictor eta = g(mu).
- Return type:
array
- class aurora.distributions.links.LogitLink[source]¶
Bases:
LinkFunctionLogit link function: g(mu) = log(mu / (1 - mu)).
Maps probabilities in (0, 1) to the real line. This is the canonical link for the binomial family. The inverse is the logistic sigmoid: g^{-1}(eta) = 1 / (1 + exp(-eta)).
Examples
>>> import numpy as np >>> from aurora.distributions.links import LogitLink >>> link = LogitLink() >>> mu = np.array([0.2, 0.5, 0.8]) >>> eta = link.link(mu) >>> mu_back = link.inverse(eta) >>> np.allclose(mu, mu_back) True
See also
ProbitLinkNormal CDF inverse link.
CLogLogLinkComplementary log-log link.
BinomialFamilyDefault family for logit link.
BetaFamilyOften used with logit link.
- link(mu)[source]¶
Apply the link function g(mu) to map mean to linear predictor.
- Parameters:
mu (array) – Mean parameter values.
- Returns:
Linear predictor eta = g(mu).
- Return type:
array
- class aurora.distributions.links.InverseLink[source]¶
Bases:
LinkFunctionInverse link function: g(mu) = 1 / mu.
Ensures mu > 0. This is the canonical link for the Gamma family. The inverse is g^{-1}(eta) = 1 / eta.
Examples
>>> import numpy as np >>> from aurora.distributions.links import InverseLink >>> link = InverseLink() >>> mu = np.array([0.5, 1.0, 2.0]) >>> eta = link.link(mu) >>> np.allclose(eta, 1.0 / mu) True >>> mu_back = link.inverse(eta) >>> np.allclose(mu_back, mu) True
See also
InverseSquareLinkInverse square link for inverse Gaussian.
LogLinkLog link (alternative for Gamma).
GammaFamilyDefault family for inverse link.
- link(mu)[source]¶
Apply the link function g(mu) to map mean to linear predictor.
- Parameters:
mu (array) – Mean parameter values.
- Returns:
Linear predictor eta = g(mu).
- Return type:
array
- class aurora.distributions.links.CLogLogLink[source]¶
Bases:
LinkFunctionComplementary log-log link function: g(mu) = log(-log(1 - mu)).
Maps probabilities in (0, 1) to the real line. Asymmetric link that approaches 0 more slowly than 1. Commonly used for binomial regression when the probability of success increases slowly at low doses but rapidly at high doses.
The inverse is g^{-1}(eta) = 1 - exp(-exp(eta)).
Examples
>>> import numpy as np >>> from aurora.distributions.links import CLogLogLink >>> link = CLogLogLink() >>> mu = np.array([0.2, 0.5, 0.8]) >>> eta = link.link(mu) >>> mu_back = link.inverse(eta) >>> np.allclose(mu, mu_back) True
See also
LogitLinkSymmetric link for binomial.
ProbitLinkNormal CDF inverse link.
BinomialFamilyDistribution family using these links.
- link(mu)[source]¶
Apply the link function g(mu) to map mean to linear predictor.
- Parameters:
mu (array) – Mean parameter values.
- Returns:
Linear predictor eta = g(mu).
- Return type:
array
- class aurora.distributions.links.ProbitLink[source]¶
Bases:
LinkFunctionProbit link
g(mu) = Φ^{-1}(mu).The probit link uses the inverse cumulative distribution function (CDF) of the standard normal distribution. Common alternative to logit for binomial and beta regression models.
Properties: - Lighter tails than logit - Assumes underlying normally distributed latent variable - Results similar to logit in practice for μ ∈ [0.2, 0.8]
Mathematical details: - Link: g(μ) = Φ^{-1}(μ) where Φ is the standard normal CDF - Inverse: μ = Φ(η) - Derivative: dg/dμ = 1/φ(Φ^{-1}(μ)) where φ is the normal PDF
Examples
>>> from aurora.distributions.links import ProbitLink >>> link = ProbitLink() >>> import numpy as np >>> mu = np.array([0.1, 0.5, 0.9]) >>> eta = link.link(mu) # Transform to linear predictor >>> mu_back = link.inverse(eta) # Should equal mu >>> np.allclose(mu, mu_back) True
Notes
The probit link is preferred when: - There is a theoretical latent normal process - Lighter tails than logit are desired - Compatibility with other software using probit (e.g., econometrics)
Comparison with logit: - Both are symmetric around 0.5 - Logit has heavier tails (more robust to outliers) - Probit: π × logit(μ) / √3 is a good approximation
References
Bliss, C. I. (1934). “The method of probits.” Science, 79, 38-39.
McCullagh, P., & Nelder, J. A. (1989). Generalized Linear Models.
- class aurora.distributions.links.SqrtLink[source]¶
Bases:
LinkFunctionSquare root link function: g(mu) = sqrt(mu).
Ensures mu > 0. Useful for count data where variance is proportional to the mean. Common alternative to the log link for Poisson-like data.
The inverse is g^{-1}(eta) = eta^2.
Examples
>>> import numpy as np >>> from aurora.distributions.links import SqrtLink >>> link = SqrtLink() >>> mu = np.array([1.0, 4.0, 9.0]) >>> eta = link.link(mu) >>> np.allclose(eta, np.sqrt(mu)) True >>> mu_back = link.inverse(eta) >>> np.allclose(mu_back, mu) True
See also
LogLinkLog link for count data.
IdentityLinkIdentity link.
PoissonFamilyCommon family for count data.
- link(mu)[source]¶
Apply the link function g(mu) to map mean to linear predictor.
- Parameters:
mu (array) – Mean parameter values.
- Returns:
Linear predictor eta = g(mu).
- Return type:
array
- class aurora.distributions.links.PowerLink(power=1.0)[source]¶
Bases:
LinkFunctionPower link function: g(mu) = mu^power.
General power transformation that generalizes several other link functions as special cases:
power = 1: Identity link
power = 0: Log link (limit as power approaches 0)
power = -1: Inverse link
power = 0.5: Square root link
power = -2: Inverse square link
- Parameters:
power (float, default=1.0) – Power parameter for the transformation.
Notes
The Box-Cox transformation is a special case when properly normalized.
For power = 0, this class uses the log link as the limit.
Examples
>>> import numpy as np >>> from aurora.distributions.links import PowerLink >>> # Square root link via power >>> link = PowerLink(power=0.5) >>> mu = np.array([1.0, 4.0, 9.0]) >>> eta = link.link(mu) >>> np.allclose(eta, np.sqrt(mu)) True >>> # Inverse link via power >>> link = PowerLink(power=-1) >>> eta = link.link(mu) >>> np.allclose(eta, 1.0 / mu) True
See also
IdentityLinkPower link with power=1.
LogLinkPower link with power=0 (limit).
InverseLinkPower link with power=-1.
InverseSquareLinkPower link with power=-2.
TweedieFamilyUses canonical power link.
- link(mu)[source]¶
Apply the link function g(mu) to map mean to linear predictor.
- Parameters:
mu (array) – Mean parameter values.
- Returns:
Linear predictor eta = g(mu).
- Return type:
array
- class aurora.distributions.links.InverseSquareLink[source]¶
Bases:
LinkFunctionInverse square link function: g(mu) = 1 / mu^2.
Ensures mu > 0. This is the canonical link for the inverse Gaussian distribution. The inverse is g^{-1}(eta) = 1 / sqrt(eta).
Examples
>>> import numpy as np >>> from aurora.distributions.links import InverseSquareLink >>> link = InverseSquareLink() >>> mu = np.array([1.0, 2.0, 3.0]) >>> eta = link.link(mu) >>> np.allclose(eta, 1.0 / mu**2) True >>> mu_back = link.inverse(eta) >>> np.allclose(mu_back, mu) True
See also
InverseLinkInverse link g(mu) = 1/mu.
InverseGaussianFamilyDefault family for inverse square link.
PowerLinkGeneral power link (power=-2 is equivalent).
- link(mu)[source]¶
Apply the link function g(mu) to map mean to linear predictor.
- Parameters:
mu (array) – Mean parameter values.
- Returns:
Linear predictor eta = g(mu).
- Return type:
array
- class aurora.distributions.links.common.IdentityLink[source]¶
Bases:
LinkFunctionIdentity link function: g(mu) = mu.
The simplest link where the linear predictor equals the response directly. This is the canonical link for the Gaussian family.
Examples
>>> import numpy as np >>> from aurora.distributions.links import IdentityLink >>> link = IdentityLink() >>> mu = np.array([1.0, 2.0, 3.0]) >>> eta = link.link(mu) >>> np.allclose(eta, mu) True >>> mu_back = link.inverse(eta) >>> np.allclose(mu_back, mu) True
See also
LogLinkLog link for positive data.
GaussianFamilyDefault family for identity link.
- link(mu)[source]¶
Apply the link function g(mu) to map mean to linear predictor.
- Parameters:
mu (array) – Mean parameter values.
- Returns:
Linear predictor eta = g(mu).
- Return type:
array
- class aurora.distributions.links.common.LogLink[source]¶
Bases:
LinkFunctionLog link function: g(mu) = log(mu).
Ensures mu > 0. This is the canonical link for the Poisson family and is commonly used for any strictly positive response.
Notes
The inverse is g^{-1}(eta) = exp(eta). The linear predictor eta is clamped to [-700, 700] to prevent numerical overflow.
Examples
>>> import numpy as np >>> from aurora.distributions.links import LogLink >>> link = LogLink() >>> mu = np.array([1.0, 2.0, 3.0]) >>> eta = link.link(mu) >>> np.allclose(eta, np.log(mu)) True >>> mu_back = link.inverse(eta) >>> np.allclose(mu_back, mu) True
See also
IdentityLinkIdentity link.
PoissonFamilyDefault family for log link.
GammaFamilyOften used with log link.
- link(mu)[source]¶
Apply the link function g(mu) to map mean to linear predictor.
- Parameters:
mu (array) – Mean parameter values.
- Returns:
Linear predictor eta = g(mu).
- Return type:
array
- class aurora.distributions.links.common.LogitLink[source]¶
Bases:
LinkFunctionLogit link function: g(mu) = log(mu / (1 - mu)).
Maps probabilities in (0, 1) to the real line. This is the canonical link for the binomial family. The inverse is the logistic sigmoid: g^{-1}(eta) = 1 / (1 + exp(-eta)).
Examples
>>> import numpy as np >>> from aurora.distributions.links import LogitLink >>> link = LogitLink() >>> mu = np.array([0.2, 0.5, 0.8]) >>> eta = link.link(mu) >>> mu_back = link.inverse(eta) >>> np.allclose(mu, mu_back) True
See also
ProbitLinkNormal CDF inverse link.
CLogLogLinkComplementary log-log link.
BinomialFamilyDefault family for logit link.
BetaFamilyOften used with logit link.
- link(mu)[source]¶
Apply the link function g(mu) to map mean to linear predictor.
- Parameters:
mu (array) – Mean parameter values.
- Returns:
Linear predictor eta = g(mu).
- Return type:
array
- class aurora.distributions.links.common.ProbitLink[source]¶
Bases:
LinkFunctionProbit link
g(mu) = Φ^{-1}(mu).The probit link uses the inverse cumulative distribution function (CDF) of the standard normal distribution. Common alternative to logit for binomial and beta regression models.
Properties: - Lighter tails than logit - Assumes underlying normally distributed latent variable - Results similar to logit in practice for μ ∈ [0.2, 0.8]
Mathematical details: - Link: g(μ) = Φ^{-1}(μ) where Φ is the standard normal CDF - Inverse: μ = Φ(η) - Derivative: dg/dμ = 1/φ(Φ^{-1}(μ)) where φ is the normal PDF
Examples
>>> from aurora.distributions.links import ProbitLink >>> link = ProbitLink() >>> import numpy as np >>> mu = np.array([0.1, 0.5, 0.9]) >>> eta = link.link(mu) # Transform to linear predictor >>> mu_back = link.inverse(eta) # Should equal mu >>> np.allclose(mu, mu_back) True
Notes
The probit link is preferred when: - There is a theoretical latent normal process - Lighter tails than logit are desired - Compatibility with other software using probit (e.g., econometrics)
Comparison with logit: - Both are symmetric around 0.5 - Logit has heavier tails (more robust to outliers) - Probit: π × logit(μ) / √3 is a good approximation
References
Bliss, C. I. (1934). “The method of probits.” Science, 79, 38-39.
McCullagh, P., & Nelder, J. A. (1989). Generalized Linear Models.
- class aurora.distributions.links.common.InverseLink[source]¶
Bases:
LinkFunctionInverse link function: g(mu) = 1 / mu.
Ensures mu > 0. This is the canonical link for the Gamma family. The inverse is g^{-1}(eta) = 1 / eta.
Examples
>>> import numpy as np >>> from aurora.distributions.links import InverseLink >>> link = InverseLink() >>> mu = np.array([0.5, 1.0, 2.0]) >>> eta = link.link(mu) >>> np.allclose(eta, 1.0 / mu) True >>> mu_back = link.inverse(eta) >>> np.allclose(mu_back, mu) True
See also
InverseSquareLinkInverse square link for inverse Gaussian.
LogLinkLog link (alternative for Gamma).
GammaFamilyDefault family for inverse link.
- link(mu)[source]¶
Apply the link function g(mu) to map mean to linear predictor.
- Parameters:
mu (array) – Mean parameter values.
- Returns:
Linear predictor eta = g(mu).
- Return type:
array
- class aurora.distributions.links.common.InverseSquareLink[source]¶
Bases:
LinkFunctionInverse square link function: g(mu) = 1 / mu^2.
Ensures mu > 0. This is the canonical link for the inverse Gaussian distribution. The inverse is g^{-1}(eta) = 1 / sqrt(eta).
Examples
>>> import numpy as np >>> from aurora.distributions.links import InverseSquareLink >>> link = InverseSquareLink() >>> mu = np.array([1.0, 2.0, 3.0]) >>> eta = link.link(mu) >>> np.allclose(eta, 1.0 / mu**2) True >>> mu_back = link.inverse(eta) >>> np.allclose(mu_back, mu) True
See also
InverseLinkInverse link g(mu) = 1/mu.
InverseGaussianFamilyDefault family for inverse square link.
PowerLinkGeneral power link (power=-2 is equivalent).
- link(mu)[source]¶
Apply the link function g(mu) to map mean to linear predictor.
- Parameters:
mu (array) – Mean parameter values.
- Returns:
Linear predictor eta = g(mu).
- Return type:
array
- class aurora.distributions.links.common.CLogLogLink[source]¶
Bases:
LinkFunctionComplementary log-log link function: g(mu) = log(-log(1 - mu)).
Maps probabilities in (0, 1) to the real line. Asymmetric link that approaches 0 more slowly than 1. Commonly used for binomial regression when the probability of success increases slowly at low doses but rapidly at high doses.
The inverse is g^{-1}(eta) = 1 - exp(-exp(eta)).
Examples
>>> import numpy as np >>> from aurora.distributions.links import CLogLogLink >>> link = CLogLogLink() >>> mu = np.array([0.2, 0.5, 0.8]) >>> eta = link.link(mu) >>> mu_back = link.inverse(eta) >>> np.allclose(mu, mu_back) True
See also
LogitLinkSymmetric link for binomial.
ProbitLinkNormal CDF inverse link.
BinomialFamilyDistribution family using these links.
- link(mu)[source]¶
Apply the link function g(mu) to map mean to linear predictor.
- Parameters:
mu (array) – Mean parameter values.
- Returns:
Linear predictor eta = g(mu).
- Return type:
array
- class aurora.distributions.links.common.SqrtLink[source]¶
Bases:
LinkFunctionSquare root link function: g(mu) = sqrt(mu).
Ensures mu > 0. Useful for count data where variance is proportional to the mean. Common alternative to the log link for Poisson-like data.
The inverse is g^{-1}(eta) = eta^2.
Examples
>>> import numpy as np >>> from aurora.distributions.links import SqrtLink >>> link = SqrtLink() >>> mu = np.array([1.0, 4.0, 9.0]) >>> eta = link.link(mu) >>> np.allclose(eta, np.sqrt(mu)) True >>> mu_back = link.inverse(eta) >>> np.allclose(mu_back, mu) True
See also
LogLinkLog link for count data.
IdentityLinkIdentity link.
PoissonFamilyCommon family for count data.
- link(mu)[source]¶
Apply the link function g(mu) to map mean to linear predictor.
- Parameters:
mu (array) – Mean parameter values.
- Returns:
Linear predictor eta = g(mu).
- Return type:
array
- class aurora.distributions.links.common.PowerLink(power=1.0)[source]¶
Bases:
LinkFunctionPower link function: g(mu) = mu^power.
General power transformation that generalizes several other link functions as special cases:
power = 1: Identity link
power = 0: Log link (limit as power approaches 0)
power = -1: Inverse link
power = 0.5: Square root link
power = -2: Inverse square link
- Parameters:
power (float, default=1.0) – Power parameter for the transformation.
Notes
The Box-Cox transformation is a special case when properly normalized.
For power = 0, this class uses the log link as the limit.
Examples
>>> import numpy as np >>> from aurora.distributions.links import PowerLink >>> # Square root link via power >>> link = PowerLink(power=0.5) >>> mu = np.array([1.0, 4.0, 9.0]) >>> eta = link.link(mu) >>> np.allclose(eta, np.sqrt(mu)) True >>> # Inverse link via power >>> link = PowerLink(power=-1) >>> eta = link.link(mu) >>> np.allclose(eta, 1.0 / mu) True
See also
IdentityLinkPower link with power=1.
LogLinkPower link with power=0 (limit).
InverseLinkPower link with power=-1.
InverseSquareLinkPower link with power=-2.
TweedieFamilyUses canonical power link.
- link(mu)[source]¶
Apply the link function g(mu) to map mean to linear predictor.
- Parameters:
mu (array) – Mean parameter values.
- Returns:
Linear predictor eta = g(mu).
- Return type:
array
Base Class¶
- class aurora.distributions.base.LinkFunction[source]¶
Bases:
ABCAbstract base class for GLM link functions.
- A link function g() relates the mean mu to the linear predictor eta:
g(mu) = eta = X^T beta
Subclasses must implement the forward link, its inverse, and its derivative. The link must be monotonic and differentiable.
See also
aurora.distributions.links.LogitLinkCanonical link for binomial/beta
aurora.distributions.links.LogLinkCanonical link for Poisson/Gamma
aurora.distributions.links.IdentityLinkCanonical link for Gaussian
Examples
>>> from aurora.distributions.links import LogitLink >>> link = LogitLink() >>> mu = np.array([0.2, 0.5, 0.8]) >>> eta = link.link(mu) # logit(mu) >>> link.inverse(eta) # recovers mu >>> link.derivative(mu) # d(mu)/d(eta)
- abstractmethod link(mu)[source]¶
Apply the link function g(mu) to map mean to linear predictor.
- Parameters:
mu (array) – Mean parameter values.
- Returns:
Linear predictor eta = g(mu).
- Return type:
array