Skip to content

Link functions

A link function \(g(x)\) is a smooth, monotonic function of \(x\).

For all link functions, we implement

  • the link \(g(x)\)
  • the inverse \(g^{-1}(x)\)
  • the derivative of the link function \(\frac{\partial g(x)}{\partial x}\).
  • the first derivative of the inverse of the link function \(\frac{\partial g(x)^{-1}}{\partial x}\). The choice of the inverse is justified by Equation (7) in Hirsch, Berrisch & Ziel (2024).

The link functions implemented in ondil implemenent these as class methods each. Currently, we have implemented the identity-link, log-link and shifted log-link functions.

Link Function Description
IdentityLink Implements the identity link function \(g(x) = x\).
LogLink Implements the logarithmic link function \(g(x) = \log(x)\).
LogShiftValueLink Log link function with a shift value added to the inverse transformation.
LogShiftTwoLink Log link function ensuring \(\hat{\theta} > 2\).
LogIdentLink Combines identity and log transformations.
LogitLink Implements the logit link function \(g(x) = \log(x/(1-x))\).
SqrtLink Implements the square root link function \(g(x) = \sqrt{x}\).
SqrtShiftValueLink Square root link function with a shift value added to the inverse transformation.
SqrtShiftTwoLink Square root link function ensuring \(\hat{\theta} > 2\).
InverseSoftPlusLink Implements the inverse softplus link function.
InverseSoftPlusShiftValueLink Inverse softplus link function with a shift value added to the inverse transformation.
InverseSoftPlusShiftTwoLink Inverse softplus link function ensuring \(\hat{\theta} > 2\).

Some link functions implement shifted versions. The shifted link function is implemented in the sense that the shift is added to the inverse transformation. This way, we can ensure that distribution parameters can be modelled on the continuous space of the \(\eta = g(\theta)\), but in the inverse transform fullfill certain additional constraints. A common example is the \(t\) distribution, where we can use a LogShift2Link or SqrtShift2Link to ensure that \(\hat{\theta} = g^-1(\eta) > 2\) and the variance exists.

Base Class

ondil.base.LinkFunction

Bases: ABC

The base class for the link functions.

link_support: Tuple[float, float]

The support of the distribution.

inverse abstractmethod

inverse(x: ndarray) -> np.ndarray

Calculate the inverse of the link function

inverse_derivative abstractmethod

inverse_derivative(x: ndarray) -> np.ndarray

Calculate the first derivative for the inverse link function

link(x: ndarray) -> np.ndarray

Calculate the Link

link_derivative(x: ndarray) -> np.ndarray

Calculate the first derivative of the link function

link_second_derivative(x: ndarray) -> np.ndarray

Calculate the second derivative for the link function

API Reference

Bases: LinkFunction

The identity link function.

The identity link is defined as \(g(x) = x\).

Bases: LinkFunction

The log-link function.

The log-link function is defined as \(g(x) = \log(x)\).

Bases: LinkFunction

The Log-Link function shifted to a value \(v\).

This link function is defined as \(g(x) = \log(x - v)\). It can be used to ensure that certain distribution paramters don't fall below lower bounds, e.g. ensuring that the degrees of freedom of a Student's t distribtuion don't fall below 2, hence ensuring that the variance exists.

Bases: LogShiftValueLink

The Log-Link function shifted to 2.

This link function is defined as \(g(x) = \log(x - 2)\). It can be used to ensure that certain distribution paramters don't fall below lower bounds, e.g. ensuring that the degrees of freedom of a Student's t distribtuion don't fall below 2, hence ensuring that the variance exists.

Bases: LinkFunction

The Logident Link function.

The LogIdent Link function has been introduced by Narajewski & Ziel 2020 and can be used to avoid the exponential inverse for large values while keeping the log-behaviour in small ranges. This can stabilize the estimation procedure.

Bases: LinkFunction

The Logit Link function.

The logit-link function is defined as \(g(x) = \log (x/ (1-x))\).

Bases: LinkFunction

The square root Link function.

The square root link function is defined as \(\(g(x) = \sqrt(x)\)\).

Bases: LinkFunction

The Sqrt-Link function shifted to a value \(v\).

This link function is defined as \(\(g(x) = \sqrt(x - v)\)\). It can be used to ensure that certain distribution paramters don't fall below lower bounds, e.g. ensuring that the degrees of freedom of a Student's t distribtuion don't fall below 2, hence ensuring that the variance exists.

Bases: SqrtShiftValueLink

The Sqrt-Link function shifted to 2.

This link function is defined as \(\(g(x) = \sqrt(x - 2)\)\). It can be used to ensure that certain distribution paramters don't fall below lower bounds, e.g. ensuring that the degrees of freedom of a Student's t distribtuion don't fall below 2, hence ensuring that the variance exists.

Bases: LinkFunction

The softplus is defined as $$ \operatorname{SoftPlus(x)} = \log(1 + \exp(x)) $$ and hence the inverse is defined as $$ \log(\exp(x) - 1) $$ which can be used as link function for the parameters on the positive real line. The behavior of the inverse softplus is more graceful on large values as it avoids the exp of the log-link and converges towards a linear behaviour.

The softplus is the smooth approximation of \(\max(x, 0)\).

Bases: LinkFunction

The Inverse SoftPlus function shifted to a value \(v\).

Bases: InverseSoftPlusShiftValueLink

The Inverse SoftPlus function shifted to 2.