LinkSpec.validate_likelihood_compatibility#
- static LinkSpec.validate_likelihood_compatibility(link, likelihood)[source]#
Raise if likelihood is incompatible with link.
The criterion is whether
mulives on the scale of the response. Under the identity link every contribution Deterministic is a share ofmu, so a likelihood that placesmuon another scale (LogNormal places it on the log scale) turns each*_original_scalevariable into a delta on that other scale multiplied bytarget_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
linkand rebuild rather than refit. That works because the likelihood is handed the linear predictor directly andinverse_linkis never applied to it, solink='identity'andlink='log'with the same likelihood give the same observed-variable graph and the same free variables. Only the*_original_scaleDeterministics differ, so an existing posterior is reinterpreted rather than invalidated.- Parameters:
- link
LinkFunction The link function used by the model.
- likelihood
Prior The likelihood distribution prior.
- link
- Raises:
ValueErrorIf the combination is known to produce incorrect downstream decomposition or optimisation results.
- Warns:
UserWarningIf the likelihood is not one whose
muscale is known.