Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
Aurora-GLM
Aurora-GLM
  • User Guide
    • Installation
    • Quickstart
    • Generalized Linear Models (GLM)
    • Generalized Additive Models (GAM)
    • Generalized Additive Mixed Models (GAMM)
    • Formula Syntax Reference
    • Inference & Diagnostics
    • Multi-Backend Support
    • Migration Guide
  • API Reference
    • GLM — Generalized Linear Models
    • GAM — Generalized Additive Models
    • GAMM — Generalized Additive Mixed Models
    • Distribution Families
    • Link Functions
    • Linear Algebra
    • Optimization
    • Smoothing
    • Inference
    • Validation & Cross-Validation
    • Visualization
    • Input / Output
    • Helpers
  • Examples & Case Studies
Back to top
View this page

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

Identity 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

LogLink

Log link for positive data.

GaussianFamily

Default 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

inverse(eta)[source]¶

Apply the inverse link g^{-1}(eta) to map linear predictor to mean.

Parameters:

eta (array) – Linear predictor values.

Returns:

Mean parameter mu = g^{-1}(eta).

Return type:

array

derivative(mu)[source]¶

Compute the derivative dg/dmu of the link function.

Parameters:

mu (array) – Mean parameter values at which to evaluate the derivative.

Returns:

Derivative dg/dmu evaluated at mu.

Return type:

array

class aurora.distributions.links.LogLink[source]¶

Bases: LinkFunction

Log 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

IdentityLink

Identity link.

PoissonFamily

Default family for log link.

GammaFamily

Often 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

inverse(eta)[source]¶

Apply the inverse link g^{-1}(eta) to map linear predictor to mean.

Parameters:

eta (array) – Linear predictor values.

Returns:

Mean parameter mu = g^{-1}(eta).

Return type:

array

derivative(mu)[source]¶

Compute the derivative dg/dmu of the link function.

Parameters:

mu (array) – Mean parameter values at which to evaluate the derivative.

Returns:

Derivative dg/dmu evaluated at mu.

Return type:

array

class aurora.distributions.links.LogitLink[source]¶

Bases: LinkFunction

Logit 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

ProbitLink

Normal CDF inverse link.

CLogLogLink

Complementary log-log link.

BinomialFamily

Default family for logit link.

BetaFamily

Often 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

inverse(eta)[source]¶

Apply the inverse link g^{-1}(eta) to map linear predictor to mean.

Parameters:

eta (array) – Linear predictor values.

Returns:

Mean parameter mu = g^{-1}(eta).

Return type:

array

derivative(mu)[source]¶

Compute the derivative dg/dmu of the link function.

Parameters:

mu (array) – Mean parameter values at which to evaluate the derivative.

Returns:

Derivative dg/dmu evaluated at mu.

Return type:

array

class aurora.distributions.links.InverseLink[source]¶

Bases: LinkFunction

Inverse 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

InverseSquareLink

Inverse square link for inverse Gaussian.

LogLink

Log link (alternative for Gamma).

GammaFamily

Default 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

inverse(eta)[source]¶

Apply the inverse link g^{-1}(eta) to map linear predictor to mean.

Parameters:

eta (array) – Linear predictor values.

Returns:

Mean parameter mu = g^{-1}(eta).

Return type:

array

derivative(mu)[source]¶

Compute the derivative dg/dmu of the link function.

Parameters:

mu (array) – Mean parameter values at which to evaluate the derivative.

Returns:

Derivative dg/dmu evaluated at mu.

Return type:

array

class aurora.distributions.links.CLogLogLink[source]¶

Bases: LinkFunction

Complementary 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

LogitLink

Symmetric link for binomial.

ProbitLink

Normal CDF inverse link.

BinomialFamily

Distribution 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

inverse(eta)[source]¶

Apply the inverse link g^{-1}(eta) to map linear predictor to mean.

Parameters:

eta (array) – Linear predictor values.

Returns:

Mean parameter mu = g^{-1}(eta).

Return type:

array

derivative(mu)[source]¶

Compute the derivative dg/dmu of the link function.

Parameters:

mu (array) – Mean parameter values at which to evaluate the derivative.

Returns:

Derivative dg/dmu evaluated at mu.

Return type:

array

class aurora.distributions.links.ProbitLink[source]¶

Bases: LinkFunction

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

