LinkSpec.validate_likelihood_compatibility#

static LinkSpec.validate_likelihood_compatibility(link, likelihood)[source]#

Raise if likelihood is incompatible with link.

The criterion is whether mu lives on the scale of the response. Under the identity link every contribution Deterministic is a share of mu, so a likelihood that places mu on another scale (LogNormal places it on the log scale) turns each *_original_scale variable into a delta on that other scale multiplied by target_scale, which is not a contribution in any units. Likelihoods that are not recognised warn instead of raising, so custom priors keep building.

The log link requires LogNormal so that the counterfactual decomposition (exp(mu) - exp(mu - media)) is correct.

The error message tells the reader to flip link and rebuild rather than refit. That works because the likelihood is handed the linear predictor directly and inverse_link is never applied to it, so link='identity' and link='log' with the same likelihood give the same observed-variable graph and the same free variables. Only the *_original_scale Deterministics differ, so an existing posterior is reinterpreted rather than invalidated.

Parameters:
linkLinkFunction

The link function used by the model.

likelihoodPrior

The likelihood distribution prior.

Raises:
ValueError

If the combination is known to produce incorrect downstream decomposition or optimisation results.

Warns:
UserWarning

If the likelihood is not one whose mu scale is known.