link(mu)[source]¶

Transform probability to linear predictor: η = Φ^{-1}(μ).

inverse(eta)[source]¶

Transform linear predictor to probability: μ = Φ(η).

No clamping is applied: Φ(η) is evaluable over the whole float64 range (it saturates to 0 or 1 only around |η| ≈ 38). Families are responsible for clipping probabilities away from the boundaries.

derivative(mu)[source]¶

Compute derivative: dg/dμ = 1/φ(Φ^{-1}(μ)).

The derivative is the reciprocal of the normal PDF evaluated at the quantile corresponding to μ.

class aurora.distributions.links.SqrtLink[source]¶

Bases: LinkFunction

Square 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

LogLink

Log link for count data.

IdentityLink

Identity link.

PoissonFamily

Common 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

inverse(eta)[source]¶

Apply the inverse link g^{-1}(eta) to map linear predictor to mean.

Parameters:

eta (array) – Linear predictor values.

Returns:

Mean parameter mu = g^{-1}(eta).

Return type:

array

derivative(mu)[source]¶

Compute the derivative dg/dmu of the link function.

Parameters:

mu (array) – Mean parameter values at which to evaluate the derivative.

Returns:

Derivative dg/dmu evaluated at mu.

Return type:

array

class aurora.distributions.links.PowerLink(power=1.0)[source]¶

Bases: LinkFunction

Power 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

IdentityLink

Power link with power=1.

LogLink

Power link with power=0 (limit).

InverseLink

Power link with power=-1.

InverseSquareLink

Power link with power=-2.

TweedieFamily

Uses canonical power link.

__init__(power=1.0)[source]¶

Initialize power link.

Parameters:

power (float) – Power parameter.

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

inverse(eta)[source]¶

Apply the inverse link g^{-1}(eta) to map linear predictor to mean.

Parameters:

eta (array) – Linear predictor values.

Returns:

Mean parameter mu = g^{-1}(eta).

Return type:

array

derivative(mu)[source]¶

Compute the derivative dg/dmu of the link function.

Parameters:

mu (array) – Mean parameter values at which to evaluate the derivative.

Returns:

Derivative dg/dmu evaluated at mu.

Return type:

array

class aurora.distributions.links.InverseSquareLink[source]¶

Bases: LinkFunction

Inverse 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

InverseLink

Inverse link g(mu) = 1/mu.

InverseGaussianFamily

Default family for inverse square link.

PowerLink

General 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

inverse(eta)[source]¶

Apply the inverse link g^{-1}(eta) to map linear predictor to mean.

Parameters:

eta (array) – Linear predictor values.

Returns:

Mean parameter mu = g^{-1}(eta).

Return type:

array

derivative(mu)[source]¶

Compute the derivative dg/dmu of the link function.

Parameters:

mu (array) – Mean parameter values at which to evaluate the derivative.

Returns:

Derivative dg/dmu evaluated at mu.

Return type:

array

class aurora.distributions.links.common.IdentityLink[source]¶

Bases: LinkFunction

Identity 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

LogLink

Log link for positive data.

GaussianFamily

Default 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

inverse(eta)[source]¶

Apply the inverse link g^{-1}(eta) to map linear predictor to mean.

Parameters:

eta (array) – Linear predictor values.

Returns:

Mean parameter mu = g^{-1}(eta).

Return type:

array

derivative(mu)[source]¶

Compute the derivative dg/dmu of the link function.

Parameters:

mu (array) – Mean parameter values at which to evaluate the derivative.

Returns:

Derivative dg/dmu evaluated at mu.

Return type:

array

class aurora.distributions.links.common.LogLink[source]¶

Bases: LinkFunction

Log 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

IdentityLink

Identity link.

PoissonFamily

Default family for log link.

GammaFamily

Often 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

inverse(eta)[source]¶

Apply the inverse link g^{-1}(eta) to map linear predictor to mean.

Parameters:

eta (array) – Linear predictor values.

Returns:

Mean parameter mu = g^{-1}(eta).

Return type:

array

derivative(mu)[source]¶

Compute the derivative dg/dmu of the link function.

Parameters:

mu (array) – Mean parameter values at which to evaluate the derivative.

Returns:

Derivative dg/dmu evaluated at mu.

Return type:

array

class aurora.distributions.links.common.LogitLink[source]¶

Bases: LinkFunction

Logit 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

ProbitLink

Normal CDF inverse link.

CLogLogLink

Complementary log-log link.

BinomialFamily

Default family for logit link.

BetaFamily

Often 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

inverse(eta)[source]¶

Apply the inverse link g^{-1}(eta) to map linear predictor to mean.

Parameters:

eta (array) – Linear predictor values.

Returns:

Mean parameter mu = g^{-1}(eta).

Return type:

array

derivative(mu)[source]¶

Compute the derivative dg/dmu of the link function.

Parameters:

mu (array) – Mean parameter values at which to evaluate the derivative.

Returns:

Derivative dg/dmu evaluated at mu.

Return type:

array

class aurora.distributions.links.common.ProbitLink[source]¶

Bases: LinkFunction

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

link(mu)[source]¶

Transform probability to linear predictor: η = Φ^{-1}(μ).

inverse(eta)[source]¶

Transform linear predictor to probability: μ = Φ(η).

No clamping is applied: Φ(η) is evaluable over the whole float64 range (it saturates to 0 or 1 only around |η| ≈ 38). Families are responsible for clipping probabilities away from the boundaries.

derivative(mu)[source]¶

Compute derivative: dg/dμ = 1/φ(Φ^{-1}(μ)).

The derivative is the reciprocal of the normal PDF evaluated at the quantile corresponding to μ.

class aurora.distributions.links.common.InverseLink[source]¶

Bases: LinkFunction

Inverse 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

InverseSquareLink

Inverse square link for inverse Gaussian.

LogLink

Log link (alternative for Gamma).

GammaFamily

Default 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

inverse(eta)[source]¶

Apply the inverse link g^{-1}(eta) to map linear predictor to mean.

Parameters:

eta (array) – Linear predictor values.

Returns:

Mean parameter mu = g^{-1}(eta).

Return type:

array

derivative(mu)[source]¶

Compute the derivative dg/dmu of the link function.

Parameters:

mu (array) – Mean parameter values at which to evaluate the derivative.

Returns:

Derivative dg/dmu evaluated at mu.

Return type:

array

class aurora.distributions.links.common.InverseSquareLink[source]¶

Bases: LinkFunction

Inverse 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

InverseLink

Inverse link g(mu) = 1/mu.

InverseGaussianFamily

Default family for inverse square link.

PowerLink

General 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

inverse(eta)[source]¶

Apply the inverse link g^{-1}(eta) to map linear predictor to mean.

Parameters:

eta (array) – Linear predictor values.

Returns:

Mean parameter mu = g^{-1}(eta).

Return type:

array

derivative(mu)[source]¶

Compute the derivative dg/dmu of the link function.

Parameters:

mu (array) – Mean parameter values at which to evaluate the derivative.

Returns:

Derivative dg/dmu evaluated at mu.

Return type:

array

class aurora.distributions.links.common.CLogLogLink[source]¶

Bases: LinkFunction

Complementary 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

LogitLink

Symmetric link for binomial.

ProbitLink

Normal CDF inverse link.

BinomialFamily

Distribution 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

inverse(eta)[source]¶

Apply the inverse link g^{-1}(eta) to map linear predictor to mean.

Parameters:

eta (array) – Linear predictor values.

Returns:

Mean parameter mu = g^{-1}(eta).

Return type:

array

derivative(mu)[source]¶

Compute the derivative dg/dmu of the link function.

Parameters:

mu (array) – Mean parameter values at which to evaluate the derivative.

Returns:

Derivative dg/dmu evaluated at mu.

Return type:

array

class aurora.distributions.links.common.SqrtLink[source]¶

Bases: LinkFunction

Square 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

LogLink

Log link for count data.

IdentityLink

Identity link.

PoissonFamily

Common 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

inverse(eta)[source]¶

Apply the inverse link g^{-1}(eta) to map linear predictor to mean.

Parameters:

eta (array) – Linear predictor values.

Returns:

Mean parameter mu = g^{-1}(eta).

Return type:

array

derivative(mu)[source]¶

Compute the derivative dg/dmu of the link function.

Parameters:

mu (array) – Mean parameter values at which to evaluate the derivative.

Returns:

Derivative dg/dmu evaluated at mu.

Return type:

array

class aurora.distributions.links.common.PowerLink(power=1.0)[source]¶

Bases: LinkFunction

Power 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

IdentityLink

Power link with power=1.

LogLink

Power link with power=0 (limit).

InverseLink

Power link with power=-1.

InverseSquareLink

Power link with power=-2.

TweedieFamily

Uses canonical power link.

__init__(power=1.0)[source]¶

Initialize power link.

Parameters:

power (float) – Power parameter.

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

inverse(eta)[source]¶

Apply the inverse link g^{-1}(eta) to map linear predictor to mean.

Parameters:

eta (array) – Linear predictor values.

Returns:

Mean parameter mu = g^{-1}(eta).

Return type:

array

derivative(mu)[source]¶

Compute the derivative dg/dmu of the link function.

Parameters:

mu (array) – Mean parameter values at which to evaluate the derivative.

Returns:

Derivative dg/dmu evaluated at mu.

Return type:

array

Base Class¶

class aurora.distributions.base.LinkFunction[source]¶

Bases: ABC

Abstract 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.LogitLink

Canonical link for binomial/beta

aurora.distributions.links.LogLink

Canonical link for Poisson/Gamma

aurora.distributions.links.IdentityLink

Canonical 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

abstractmethod inverse(eta)[source]¶

Apply the inverse link g^{-1}(eta) to map linear predictor to mean.

Parameters:

eta (array) – Linear predictor values.

Returns:

Mean parameter mu = g^{-1}(eta).

Return type:

array

abstractmethod derivative(mu)[source]¶

Compute the derivative dg/dmu of the link function.

Parameters:

mu (array) – Mean parameter values at which to evaluate the derivative.

Returns:

Derivative dg/dmu evaluated at mu.

Return type:

array

Next
Linear Algebra
Previous
Distribution Families
Copyright © 2025, Lucy Eduardo Arias
Made with Sphinx and @pradyunsg's Furo
On this page
  • Link Functions
    • IdentityLink
      • IdentityLink.link()
      • IdentityLink.inverse()
      • IdentityLink.derivative()
    • LogLink
      • LogLink.link()
      • LogLink.inverse()
      • LogLink.derivative()
    • LogitLink
      • LogitLink.link()
      • LogitLink.inverse()
      • LogitLink.derivative()
    • InverseLink
      • InverseLink.link()
      • InverseLink.inverse()
      • InverseLink.derivative()
    • CLogLogLink
      • CLogLogLink.link()
      • CLogLogLink.inverse()
      • CLogLogLink.derivative()
    • ProbitLink
      • ProbitLink.link()
      • ProbitLink.inverse()
      • ProbitLink.derivative()
    • SqrtLink
      • SqrtLink.link()
      • SqrtLink.inverse()
      • SqrtLink.derivative()
    • PowerLink
      • PowerLink.__init__()
      • PowerLink.link()
      • PowerLink.inverse()
      • PowerLink.derivative()
    • InverseSquareLink
      • InverseSquareLink.link()
      • InverseSquareLink.inverse()
      • InverseSquareLink.derivative()
    • IdentityLink
      • IdentityLink.link()
      • IdentityLink.inverse()
      • IdentityLink.derivative()
    • LogLink
      • LogLink.link()
      • LogLink.inverse()
      • LogLink.derivative()
    • LogitLink
      • LogitLink.link()
      • LogitLink.inverse()
      • LogitLink.derivative()
    • ProbitLink
      • ProbitLink.link()
      • ProbitLink.inverse()
      • ProbitLink.derivative()
    • InverseLink
      • InverseLink.link()
      • InverseLink.inverse()
      • InverseLink.derivative()
    • InverseSquareLink
      • InverseSquareLink.link()
      • InverseSquareLink.inverse()
      • InverseSquareLink.derivative()
    • CLogLogLink
      • CLogLogLink.link()
      • CLogLogLink.inverse()
      • CLogLogLink.derivative()
    • SqrtLink
      • SqrtLink.link()
      • SqrtLink.inverse()
      • SqrtLink.derivative()
    • PowerLink
      • PowerLink.__init__()
      • PowerLink.link()
      • PowerLink.inverse()
      • PowerLink.derivative()
    • Base Class
      • LinkFunction
        • LinkFunction.link()
        • LinkFunction.inverse()
        • LinkFunction.derivative()